Beispiel #1
0
    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")
Beispiel #2
0
    def test_set_dateranges_strings(self):

        client = GAClient(settings.get("path_to_service_account"))

        start_date = daterange_settings.get("start_date")
        end_date = daterange_settings.get("end_date")

        client.set_dateranges(start_date, end_date)
        self.assertIsInstance(client.start_date, date)
        self.assertIsInstance(client.end_date, date)

        self.assertEqual(
            start_date,
            client.start_date.strftime("%Y-%m-%d"),
            msg="Start date is not equal",
        )
        self.assertEqual(
            end_date,
            client.end_date.strftime("%Y-%m-%d"),
            msg="Start date is not equal",
        )
Beispiel #3
0
    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")