Esempio n. 1
0
 def test_validate_dates(self, mock_build_headers):
     temp_kwargs = self.kwargs.copy()
     params = {
         "start_date": datetime(2020, 1, 3),
         "end_date": datetime(2020, 1, 1)
     }
     temp_kwargs.update(params)
     with self.assertRaises(DateDefinitionException):
         TheTradeDeskReader(**temp_kwargs)
Esempio n. 2
0
 def test_read(self, mock_build_headers, mock_retry, mock_download_report):
     reader = TheTradeDeskReader(**self.kwargs)
     reader.report_template_id = 1234
     reader.report_schedule_id = 5678
     reader.download_url = "https://download.url"
     output = next(reader.read())
     expected = [
         {
             "Date": "2020-01-01",
             "Advertiser ID": "XXXXX",
             "Impressions": 10
         },
         {
             "Date": "2020-02-01",
             "Advertiser ID": "XXXXX",
             "Impressions": 11
         },
         {
             "Date": "2020-02-03",
             "Advertiser ID": "XXXXX",
             "Impressions": 12
         },
     ]
     for output_record, expected_record in zip(output.readlines(),
                                               iter(expected)):
         self.assertEqual(output_record, expected_record)
def the_trade_desk(**kwargs):
    return TheTradeDeskReader(**extract_args("ttd_", kwargs))
Esempio n. 4
0
 def test_get_report_template_id_if_exactly_1_match(self,
                                                    mock_build_headers,
                                                    mock_api_call):
     reader = TheTradeDeskReader(**self.kwargs)
     reader._get_report_template_id()
     self.assertEqual(reader.report_template_id, 1234)
Esempio n. 5
0
 def test_wait_for_download_url(self, mock_build_headers, mock_retry,
                                mock_api_call):
     reader = TheTradeDeskReader(**self.kwargs)
     reader.report_schedule_id = 5678
     reader._wait_for_download_url()
     self.assertEqual(reader.download_url, "https://download.url")
Esempio n. 6
0
 def test_create_report_schedule(self, mock_build_headers, mock_api_call):
     reader = TheTradeDeskReader(**self.kwargs)
     reader.report_template_id = 1234
     reader._create_report_schedule()
     self.assertEqual(reader.report_schedule_id, 5678)
Esempio n. 7
0
 def test_get_report_template_id_if_no_match(self, mock_build_headers,
                                             mock_api_call):
     with self.assertRaises(Exception):
         TheTradeDeskReader(**self.kwargs)._get_report_template_id()