Skip to content

Commit

Permalink
Merge pull request #54 from GSA/fix-cf-integration-tests
Browse files Browse the repository at this point in the history
Fix cf integration tests
  • Loading branch information
rshewitt authored Apr 24, 2024
2 parents d06ecc9 + 0ecc6a1 commit fdf55ec
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ Once installed, `poetry install` installs dependencies into a local virtual envi

If you followed the instructions for `CKAN load testing` and `Harvester testing` you can simply run `poetry run pytest` to run all tests.

### Integration testing
- to run integration tests locally add the following env variables to your .env file in addition to their appropriate values
- CF_SERVICE_USER = "put username here"
- CF_SERVICE_AUTH = "put password here"

## Comparison

- `./tests/harvest_sources/ckan_datasets_resp.json`
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.6"
version = "0.3.7"
description = ""
# authors = [
# {name = "Jin Sun", email = "[email protected]"},
Expand Down
37 changes: 17 additions & 20 deletions tests/integration/cf/test_cf_tasks_int.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
class TestCFTasking:
def test_add_task(self, cf_handler, dhl_cf_task_data):
from time import sleep


assert cf_handler.start_task(**dhl_cf_task_data) is not None
class TestCFTasking:
def test_crud_task(self, cf_handler, dhl_cf_task_data):

def test_get_task(self, cf_handler, dhl_cf_task_data):
# start a new task
new_task = cf_handler.start_task(**dhl_cf_task_data)
sleep(2)
# retrieve that task via task guid
task = cf_handler.get_task(new_task["guid"])

task = cf_handler.get_task(
dhl_cf_task_data["app_guuid"], dhl_cf_task_data["task_id"]
# read the recent logs of the task
logs = cf_handler.read_recent_app_logs(
dhl_cf_task_data["app_guuid"], task["guid"]
)
assert task is not None
assert logs is not None

# cancel the task
cancelled_task = cf_handler.stop_task(task["guid"])
assert cancelled_task is not None

def test_get_all_app_tasks(self, cf_handler, dhl_cf_task_data):
tasks = cf_handler.get_all_app_tasks(dhl_cf_task_data["app_guuid"])
assert tasks is not None

def test_cancel_task(self, cf_handler, dhl_cf_task_data):

task = cf_handler.stop_task(dhl_cf_task_data["task_id"])
assert task is not None

def test_read_recent_task_logs(self, cf_handler, dhl_cf_task_data):

logs = cf_handler.read_recent_app_logs(
dhl_cf_task_data["app_guuid"], dhl_cf_task_data["task_id"]
)

assert logs is not None

1 comment on commit fdf55ec

@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.py5799 84%
TOTAL5727687% 

Tests Skipped Failures Errors Time
34 0 💤 0 ❌ 0 🔥 6.420s ⏱️

Please sign in to comment.