Example #1
0
 def test_ensure_cfn_bucket_doesnt_exist_us_west(self):
     session = get_session("us-west-1")
     provider = Provider(session)
     action = BaseAction(
         context=mock_context("mynamespace"),
         provider_builder=MockProviderBuilder(provider, region="us-west-1")
     )
     stubber = Stubber(action.s3_conn)
     stubber.add_client_error(
         "head_bucket",
         service_error_code="NoSuchBucket",
         service_message="Not Found",
         http_status_code=404,
     )
     stubber.add_response(
         "create_bucket",
         service_response={},
         expected_params={
             "Bucket": ANY,
             "CreateBucketConfiguration": {
                 "LocationConstraint": "us-west-1",
             }
         }
     )
     with stubber:
         action.ensure_cfn_bucket()
Example #2
0
 def test_ensure_cfn_bucket_exists(self):
     provider = Provider("us-east-1")
     action = BaseAction(context=mock_context("mynamespace"),
                         provider=provider)
     stubber = Stubber(action.s3_conn)
     stubber.add_response("head_bucket",
                          service_response={},
                          expected_params={
                              "Bucket": ANY,
                          })
     with stubber:
         action.ensure_cfn_bucket()
Example #3
0
 def test_ensure_cfn_forbidden(self):
     provider = Provider("us-west-1")
     action = BaseAction(context=mock_context("mynamespace"),
                         provider=provider)
     stubber = Stubber(action.s3_conn)
     stubber.add_client_error(
         "head_bucket",
         service_error_code="AccessDenied",
         service_message="Forbidden",
         http_status_code=403,
     )
     with stubber:
         with self.assertRaises(botocore.exceptions.ClientError):
             action.ensure_cfn_bucket()
Example #4
0
 def test_ensure_cfn_bucket_exists(self):
     session = get_session("us-east-1")
     provider = Provider(session)
     action = BaseAction(
         context=mock_context("mynamespace"),
         provider_builder=MockProviderBuilder(provider)
     )
     stubber = Stubber(action.s3_conn)
     stubber.add_response(
         "head_bucket",
         service_response={},
         expected_params={
             "Bucket": ANY,
         }
     )
     with stubber:
         action.ensure_cfn_bucket()
Example #5
0
 def test_ensure_cfn_forbidden(self):
     session = get_session("us-west-1")
     provider = Provider(session)
     action = BaseAction(
         context=mock_context("mynamespace"),
         provider_builder=MockProviderBuilder(provider)
     )
     stubber = Stubber(action.s3_conn)
     stubber.add_client_error(
         "head_bucket",
         service_error_code="AccessDenied",
         service_message="Forbidden",
         http_status_code=403,
     )
     with stubber:
         with self.assertRaises(botocore.exceptions.ClientError):
             action.ensure_cfn_bucket()
Example #6
0
 def test_ensure_cfn_bucket_doesnt_exist_us_east(self):
     provider = Provider("us-east-1")
     action = BaseAction(context=mock_context("mynamespace"),
                         provider=provider)
     stubber = Stubber(action.s3_conn)
     stubber.add_client_error(
         "head_bucket",
         service_error_code="NoSuchBucket",
         service_message="Not Found",
         http_status_code=404,
     )
     stubber.add_response("create_bucket",
                          service_response={},
                          expected_params={
                              "Bucket": ANY,
                          })
     with stubber:
         action.ensure_cfn_bucket()
Example #7
0
 def test_ensure_cfn_bucket_doesnt_exist_us_west(self):
     session = get_session("us-west-1")
     provider = Provider(session)
     action = BaseAction(context=mock_context("mynamespace"),
                         provider_builder=MockProviderBuilder(
                             provider, region="us-west-1"))
     stubber = Stubber(action.s3_conn)
     stubber.add_client_error(
         "head_bucket",
         service_error_code="NoSuchBucket",
         service_message="Not Found",
         http_status_code=404,
     )
     stubber.add_response("create_bucket",
                          service_response={},
                          expected_params={
                              "Bucket": ANY,
                              "CreateBucketConfiguration": {
                                  "LocationConstraint": "us-west-1",
                              }
                          })
     with stubber:
         action.ensure_cfn_bucket()