Ejemplo n.º 1
0
    def test_change_dict(self):
        client = ClientMock()
        hosted_zone_gateway = HostedZoneGateway(client)
        usecase = FlipDNSRecord(client=client,
                                hosted_zone_gateway=hosted_zone_gateway,
                                live='test-green.example.co.uk',
                                green='test-green.example.co.uk',
                                blue='test-blue.example.co.uk',
                                target_domain='test.example.co.uk')

        expected_dict = {
            'HostedZoneId': '/hosted/id',
            'ChangeBatch': {
                'Comment':
                'Flipping live to test-blue.example.co.uk.',
                'Changes': [{
                    'Action': 'UPSERT',
                    'ResourceRecordSet': {
                        'Name': 'test.example.co.uk.',
                        'Type': 'A',
                        'AliasTarget': {
                            'HostedZoneId': 'Dan-and-Seb',
                            'DNSName': 'test-blue.example.co.uk.',
                            'EvaluateTargetHealth': False
                        }
                    }
                }]
            }
        }

        assert usecase.build_change_dict() == expected_dict
Ejemplo n.º 2
0
    def test_correct_zone_records_found(self):
        client = ClientMock()
        hosted_zone_gateway = HostedZoneGateway(client)

        assert hosted_zone_gateway.get_hosted_zone_records(
            'test-blue.example.co.uk.') == [{
                'Name': 'test-blue.example.co.uk.',
                'Type': 'A',
                'AliasTarget': {
                    'HostedZoneId': 'Seb',
                    'DNSName': 'super-elastic-load-balancer.example.co.uk.',
                    'EvaluateTargetHealth': False
                }
            }, {
                'Name': 'test-green.example.co.uk.',
                'Type': 'A',
                'AliasTarget': {
                    'HostedZoneId': 'Dan',
                    'DNSName': 'super-elastic-load-balancer.example.co.uk.',
                    'EvaluateTargetHealth': False
                }
            }, {
                'Name': 'test.example.co.uk.',
                'Type': 'A',
                'AliasTarget': {
                    'HostedZoneId': 'Dan-and-Seb',
                    'DNSName': 'test-green.example.co.uk.',
                    'EvaluateTargetHealth': False
                }
            }]
 def test_gets_inactive_environment_correctly(self):
     hosted_zone_gateway = HostedZoneGateway(ClientMock())
     use_case = GetInactiveEnvironment(
         blue='test-blue.example.co.uk',
         green='test-green.example.co.uk',
         target_domain='test.example.co.uk',
         hosted_zone_gateway=hosted_zone_gateway)
     assert use_case.call() == 'test-blue.example.co.uk'
Ejemplo n.º 4
0
    def test_correct_zone_is_found(self):
        client = ClientMock()
        hosted_zone_gateway = HostedZoneGateway(client)

        assert hosted_zone_gateway.get_hosted_zone(
            'test-blue.example.co.uk.') == {
                'Id': '/hosted/id',
                'Name': 'example.co.uk.'
            }
Ejemplo n.º 5
0
    def test_gets_correct_non_live_resource_record(self):
        client = ClientMock()
        hosted_zone_gateway = HostedZoneGateway(client)
        usecase = FlipDNSRecord(client=client,
                                hosted_zone_gateway=hosted_zone_gateway,
                                live='test-green.example.co.uk',
                                green='test-green.example.co.uk',
                                blue='test-blue.example.co.uk',
                                target_domain='test.example.co.uk')

        assert usecase.get_non_live_resource() == 'test-blue.example.co.uk.'
Ejemplo n.º 6
0
    def test_end_to_end(self):
        client = ClientMock()
        hosted_zone_gateway = HostedZoneGateway(client)
        usecase = FlipDNSRecord(client=client,
                                hosted_zone_gateway=hosted_zone_gateway,
                                live='test-green.example.co.uk',
                                green='test-green.example.co.uk',
                                blue='test-blue.example.co.uk',
                                target_domain='test.example.co.uk')

        assert usecase.call()['ChangeInfo'][
            'Comment'] == 'Flipping live to test-blue.example.co.uk.'
Ejemplo n.º 7
0
    def test_change_resource_dict(self):
        client = ClientMock()
        hosted_zone_gateway = HostedZoneGateway(client)
        usecase = FlipDNSRecord(client=client,
                                hosted_zone_gateway=hosted_zone_gateway,
                                live='test-green.example.co.uk',
                                green='test-green.example.co.uk',
                                blue='test-blue.example.co.uk',
                                target_domain='test.example.co.uk')

        expected_dict = {
            'Name': 'test.example.co.uk.',
            'Type': 'A',
            'AliasTarget': {
                'HostedZoneId': 'Dan-and-Seb',
                'DNSName': 'test-blue.example.co.uk.',
                'EvaluateTargetHealth': False
            }
        }

        assert usecase.build_resource_dict() == expected_dict
Ejemplo n.º 8
0
 def test_gets_current_live_environment_correctly(self):
     hosted_zone_gateway = HostedZoneGateway(ClientMock())
     use_case = GetCurrentLiveEnvironment(
         target_domain='test.example.co.uk',
         hosted_zone_gateway=hosted_zone_gateway)
     assert use_case.call() == 'test-green.example.co.uk'