|
| 1 | +"""Tests for the registry class object.""" |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | +from src.jsonid import registry_class |
| 6 | + |
| 7 | +registry_marker_tests = [ |
| 8 | + ( |
| 9 | + [ |
| 10 | + {"KEY": "$id", "STARTSWITH": "http://www.parcore.org/schema/"}, |
| 11 | + {"KEY": "$schema", "EXISTS": None}, |
| 12 | + {"KEY": "definitions", "ISTYPE": dict}, |
| 13 | + ], |
| 14 | + { |
| 15 | + "identifier": "", |
| 16 | + "name": [], |
| 17 | + "version": None, |
| 18 | + "description": [], |
| 19 | + "pronom": "", |
| 20 | + "wikidata": "", |
| 21 | + "loc": "", |
| 22 | + "archive_team": "", |
| 23 | + "rfc": "", |
| 24 | + "mime": [], |
| 25 | + "markers": [ |
| 26 | + {"KEY": "$id", "STARTSWITH": "http://www.parcore.org/schema/"}, |
| 27 | + {"KEY": "$schema", "EXISTS": None}, |
| 28 | + {"KEY": "definitions", "ISTYPE": "map"}, |
| 29 | + ], |
| 30 | + "depth": 0, |
| 31 | + "additional": "", |
| 32 | + "encoding": "", |
| 33 | + }, |
| 34 | + ), |
| 35 | + ( |
| 36 | + [ |
| 37 | + {"KEY": "$id", "STARTSWITH": "http://www.parcore.org/schema/"}, |
| 38 | + {"KEY": "$schema", "EXISTS": None}, |
| 39 | + {"KEY": "definitions", "ISTYPE": None}, |
| 40 | + ], |
| 41 | + { |
| 42 | + "identifier": "", |
| 43 | + "name": [], |
| 44 | + "version": None, |
| 45 | + "description": [], |
| 46 | + "pronom": "", |
| 47 | + "wikidata": "", |
| 48 | + "loc": "", |
| 49 | + "archive_team": "", |
| 50 | + "rfc": "", |
| 51 | + "mime": [], |
| 52 | + "markers": [ |
| 53 | + {"KEY": "$id", "STARTSWITH": "http://www.parcore.org/schema/"}, |
| 54 | + {"KEY": "$schema", "EXISTS": None}, |
| 55 | + {"KEY": "definitions", "ISTYPE": None}, |
| 56 | + ], |
| 57 | + "depth": 0, |
| 58 | + "additional": "", |
| 59 | + "encoding": "", |
| 60 | + }, |
| 61 | + ), |
| 62 | + ( |
| 63 | + [], |
| 64 | + { |
| 65 | + "identifier": "", |
| 66 | + "name": [], |
| 67 | + "version": None, |
| 68 | + "description": [], |
| 69 | + "pronom": "", |
| 70 | + "wikidata": "", |
| 71 | + "loc": "", |
| 72 | + "archive_team": "", |
| 73 | + "rfc": "", |
| 74 | + "mime": [], |
| 75 | + "markers": [], |
| 76 | + "depth": 0, |
| 77 | + "additional": "", |
| 78 | + "encoding": "", |
| 79 | + }, |
| 80 | + ), |
| 81 | +] |
| 82 | + |
| 83 | + |
| 84 | +@pytest.mark.parametrize("entry, expected", registry_marker_tests) |
| 85 | +def test_registry_entry_markers_json(entry, expected): |
| 86 | + """Outputting the markers as JSON requires some subtle changes to |
| 87 | + types so they can be stringified correctly. Test these work as |
| 88 | + throughout any changes to the code base. |
| 89 | + """ |
| 90 | + entry_obj = registry_class.RegistryEntry() |
| 91 | + entry_obj.markers = entry |
| 92 | + res = entry_obj.json() |
| 93 | + assert res == expected |
0 commit comments