Skip to content

Commit

Permalink
Merge pull request #57 from GSA/get-source-by-jobid
Browse files Browse the repository at this point in the history
Get source by jobid
  • Loading branch information
jbrown-xentity authored Apr 25, 2024
2 parents c1fa24a + d64acc1 commit 8f52c3e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions app/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ def get_harvest_record_by_source(self, source_id):
HarvesterDBInterface._to_dict(rcd) for rcd in harvest_records]
return harvest_records_data

def get_source_by_jobid(self, jobid):
harvest_job = self.db.query(HarvestJob).filter_by(id=jobid).first()
if harvest_job is None:
return None
else:
return HarvesterDBInterface._to_dict(harvest_job.source)

def close(self):
if hasattr(self.db, "remove"):
self.db.remove()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "datagov-harvesting-logic"
version = "0.3.8"
version = "0.3.9"
description = ""
# authors = [
# {name = "Jin Sun", email = "[email protected]"},
Expand Down
15 changes: 15 additions & 0 deletions tests/database/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,18 @@ def test_delete_harvest_source(interface, source_data):

deleted_source = interface.get_harvest_source(source.id)
assert deleted_source is None

@pytest.fixture
def job_data(source_data):
return {"status": "new"}


def test_harvest_source_by_jobid(interface, source_data, job_data):

source = interface.add_harvest_source(source_data)
job_data["harvest_source_id"] = source.id

harvest_job = interface.add_harvest_job(job_data)
harvest_source = interface.get_source_by_jobid(harvest_job.id)

assert source.id == harvest_source["id"]

1 comment on commit 8f52c3e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
harvester
   __init__.py50100% 
   ckan_utils.py4222 95%
   exceptions.py420100% 
   harvest.py4256565 85%
   logger_config.py10100% 
   utils.py6299 85%
TOTAL5777687% 

Tests Skipped Failures Errors Time
35 0 💤 0 ❌ 0 🔥 3.818s ⏱️

Please sign in to comment.