From bda6c08e74dc622951981300d7470165585c9d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pomp=C3=A9ry?= Date: Tue, 16 Apr 2024 23:27:39 +0200 Subject: [PATCH] chore: update tests after new test data --- endpoint/src/main.rs | 33 ++++++--------------------------- endpoint/src/sample_data.rs | 2 +- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/endpoint/src/main.rs b/endpoint/src/main.rs index 8aafcfc..77dd965 100644 --- a/endpoint/src/main.rs +++ b/endpoint/src/main.rs @@ -660,7 +660,7 @@ fn get_list_with_filter_eq_test() { assert_eq!(rocket::http::Status::Ok, resp.status()); let json: PfListingResponseInner = resp.into_json().unwrap(); - assert_eq!(json.data.len(), 5); + assert_eq!(json.data.len(), 1); } #[test] @@ -677,7 +677,7 @@ fn get_list_with_filter_lt_test() { let bearer_token = format!("Bearer {jwt}"); - let get_list_with_limit_uri = "/2/footprints?$filter=updated+lt+'2023-01-01T00:00:00.000Z'"; + let get_list_with_limit_uri = "/2/footprints?$filter=updated+lt+'2023-06-27T13:00:00.000Z'"; let resp = client .get(get_list_with_limit_uri) @@ -687,7 +687,7 @@ fn get_list_with_filter_lt_test() { assert_eq!(rocket::http::Status::Ok, resp.status()); let json: PfListingResponseInner = resp.into_json().unwrap(); - assert_eq!(json.data.len(), 3); + assert_eq!(json.data.len(), 1); } #[test] @@ -703,7 +703,7 @@ fn get_list_with_filter_eq_and_lt_test() { let jwt = auth::encode_token(&token, key_pair).ok().unwrap(); let bearer_token = format!("Bearer {jwt}"); - let get_list_with_limit_uri = "/2/footprints?$filter=(pcf/geographyCountry+eq+'FR')+and+(updated+lt+'2023-01-01T00:00:00.000Z')"; + let get_list_with_limit_uri = "/2/footprints?$filter=(pcf/geographyCountry+eq+'FR')+and+(updated+lt+'2023-06-27T12:12:04.000Z')"; let resp = client .get(get_list_with_limit_uri) @@ -743,7 +743,7 @@ fn get_list_with_filter_any_test() { assert_eq!(rocket::http::Status::Ok, resp.status()); let json: PfListingResponseInner = resp.into_json().unwrap(); - assert_eq!(json.data.len(), 8); + assert_eq!(json.data.len(), 1); let get_list_with_limit_uri = "/2/footprints?$filter=productIds/any(productId:(productId+eq+'urn:gtin:12345'))"; @@ -774,7 +774,6 @@ fn get_list_with_limit_test() { let get_list_with_limit_uri = "/2/footprints?limit=3"; let expected_next_link1 = "/2/footprints?offset=3&limit=3"; - let expected_next_link2 = "/2/footprints?offset=6&limit=3"; { let resp = client @@ -799,26 +798,6 @@ fn get_list_with_limit_test() { { let resp = client .get(expected_next_link1) - .header(rocket::http::Header::new( - "Authorization", - bearer_token.clone(), - )) - .header(rocket::http::Header::new("Host", EXAMPLE_HOST)) - .dispatch(); - - assert_eq!(rocket::http::Status::Ok, resp.status()); - let link_header = resp.headers().get("link").next().unwrap().to_string(); - assert_eq!( - link_header, - format!("; rel=\"next\"") - ); - let json: PfListingResponseInner = resp.into_json().unwrap(); - assert_eq!(json.data.len(), 3); - } - - { - let resp = client - .get(expected_next_link2) .header(rocket::http::Header::new("Authorization", bearer_token)) .header(rocket::http::Header::new("Host", EXAMPLE_HOST)) .dispatch(); @@ -826,7 +805,7 @@ fn get_list_with_limit_test() { assert_eq!(rocket::http::Status::Ok, resp.status()); assert_eq!(resp.headers().get("link").next(), None); let json: PfListingResponseInner = resp.into_json().unwrap(); - assert_eq!(json.data.len(), 2); + assert_eq!(json.data.len(), 1); } } diff --git a/endpoint/src/sample_data.rs b/endpoint/src/sample_data.rs index 6cd7e37..7c80a5d 100644 --- a/endpoint/src/sample_data.rs +++ b/endpoint/src/sample_data.rs @@ -194,7 +194,7 @@ lazy_static!( boundary_processes_description: String::from("1) Material acquisition and preprocessing, including growth of trees 2) Production: fuel consumption, electricity consumption, water consumption, process-generated direct emissions 3) Distribution and storage: transportation of the finished product from manufacturing site to storage site"), reference_period_start: Utc.ymd(2021, 1, 1).and_hms(00, 00, 00), reference_period_end: Utc.ymd(2022, 1, 1).and_hms(00, 00, 00), - geographic_scope: Some(GeographicScope::Subdivision { geography_country_subdivision: String::from("FR-89").into() }), + geographic_scope: Some(GeographicScope::Country { geography_country: ISO3166CC("FR".into()) }), secondary_emission_factor_sources: Some(EmissionFactorDSSet(vec![EmissionFactorDS { name: String::from("Gabi").into(), version: String::from("2022").into(),