From d006ecabda5fb0a230029499b44bdc02e685435e Mon Sep 17 00:00:00 2001 From: Dan Noble Date: Mon, 18 Nov 2024 15:57:31 -0800 Subject: [PATCH] Added test case to cover fetching observations from sql when the requested date has a hyphen --- .../v2/observation/golden/direct/2024-09.json | 30 ++++++++++++++++++ .../v2/observation/golden/direct_test.go | 9 ++++++ test/datacommons.db | Bin 32768 -> 32768 bytes test/observations.csv | 4 +++ 4 files changed, 43 insertions(+) create mode 100644 internal/server/v2/observation/golden/direct/2024-09.json diff --git a/internal/server/v2/observation/golden/direct/2024-09.json b/internal/server/v2/observation/golden/direct/2024-09.json new file mode 100644 index 000000000..25f5ca479 --- /dev/null +++ b/internal/server/v2/observation/golden/direct/2024-09.json @@ -0,0 +1,30 @@ +{ + "by_variable": { + "var_with_hyphenated_date": { + "by_entity": { + "country/USA": { + "ordered_facets": [ + { + "facet_id": "2921750529", + "observations": [ + { + "date": "2024-09", + "value": 3 + } + ], + "obs_count": 1, + "earliest_date": "2024-09", + "latest_date": "2024-09" + } + ] + } + } + } + }, + "facets": { + "2921750529": { + "import_name": "Custom Prov", + "provenance_url": "custom.datacommons.org" + } + } +} \ No newline at end of file diff --git a/internal/server/v2/observation/golden/direct_test.go b/internal/server/v2/observation/golden/direct_test.go index eebdfa640..90e018a44 100644 --- a/internal/server/v2/observation/golden/direct_test.go +++ b/internal/server/v2/observation/golden/direct_test.go @@ -93,6 +93,15 @@ func TestFetchDirect(t *testing.T) { nil, "2010.json", }, + { + []string{ + "var_with_hyphenated_date", + }, + []string{"country/USA"}, + "2024-09", + nil, + "2024-09.json", + }, { []string{ "Area_Farm", diff --git a/test/datacommons.db b/test/datacommons.db index 8c63afead8ed6cb87b0e8560640bfadd2bbe3a20..3be81e5cfbb337f0216af79b3205a47095465b1e 100644 GIT binary patch delta 233 zcmZo@U}|V!njkHBl7WGN1Bh9Hm<5PCC+Zk8p4^zQgr7N-QDZW@z+w)@M~q7t(-<`- zHkNVPgmNp}O7lzdPL36lP|K(+$VkmgEJ;m?PXUrf21X{jh6X0drNt%rxi%q$lp0tX fLzM;-RBB-aRT_k(R2G{949pE7N;fMAJ;((BV;DlS delta 52 zcmZo@U}|V!njkH>lYxPO1Bh9Hm<5PyC+Zk8?%bHLgr7N(NntX(z~YUKWsI8@gdXGq E04f{}6aWAK diff --git a/test/observations.csv b/test/observations.csv index f3e6ee78c..d13405996 100644 --- a/test/observations.csv +++ b/test/observations.csv @@ -80,3 +80,7 @@ country/USA,var_with_props,2023,1,custom,USD,,,, country/GBR,var_with_props,2023,2,custom,USD,,,, country/USA,var_with_props,2023,3,custom,GBP,,,, country/GBR,var_with_props,2023,4,custom,GBP,,,, +country/USA,var_with_hyphenated_date,2024-07,1,custom,,,,, +country/USA,var_with_hyphenated_date,2024-08,2,custom,,,,, +country/USA,var_with_hyphenated_date,2024-09,3,custom,,,,, +country/USA,var_with_hyphenated_date,2024-10,4,custom,,,,,