Exemplo n.º 1
0
 def test_init(self):
     """test __init__()"""
     cls = _Route53Service(21, 43)
     assert cls.service_name == 'Route53'
     assert cls.api_name == 'route53'
     assert cls.conn is None
     assert cls.warning_threshold == 21
     assert cls.critical_threshold == 43
Exemplo n.º 2
0
 def test_get_limits(self):
     """
     Test that get_limits returns AwsLimits
     """
     cls = _Route53Service(21, 43)
     cls.limits = {}
     res = cls.get_limits()
     assert sorted(res.keys()) == sorted([
         'Record sets per hosted zone',
         'VPC associations per hosted zone',
     ])
     for name, limit in res.items():
         assert limit.service == cls
         assert limit.def_warning_threshold == 21
         assert limit.def_critical_threshold == 43
Exemplo n.º 3
0
    def test_find_limit_hosted_zone_vpc_associations(self):
        cls = _Route53Service(21, 43)
        self._mock_reponse_init(cls)
        cls._find_limit_hosted_zone()

        limit_key = cls.MAX_VPCS_ASSOCIATED_BY_ZONE["name"]
        assert cls.limits[limit_key].default_limit == 100

        usage1 = cls.limits[limit_key].get_current_usage()[0]
        assert usage1.get_value() == 10
        assert usage1.resource_id == "abc.example.com."
        assert usage1.get_maximum() == 100

        usage2 = cls.limits[limit_key].get_current_usage()[1]
        assert usage2.get_value() == 2
        assert usage2.resource_id == "def.example.com."
        assert usage2.get_maximum() == 101
Exemplo n.º 4
0
    def test_update_limits_from_api(self):
        """test _update_limits_from_api method calls other methods"""

        mock_conn = Mock()
        with patch('%s.connect' % pb) as mock_connect:
            with patch.multiple(
                    pb,
                    _find_limit_hosted_zone=DEFAULT,
            ) as mocks:
                cls = _Route53Service(21, 43)
                cls.conn = mock_conn
                cls._update_limits_from_api()
        assert mock_connect.mock_calls == [call()]
        assert mock_conn.mock_calls == []
        for x in [
                '_find_limit_hosted_zone',
        ]:
            assert mocks[x].mock_calls == [call()]
Exemplo n.º 5
0
    def test_find_limit_hosted_zone_recordsets(self):
        cls = _Route53Service(21, 43)
        self._mock_reponse_init(cls)
        cls._find_limit_hosted_zone()

        limit_key = cls.MAX_RRSETS_BY_ZONE["name"]
        assert cls.limits[limit_key].default_limit == 10000

        usage1 = cls.limits[limit_key].get_current_usage()[0]
        assert usage1.get_value() == 7500
        assert usage1.resource_id == "abc.example.com."
        assert usage1.get_maximum() == 10000

        usage2 = cls.limits[limit_key].get_current_usage()[1]
        assert usage2.get_value() == 2500
        assert usage2.resource_id == "def.example.com."
        assert usage2.get_maximum() == 10001

        usage2 = cls.limits[limit_key].get_current_usage()[2]
        assert usage2.get_value() == 5678
        assert usage2.resource_id == "ghi.example.com."
        assert usage2.get_maximum() == 10002
Exemplo n.º 6
0
    def test_find_usage(self):
        cls = _Route53Service(21, 43)

        assert cls._have_usage is False
        cls.find_usage()
        assert cls._have_usage is True
Exemplo n.º 7
0
 def test_required_iam_permissions(self):
     cls = _Route53Service(21, 43)
     assert cls.required_iam_permissions() == [
         "route53:GetHostedZone", "route53:GetHostedZoneLimit",
         "route53:ListHostedZones"
     ]