Beispiel #1
0
 def test_start_manifest_processing(self, mock_download_manifest, mock_task):
     """Test start_manifest_processing."""
     test_matrix = [
         {"mock_downloader_manifest": {}, "expect_chord_called": False},
         {
             "mock_downloader_manifest": {
                 "manifest_id": 1,
                 "files": [{"local_file": "file1.csv", "key": "filekey"}],
             },
             "expect_chord_called": True,
         },
     ]
     for test in test_matrix:
         mock_download_manifest.return_value = test.get("mock_downloader_manifest")
         orchestrator = Orchestrator()
         account = self.mock_accounts[0]
         orchestrator.start_manifest_processing(
             account.get("customer_name"),
             account.get("authentication"),
             account.get("billing_source"),
             "AWS-local",
             account.get("schema_name"),
             account.get("provider_uuid"),
             DateAccessor().get_billing_months(1)[0],
         )
         if test.get("expect_chord_called"):
             mock_task.assert_called()
         else:
             mock_task.assert_not_called()
Beispiel #2
0
 def test_start_manifest_processing_priority_queue(self,
                                                   mock_download_manifest,
                                                   mock_task, mock_inspect):
     """Test start_manifest_processing using priority queue."""
     test_queues = [
         {
             "name": "qe-account",
             "provider_uuid": str(uuid4()),
             "queue-name": "priority",
             "expected": "priority"
         },
         {
             "name": "qe-account",
             "provider_uuid": None,
             "queue-name": "priority",
             "expected": "summary"
         },
         {
             "name": "qe-account",
             "provider_uuid": str(uuid4()),
             "queue-name": None,
             "expected": "summary"
         },
     ]
     mock_manifest = {
         "mock_downloader_manifest": {
             "manifest_id": 1,
             "files": [{
                 "local_file": "file1.csv",
                 "key": "filekey"
             }]
         }
     }
     for test in test_queues:
         with self.subTest(test=test.get("name")):
             mock_download_manifest.return_value = mock_manifest.get(
                 "mock_downloader_manifest")
             orchestrator = Orchestrator(
                 provider_uuid=test.get("provider_uuid"),
                 queue_name=test.get("queue-name"))
             account = self.mock_accounts[0]
             orchestrator.start_manifest_processing(
                 account.get("customer_name"),
                 account.get("credentials"),
                 account.get("data_source"),
                 "AWS-local",
                 account.get("schema_name"),
                 account.get("provider_uuid"),
                 DateAccessor().get_billing_months(1)[0],
             )
             actual_queue = mock_task.call_args.args[1].options.get("queue")
             self.assertEqual(actual_queue, test.get("expected"))
Beispiel #3
0
    def test_start_manifest_processing_in_progress(self, mock_record_report_status, mock_download_manifest, mock_task):
        """Test start_manifest_processing with report in progressed."""
        orchestrator = Orchestrator()
        account = self.mock_accounts[0]

        orchestrator.start_manifest_processing(
            account.get("customer_name"),
            account.get("authentication"),
            account.get("billing_source"),
            "AWS-local",
            account.get("schema_name"),
            account.get("provider_uuid"),
            DateAccessor().get_billing_months(1)[0],
        )
        mock_task.assert_not_called()
Beispiel #4
0
    def test_start_manifest_processing_already_progressed(
            self, mock_record_report_status, mock_download_manifest, mock_task,
            mock_inspect):
        """Test start_manifest_processing with report already processed."""
        orchestrator = Orchestrator()
        account = self.mock_accounts[0]

        orchestrator.start_manifest_processing(
            account.get("customer_name"),
            account.get("credentials"),
            account.get("data_source"),
            "AWS-local",
            account.get("schema_name"),
            account.get("provider_uuid"),
            DateAccessor().get_billing_months(1)[0],
        )
        mock_task.assert_not_called()