Procházet zdrojové kódy

Modify bulk tests to use object codes

stephenjboyle před 7 měsíci
rodič
revize
7f2c76ece0

+ 5 - 5
tests/test_prodcom.py

@@ -45,7 +45,7 @@ class TestProdcom2016Data:
             GEONAMES["2635167"],
             metric,
             PROBS.SoldProduction,
-            object_code = code
+            object_code=code
         )
         assert_exact_results(result, expected_value)
 
@@ -62,7 +62,7 @@ class TestProdcom2016Data:
             GEONAMES["2635167"] ,
             metric,
             PROBS.SoldProduction,
-            object_code = code
+            object_code=code
         )
         assert_no_measurement(result)
 
@@ -77,7 +77,7 @@ class TestProdcom2016Data:
             GEONAMES["2635167"] ,
             metric,
             PROBS.SoldProduction,
-            object_code = code
+            object_code=code
         )
         assert_no_result(result)
 
@@ -103,7 +103,7 @@ class TestProdcom2017Data:
             GEONAMES["2635167"],
             metric,
             PROBS.SoldProduction,
-            object_code = code
+            object_code=code
         )
         assert_exact_results(result, expected_value)
 
@@ -129,6 +129,6 @@ class TestProdcom2018Data:
             GEONAMES["2635167"],
             metric,
             PROBS.SoldProduction,
-            object_code = code
+            object_code=code
         )
         assert_exact_results(result, expected_value)

+ 11 - 12
tests/test_prodcom_bulk_sold.py

@@ -25,16 +25,13 @@ def assert_no_result(result):
     assert len(result) == 0
 
 
-def obj_id(obj_code):
-    return ("Object-" + sha256(obj_code.encode('utf-8')).hexdigest())
-
-
 # Do most tests for 2016; then spot check a few values for the other years
 
 class TestProdcom2016Data:
     """Test PRODCOM2016 DATA conversion"""
 
-    endpoint_data = ["outputs/sold_production/DS-056120_006-2016.nt.gz"]
+    endpoint_data = ["outputs/sold_production/DS-056120_006-2016.nt.gz",
+                     "outputs/PRD_2017_20200617_185035.nt.gz"]
 
     @pytest.mark.parametrize("code,metric,expected_value", [
         ("10113250", QUANTITYKIND.Mass, 2717950),
@@ -49,7 +46,7 @@ class TestProdcom2016Data:
             GEONAMES["2635167"],
             metric,
             PROBS.SoldProduction,
-            object_=PRODCOM2017["Object-" + code]
+            object_code=code
         )
         assert_exact_results(result, expected_value)
 
@@ -64,7 +61,7 @@ class TestProdcom2016Data:
             GEONAMES["2635167"] ,
             metric,
             PROBS.SoldProduction,
-            object_=PRODCOM2017["Object-" + code],
+            object_code=code,
         )
         assert_no_result(result)
 
@@ -79,7 +76,7 @@ class TestProdcom2016Data:
             GEONAMES["2635167"] ,
             metric,
             PROBS.SoldProduction,
-            object_=PRODCOM2017["Object-" + code],
+            object_code=code,
         )
         assert_no_result(result)
 
@@ -90,7 +87,8 @@ class TestProdcom2017Data:
     Just include a few expected values, since other behaviour is tested for the 2016 data.
     """
 
-    endpoint_data = ["outputs/sold_production/DS-056120_006-2017.nt.gz"]
+    endpoint_data = ["outputs/sold_production/DS-056120_006-2017.nt.gz",
+                     "outputs/PRD_2017_20200617_185035.nt.gz"]
 
     @pytest.mark.parametrize("code,metric,expected_value", [
         ("10721253", QUANTITYKIND.Mass, 244871494),
@@ -104,7 +102,7 @@ class TestProdcom2017Data:
             GEONAMES["2635167"],
             metric,
             PROBS.SoldProduction,
-            object_=PRODCOM2017["Object-" + code]
+            object_code=code
         )
         assert_exact_results(result, expected_value)
 
@@ -115,7 +113,8 @@ class TestProdcom2018Data:
     Just include a few expected values, since other behaviour is tested for the 2016 data.
     """
 
