Skip to content

Commit

Permalink
doh
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz committed Nov 24, 2024
1 parent d05753c commit ae652aa
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions tests/test_atproto_client/models/tests/test_string_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,61 @@
# https://github.com/bluesky-social/atproto/tree/main/interop-test-files/syntax
INTEROP_TEST_FILES_DIR: Path = Path('tests/test_atproto_client/interop-test-files/syntax')


def get_test_cases(filename: str) -> list[str]:
"""Get non-comment, non-empty lines from an interop test file."""
return [
line.strip() for line in INTEROP_TEST_FILES_DIR.joinpath(filename).read_text().splitlines()
line.strip()
for line in INTEROP_TEST_FILES_DIR.joinpath(filename).read_text().splitlines()
if line.strip() and not line.startswith('#')
]


@pytest.fixture
def valid_handles() -> list[str]:
return get_test_cases('handle_syntax_valid.txt')


@pytest.fixture
def valid_dids() -> list[str]:
return get_test_cases('did_syntax_valid.txt')


@pytest.fixture
def valid_nsids() -> list[str]:
return get_test_cases('nsid_syntax_valid.txt')


@pytest.fixture
def valid_aturis() -> list[str]:
return get_test_cases('aturi_syntax_valid.txt')


@pytest.fixture
def valid_datetimes() -> list[str]:
return get_test_cases('datetime_syntax_valid.txt')


@pytest.fixture
def valid_tids() -> list[str]:
return get_test_cases('tid_syntax_valid.txt')


@pytest.fixture
def valid_record_keys() -> list[str]:
return get_test_cases('recordkey_syntax_valid.txt')


@pytest.fixture
def valid_data(valid_handles: list[str], valid_dids: list[str], valid_nsids: list[str], valid_aturis: list[str],
valid_datetimes: list[str], valid_tids: list[str], valid_record_keys: list[str]) -> dict:
def valid_data(
valid_handles: list[str],
valid_dids: list[str],
valid_nsids: list[str],
valid_aturis: list[str],
valid_datetimes: list[str],
valid_tids: list[str],
valid_record_keys: list[str],
) -> dict:
return {
'handle': valid_handles[0],
'did': valid_dids[0],
Expand All @@ -62,6 +79,7 @@ def valid_data(valid_handles: list[str], valid_dids: list[str], valid_nsids: lis
'language': 'en-US', # No interop test file for language
}


@pytest.fixture
def invalid_data() -> dict:
return {
Expand All @@ -77,6 +95,7 @@ def invalid_data() -> dict:
'language': 'invalid!', # No interop test file for language
}


@pytest.mark.parametrize(
'validator_type,field_name,expected_error',
[
Expand Down

0 comments on commit ae652aa

Please sign in to comment.