From 4de05f316d39efaa627a05b3dcd9a8abf42eb2be Mon Sep 17 00:00:00 2001 From: Anandashankar Anil Date: Wed, 17 Jan 2024 17:40:34 +0100 Subject: [PATCH 1/2] Add some test conditions --- tests/test_ngi_data.py | 6 ++++-- tests/test_utils.py | 7 +++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/test_ngi_data.py b/tests/test_ngi_data.py index 28324e7..485c0e5 100644 --- a/tests/test_ngi_data.py +++ b/tests/test_ngi_data.py @@ -171,12 +171,14 @@ def test_save_data_to_disk(data_repo_full, mocked_statusdb_conn_rows): def test_get_data_with_project(data_repo_full, mocked_statusdb_conn_rows): """Test getting data for a specific order""" config_values = config.Config() + order_id = "NGI123457" with mock.patch("daily_read.statusdb.StatusDBSession"): data_master = ngi_data.ProjectDataMaster(config_values) data_master.sources[0].statusdb_session.rows.return_value = mocked_statusdb_conn_rows - data_master.get_data("NGI123457") + data_master.get_data(order_id) assert len(data_master.data.keys()) == 1 - assert "NGI123457" in data_master.data + assert order_id in data_master.data + assert data_master.data[order_id].internal_id_or_portal_id == order_id def test_get_data_with_project_unknown(data_repo_full, mocked_statusdb_conn_rows): diff --git a/tests/test_utils.py b/tests/test_utils.py index 04f1382..05fa7b3 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -3,11 +3,12 @@ from daily_read import utils +daily_read_module_name = "tests" +log = logging.getLogger(daily_read_module_name) + def test_error_reporting_without_error(): """Test that no error is raised when the log has no error messages""" - daily_read_module_name = "tests" - log = logging.getLogger(daily_read_module_name) log.info("Test info") log.warning("Warn message") try: @@ -18,8 +19,6 @@ def test_error_reporting_without_error(): def test_error_reporting_with_error(): """Test error thrown when the log has error messages""" - daily_read_module_name = "tests" - log = logging.getLogger(daily_read_module_name) log.error("Test error message") with pytest.raises(RuntimeError, match=f"Errors logged in {daily_read_module_name} during execution"): utils.error_reporting(log, "tests") From f40b7cbe927d5ab3ce9fab5a72463b7a5b01c5c1 Mon Sep 17 00:00:00 2001 From: Anandashankar Anil Date: Wed, 17 Jan 2024 17:47:58 +0100 Subject: [PATCH 2/2] Right param --- tests/test_ngi_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_ngi_data.py b/tests/test_ngi_data.py index 485c0e5..633580a 100644 --- a/tests/test_ngi_data.py +++ b/tests/test_ngi_data.py @@ -178,7 +178,7 @@ def test_get_data_with_project(data_repo_full, mocked_statusdb_conn_rows): data_master.get_data(order_id) assert len(data_master.data.keys()) == 1 assert order_id in data_master.data - assert data_master.data[order_id].internal_id_or_portal_id == order_id + assert data_master.data[order_id].internal_id_or_portal_id == "P123457" def test_get_data_with_project_unknown(data_repo_full, mocked_statusdb_conn_rows):