1+ import datetime
12import os
2- import re
33import unittest
44from unittest .mock import patch , MagicMock
55
@@ -21,15 +21,17 @@ def test_inserts_one_row_per_taxonomy_per_source_assembly(self):
2121 ('EVA' , '9913,9940' , 'Cattle' , 'GCA_000000001.1' , 'GCA_000003055.3' , 10 , 'Completed' ),
2222 ('EVA' , '9940' , 'Cattle' , 'GCA_000000002.1' , 'GCA_000003055.3' , 5 , 'Completed' ),
2323 ]
24+ mocked_now = datetime .datetime .now ()
2425 with patch ('eva_assembly_ingestion.assembly_ingestion_job.get_metadata_connection_handle' ), \
2526 patch ('eva_assembly_ingestion.assembly_ingestion_job.execute_query' ) as mock_execute_query , \
26- patch .object (self .remapping_job , 'get_job_information_from_tracker' , return_value = tracker_rows ):
27+ patch .object (self .remapping_job , 'get_job_information_from_tracker' , return_value = tracker_rows ), \
28+ patch ('eva_assembly_ingestion.assembly_ingestion_job.datetime' ) as mock_datetime :
29+ mock_datetime .datetime .now .return_value = mocked_now
2730 self .remapping_job .add_to_clustered_variant_update ()
2831 captured_queries = [c [1 ][1 ] for c in mock_execute_query .mock_calls ]
29- print (captured_queries )
3032 expected_queries = [
31- "INSERT INTO evapro.clustered_variant_update (taxonomy_id, assembly_accession, source, ingestion_time) VALUES (9913, 'GCA_000003055.3', 'GCA_000000001.1', '2026-04-10 16:21:35.400490 ')" ,
32- "INSERT INTO evapro.clustered_variant_update (taxonomy_id, assembly_accession, source, ingestion_time) VALUES (9940, 'GCA_000003055.3', 'GCA_000000001.1', '2026-04-10 16:21:35.400490 ')" ,
33- "INSERT INTO evapro.clustered_variant_update (taxonomy_id, assembly_accession, source, ingestion_time) VALUES (9940, 'GCA_000003055.3', 'GCA_000000002.1', '2026-04-10 16:21:35.400490 ')"
33+ f "INSERT INTO evapro.clustered_variant_update (taxonomy_id, assembly_accession, source, ingestion_time) VALUES (9913, 'GCA_000003055.3', 'GCA_000000001.1', '{ mocked_now . strftime ( '%Y-%m-%d %H:%M:%S.%f' ) } ')" ,
34+ f "INSERT INTO evapro.clustered_variant_update (taxonomy_id, assembly_accession, source, ingestion_time) VALUES (9940, 'GCA_000003055.3', 'GCA_000000001.1', '{ mocked_now . strftime ( '%Y-%m-%d %H:%M:%S.%f' ) } ')" ,
35+ f "INSERT INTO evapro.clustered_variant_update (taxonomy_id, assembly_accession, source, ingestion_time) VALUES (9940, 'GCA_000003055.3', 'GCA_000000002.1', '{ mocked_now . strftime ( '%Y-%m-%d %H:%M:%S.%f' ) } ')"
3436 ]
3537 assert captured_queries == expected_queries
0 commit comments