Skip to content

Commit

Permalink
new: Validate all UUIDv5 as per spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Mar 4, 2025
1 parent 8241e9d commit 1ed7871
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import json
import unittest
import uuid

from pytaxonomies import Taxonomies
import pytaxonomies.api

Expand Down Expand Up @@ -85,6 +87,17 @@ def test_recreate_dump(self):
def test_validate_schema(self):
self.taxonomies_offline.validate_with_schema()

def test_validate_uuid5(self):
for taxonomy in self.taxonomies_offline.values():
expected_namespace_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, taxonomy.name)
self.assertEqual(taxonomy.uuid, str(expected_namespace_uuid))
for predicate in taxonomy.predicates.values():
expected_predicate_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, f'{taxonomy.name}:{predicate.predicate}')
self.assertEqual(predicate.uuid, str(expected_predicate_uuid))
for entry in predicate.entries.values():
expected_entry_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, f'{taxonomy.name}:{predicate.predicate}="{entry.value}"')
self.assertEqual(entry.uuid, str(expected_entry_uuid))


if __name__ == "__main__":
unittest.main()

0 comments on commit 1ed7871

Please sign in to comment.