diff --git a/tests/test_atproto_client/models/tests/test_string_formats.py b/tests/test_atproto_client/models/tests/test_string_formats.py index 16725ee4..dd973d08 100644 --- a/tests/test_atproto_client/models/tests/test_string_formats.py +++ b/tests/test_atproto_client/models/tests/test_string_formats.py @@ -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], @@ -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 { @@ -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', [