Ejemplo n.º 1
0
    def test_should_error_on_request_with_no_dateranges(self):

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

        base_request_body_no_dateranges = settings.get(
            "base_request_body_no_dateranges"
        )
        with self.assertRaises(HttpError) as context:
            client.get_all_data(base_request_body_no_dateranges)
        self.assertTrue("HttpError 400" in str(context.exception))
Ejemplo n.º 2
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")
Ejemplo n.º 3
0
    def test_set_view_id_via_arg(self):

        view_id = settings.get("view_id")
        client = GAClient(view_id=view_id)
        self.assertEqual(client.view_id, view_id)
        res = client.get_all_data(
            settings.get("base_request_body_with_dateranges_no_viewid")
        )
        self.assertEqual(len(res["data"]), 7, "Result dataset should contain 7 rows")
Ejemplo n.º 4
0
    def test_should_get_data_on_request_with_dateranges_as_args(self):

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

        client = GAClient(
            settings.get("path_to_service_account"),
            view_id=settings["view_id"],
            start_date=start_date,
            end_date=end_date,
        )

        res = client.get_all_data(
            settings.get("base_request_body_no_dateranges_no_viewid")
        )
        self.assertEqual(len(res["data"]), 7, "Result dataset should contain 7 rows")
Ejemplo n.º 5
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")
Ejemplo n.º 6
0
 def test_should_have_more_than_100k_rows(self):
     client = GAClient(settings.get("path_to_service_account"))
     res = client.get_all_data(settings.get("request_body_with_100k_plus_rows"))
     self.assertGreater(len(res["data"]), 100000)
Ejemplo n.º 7
0
 def test_should_load_with_sampling(self):
     client = GAClient(settings.get("path_to_service_account"))
     res = client.get_all_data(settings.get("request_body_with_sampling"))
     self.assertIsNotNone(
         res["info"]["samplesReadCounts"], "Should have sampling size"
     )