def test_set_view_id(self): client = GAClient(settings.get("path_to_service_account")) view_id = settings.get("view_id") client.set_view_id(view_id) self.assertEqual(client.view_id, view_id)
def test_should_load_data_with_overridden_view_id_and_dateranges(self): client = GAClient(settings.get("path_to_service_account")) client.set_view_id("1234567890") client.set_dateranges("2019-01-01", "2019-01-01") res = client.get_all_data( settings.get("base_request_body_with_dateranges_and_view_id") ) self.assertEqual(len(res["data"]), 7, "Result dataset should contain 7 rows")
def test_should_load_data_on_request_after_dateranges_set(self): base_request_body_no_dateranges = settings.get( "base_request_body_no_dateranges" ) start_date = daterange_settings.get("start_date") end_date = daterange_settings.get("end_date") client = GAClient(settings.get("path_to_service_account")) client.set_view_id(settings.get("view_id")) client.set_dateranges(start_date, end_date) res = client.get_all_data(base_request_body_no_dateranges) self.assertIs( res["info"]["isDataGolden"], True, "info.isDataGolden should be True" ) self.assertIsNone(res["info"]["nextPageToken"], "NextPageToken should be None") self.assertIsNone( res["info"]["samplingSpaceSizes"], "Data should not be sampled" ) self.assertIsNone( res["info"]["samplesReadCounts"], "Data should not be sampled" ) self.assertEqual(len(res["data"]), 7, "Result dataset should contain 7 rows")