-    endpoint_data = ["outputs/sold_production/DS-056120_006-2018.nt.gz"]
+    endpoint_data = ["outputs/sold_production/DS-056120_006-2018.nt.gz",
+                     "outputs/PRD_2017_20200617_185035.nt.gz"]
 
     @pytest.mark.parametrize("code,metric,expected_value", [
         ("10131120", QUANTITYKIND.Mass, 104282828),
@@ -129,6 +128,6 @@ class TestProdcom2018Data:
             GEONAMES["2635167"],
             metric,
             PROBS.SoldProduction,
-            object_=PRODCOM2017["Object-" + code]
+            object_code=code
         )
         assert_exact_results(result, expected_value)

+ 11 - 13
tests/test_prodcom_bulk_total.py

@@ -25,16 +25,13 @@ def assert_no_result(result):
     assert len(result) == 0
 
 
-def obj_id(obj_code):
-    return ("Object-" + sha256(obj_code.encode('utf-8')).hexdigest())
-
-
 # Do most tests for 2016; then spot check a few values for the other years
 
 class TestProdcom2016Data:
     """Test PRODCOM2016 DATA conversion"""
 
-    endpoint_data = ["outputs/total_production/DS-056121_006-2016.nt.gz"]
+    endpoint_data = ["outputs/total_production/DS-056121_006-2016.nt.gz",
+                     "outputs/PRD_2017_20200617_185035.nt.gz"]
 
     @pytest.mark.parametrize("code,metric,expected_value", [
         ("13103100", QUANTITYKIND.Mass, 224299),
@@ -49,7 +46,7 @@ class TestProdcom2016Data:
             GEONAMES["2635167"],
             metric,
             PROBS.TotalProduction,
-            object_=PRODCOM2017["Object-" + code]
+            object_code=code
         )
         assert_exact_results(result, expected_value)
 
@@ -64,10 +61,9 @@ class TestProdcom2016Data:
             GEONAMES["2635167"] ,
             metric,
             PROBS.TotalProduction,
-            object_=PRODCOM2017["Object-" + code],
+            object_code=code,
         )
         assert_no_result(result)
-        print(PRODCOM2017[obj_id(code)])
 
     @pytest.mark.parametrize("code,metric", [
         ("13201230", QUANTITYKIND.Mass),
@@ -80,7 +76,7 @@ class TestProdcom2016Data:
             GEONAMES["2635167"] ,
             metric,
             PROBS.TotalProduction,
-            object_=PRODCOM2017["Object-" + code],
+            object_code=code,
         )
         assert_no_result(result)
 
@@ -91,7 +87,8 @@ class TestProdcom2017Data:
     Just include a few expected values, since other behaviour is tested for the 2016 data.
     """
 
-    endpoint_data = ["outputs/total_production/DS-056121_006-2017.nt.gz"]
+    endpoint_data = ["outputs/total_production/DS-056121_006-2017.nt.gz",
+                     "outputs/PRD_2017_20200617_185035.nt.gz"]
 
     @pytest.mark.parametrize("code,metric,expected_value", [
         ("08111250", QUANTITYKIND.Mass, 604132000),
@@ -105,7 +102,7 @@ class TestProdcom2017Data:
             GEONAMES["2635167"],
             metric,
             PROBS.TotalProduction,
-            object_=PRODCOM2017["Object-" + code]
+            object_code=code
         )
         assert_exact_results(result, expected_value)
 
@@ -116,7 +113,8 @@ class TestProdcom2018Data:
     Just include a few expected values, since other behaviour is tested for the 2016 data.
     """
 
-    endpoint_data = ["outputs/total_production/DS-056121_006-2018.nt.gz"]
+    endpoint_data = ["outputs/total_production/DS-056121_006-2018.nt.gz",
+                     "outputs/PRD_2017_20200617_185035.nt.gz"]
 
     @pytest.mark.parametrize("code,metric,expected_value", [
         ("08114000", QUANTITYKIND.Mass, 41455000),
@@ -130,6 +128,6 @@ class TestProdcom2018Data:
             GEONAMES["2635167"],
             metric,
             PROBS.TotalProduction,
-            object_=PRODCOM2017["Object-" + code]
+            object_code=code
         )
         assert_exact_results(result, expected_value)