예제 #1
0
 def test_should_raise_exception_when_body_empty(self):
     body = None
     with self.assertRaises(AirflowException) as cm:
         TransferJobValidator(body=body).validate_body()
     err = cm.exception
     self.assertIn("The required parameter 'body' is empty or None",
                   str(err))
예제 #2
0
    def test_verify_success(self, body):
        try:
            TransferJobValidator(body=body).validate_body()
            validated = True
        except AirflowException:
            validated = False

        self.assertTrue(validated)
예제 #3
0
 def test_should_raise_exception_when_encounters_aws_credentials(self):
     body = {"transferSpec": {"awsS3DataSource": {"awsAccessKey": TEST_AWS_ACCESS_KEY}}}
     with self.assertRaises(AirflowException) as cm:
         TransferJobValidator(body=body).validate_body()
     err = cm.exception
     self.assertIn(
         "AWS credentials detected inside the body parameter (awsAccessKey). This is not allowed, please "
         "use Airflow connections to store credentials.",
         str(err),
     )
예제 #4
0
    def test_verify_data_source(self, transfer_spec):
        body = {TRANSFER_SPEC: transfer_spec}

        with self.assertRaises(AirflowException) as cm:
            TransferJobValidator(body=body).validate_body()
        err = cm.exception
        self.assertIn(
            "More than one data source detected. Please choose exactly one data source from: "
            "gcsDataSource, awsS3DataSource and httpDataSource.",
            str(err),
        )
    def test_verify_success(self, body):

        TransferJobValidator(body=body).validate_body()

        self.assertTrue(True)