Skip to content

Commit

Permalink
Aggregate test
Browse files Browse the repository at this point in the history
  • Loading branch information
loleg committed Nov 30, 2022
1 parent e96ea09 commit 2a0e1cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions dribdat/apipackage.py
Expand Up @@ -260,6 +260,9 @@ def ImportEventPackage(data, DRY_RUN=False, ALL_DATA=False):

def fetch_datapackage(url, DRY_RUN=False, ALL_DATA=False):
"""Get event data from a URL."""
if not url.endswith('datapackage.json'):
logging.error("Invalid URL", url)
return {}
try:
data = requests.get(url, timeout=REQUEST_TIMEOUT).json()
return ImportEventPackage(data, DRY_RUN, ALL_DATA)
Expand Down
8 changes: 3 additions & 5 deletions tests/test_aggregate.py
Expand Up @@ -5,17 +5,15 @@


class TestAggregate:
"""Here be dataragons!"""
"""Here be dataragons."""

def test_datapackage(self):
"""Test parsing a Data Package."""
test_url = 'https://meta.dribdat.cc/api/event/5/datapackage.json'
test_url = 'https://meta.dribdat.cc/api/event/current/datapackage.json'
test_obj = GetProjectData(test_url)
assert 'name' in test_obj
assert test_obj['name'] == 'event-5'
assert test_obj['type'] == 'Data Package'
tl = 'Event and project details collected with dribdat'
assert tl in test_obj['description']
assert 'dribdat' in test_obj['description']
assert test_url in test_obj['source_url']

def test_gitea(self):
Expand Down

0 comments on commit 2a0e1cf

Please sign in to comment.