Skip to content

Commit

Permalink
Added test.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjohns-scottlogic committed Jan 6, 2025
1 parent 1a7309f commit 6a18a4d
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/unit/test_collection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from digital_land.register import hash_value, Item
from digital_land.collection import Collection, LogStore
from digital_land.collection import Collection, LogStore, ResourceLogStore, CSVStore
from digital_land.schema import Schema
from datetime import datetime

Expand Down Expand Up @@ -90,3 +91,30 @@ def test_format_date():
for date in dates:
print(date)
assert Collection.format_date(date) == check


def test_endpoint_source_mismatch():
log = LogStore(Schema("log"))
log.add_entry(
{
"endpoint": "abc123",
"entry-date": "2025-01-06",
"resource": "aaa",
"bytes": "1024",
}
)

# This one matches
source = CSVStore(Schema("source"))
source.add_entry({"endpoint": "abc123", "organisation": "test-org"})

resource = ResourceLogStore(Schema("resource"))
resource.load(log, source)

# This one doesn't
source = CSVStore(Schema("source"))
source.add_entry({"endpoint": "abc124", "organisation": "test-org"})

resource = ResourceLogStore(Schema("resource"))
with pytest.raises(RuntimeError):
resource.load(log, source)

0 comments on commit 6a18a4d

Please sign in to comment.