Esempio n. 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))
Esempio n. 2
0
    def test_verify_success(self, body):
        try:
            TransferJobValidator(body=body).validate_body()
            validated = True
        except AirflowException:
            validated = False

        assert validated
Esempio n. 3
0
    def test_verify_data_source(self, transfer_spec):
        body = {TRANSFER_SPEC: transfer_spec}

        with pytest.raises(AirflowException) as ctx:
            TransferJobValidator(body=body).validate_body()
        err = ctx.value
        assert (
            "More than one data source detected. Please choose exactly one data source from: "
            "gcsDataSource, awsS3DataSource and httpDataSource." in str(err))
Esempio n. 4
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),
     )
Esempio n. 5
0
 def test_should_raise_exception_when_body_empty(self):
     body = None
     with pytest.raises(AirflowException) as ctx:
         TransferJobValidator(body=body).validate_body()
     err = ctx.value
     assert "The required parameter 'body' is empty or None" in str(err)