@@ -47,6 +47,7 @@ def test_postgres_edla_write_with_optional_fields():
4747 "source_app_version" : "1.0.0" ,
4848 "environment" : "dev" ,
4949 "timestamp_event" : 111 ,
50+ "country" : "za" ,
5051 "catalog_id" : "db.tbl" ,
5152 "operation" : "append" ,
5253 "location" : "s3://bucket/path" ,
@@ -57,12 +58,13 @@ def test_postgres_edla_write_with_optional_fields():
5758 writer_postgres .postgres_edla_write (cur , "table_a" , message )
5859 assert len (cur .executions ) == 1
5960 _sql , params = cur .executions [0 ]
60- assert len (params ) == 12
61+ assert len (params ) == 13
6162 assert params [0 ] == "e1"
62- assert params [8 ] == "s3://bucket/path"
63- assert params [9 ] == "parquet"
64- assert json .loads (params [10 ]) == {"compression" : "snappy" }
65- assert json .loads (params [11 ]) == {"foo" : "bar" }
63+ assert params [6 ] == "za"
64+ assert params [9 ] == "s3://bucket/path"
65+ assert params [10 ] == "parquet"
66+ assert json .loads (params [11 ]) == {"compression" : "snappy" }
67+ assert json .loads (params [12 ]) == {"foo" : "bar" }
6668
6769
6870def test_postgres_edla_write_missing_optional ():
@@ -80,10 +82,11 @@ def test_postgres_edla_write_missing_optional():
8082 }
8183 writer_postgres .postgres_edla_write (cur , "table_a" , message )
8284 _sql , params = cur .executions [0 ]
83- assert params [8 ] is None
84- assert params [9 ] == "delta"
85- assert params [10 ] is None
85+ assert params [6 ] == ""
86+ assert params [9 ] is None
87+ assert params [10 ] == "delta"
8688 assert params [11 ] is None
89+ assert params [12 ] is None
8790
8891
8992def test_postgres_run_write ():
@@ -100,6 +103,7 @@ def test_postgres_run_write():
100103 "jobs" : [
101104 {"catalog_id" : "c1" , "status" : "succeeded" , "timestamp_start" : 1100 , "timestamp_end" : 1200 },
102105 {
106+ "country" : "bw" ,
103107 "catalog_id" : "c2" ,
104108 "status" : "failed" ,
105109 "timestamp_start" : 1300 ,
@@ -111,12 +115,23 @@ def test_postgres_run_write():
111115 }
112116 writer_postgres .postgres_run_write (cur , "runs_table" , "jobs_table" , message )
113117 assert len (cur .executions ) == 3
118+
119+ # Check run insert
114120 run_sql , run_params = cur .executions [0 ]
115121 assert "source_app_version" in run_sql
116122 assert run_params [3 ] == "runapp"
123+
124+ # Check first job
125+ _job1_sql , job1_params = cur .executions [1 ]
126+ assert job1_params [1 ] == ""
127+ assert job1_params [2 ] == "c1"
128+
129+ # Check second job
117130 _job2_sql , job2_params = cur .executions [2 ]
118- assert job2_params [5 ] == "err"
119- assert json .loads (job2_params [6 ]) == {"k" : "v" }
131+ assert job2_params [1 ] == "bw"
132+ assert job2_params [2 ] == "c2"
133+ assert job2_params [6 ] == "err"
134+ assert json .loads (job2_params [7 ]) == {"k" : "v" }
120135
121136
122137def test_postgres_test_write ():
0 commit comments