def test_read_data(self, mock_report, mock_query): reader = GoogleAdsReader(**self.kwargs) expected = [{ "AdGroupName": "ad_group_example", "Date": "2019-01-01", "Impressions": "0" }, { "AdGroupName": "ad_group_example", "Date": "2019-01-01", "Impressions": "4" }] for data in reader.read(): assert len(list(data.readlines())) != 0 for record, output in zip(data.readlines(), iter(expected)): assert record == output
def test_read_data_and_include_account_id(self, mock_report, mock_query): temp_kwargs = self.kwargs.copy() temp_kwargs.update({'include_client_customer_id': True}) reader = GoogleAdsReader(**temp_kwargs) expected = [{ "AdGroupName": "ad_group_example", "AccountId": "123-456-7890", "Date": "2019-01-01", "Impressions": "0" }, { "AdGroupName": "ad_group_example", "AccountId": "123-456-7890", "Date": "2019-01-01", "Impressions": "4" }] for data in reader.read(): assert len(list(data.readlines())) != 0 for record, output in zip(data.readlines(), iter(expected)): assert record == output