File: test_python_snippet_updater.py

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (45 lines) | stat: -rw-r--r-- 1,332 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
import pytest
from ci_tools.snippet_update.python_snippet_updater import (
    get_snippet,
    update_snippet,
    check_snippets,
    check_not_up_to_date,
)


def test_get_snippet():
    folder = os.path.dirname(os.path.abspath(__file__))
    file = os.path.join(folder, "example_async.py")
    get_snippet(file)
    snippets = check_snippets().keys()
    assert len(snippets) == 7
    assert "example_async.trio" in snippets
    assert "example_async.async_retry_policy" in snippets


def test_update_snippet():
    folder = os.path.dirname(os.path.abspath(__file__))
    file = os.path.join(folder, "example_async.py")
    get_snippet(file)
    file_1 = os.path.join(folder, "README.md")
    update_snippet(file_1)


def test_missing_snippet():
    folder = os.path.dirname(os.path.abspath(__file__))
    file = os.path.join(folder, "example_async.py")
    get_snippet(file)
    file_1 = os.path.join(folder, "README_missing_snippet.md")
    with pytest.raises(SystemExit):
        update_snippet(file_1)


def test_out_of_sync():
    folder = os.path.dirname(os.path.abspath(__file__))
    file = os.path.join(folder, "example_async.py")
    get_snippet(file)
    file_1 = os.path.join(folder, "README_out_of_sync.md")
    update_snippet(file_1)
    not_up_to_date = check_not_up_to_date()
    assert not_up_to_date