def test_migrate_maas_dns_(self, parse_data, related_units, relation_ids,
                               write_maas_dns_address,
                               needs_maas_dns_migration):
        needs_maas_dns_migration.return_value = True
        related_units.return_value = 'keystone/0'
        relation_ids.return_value = 'ha:4'

        def mock_parse_data(relid, unit, key):
            if key == 'resources':
                return {'res_keystone_public_hostname': 'ocf:maas:dns'}
            elif key == 'resource_params':
                return {'res_keystone_public_hostname':
                        'params fqdn="keystone.maas" ip_address="172.16.0.1"'}
            else:
                raise KeyError("unexpected key {}".format(key))

        parse_data.side_effect = mock_parse_data
        hooks.migrate_maas_dns()
        write_maas_dns_address.assert_called_with(
            "res_keystone_public_hostname", "172.16.0.1")
    def test_migrate_maas_dns_(self, parse_data, related_units, relation_ids,
                               write_maas_dns_address,
                               needs_maas_dns_migration):
        needs_maas_dns_migration.return_value = True
        related_units.return_value = 'keystone/0'
        relation_ids.return_value = 'ha:4'

        def mock_parse_data(relid, unit, key):
            if key == 'resources':
                return {'res_keystone_public_hostname': 'ocf:maas:dns'}
            elif key == 'resource_params':
                return {'res_keystone_public_hostname':
                        'params fqdn="keystone.maas" ip_address="172.16.0.1"'}
            else:
                raise KeyError("unexpected key {}".format(key))

        parse_data.side_effect = mock_parse_data
        hooks.migrate_maas_dns()
        write_maas_dns_address.assert_called_with(
            "res_keystone_public_hostname", "172.16.0.1")
 def test_migrate_maas_dns_no_migration(self, relation_ids,
                                        needs_maas_dns_migration):
     needs_maas_dns_migration.return_value = False
     hooks.migrate_maas_dns()
     relation_ids.assert_not_called()
 def test_migrate_maas_dns_no_migration(self, relation_ids,
                                        needs_maas_dns_migration):
     needs_maas_dns_migration.return_value = False
     hooks.migrate_maas_dns()
     relation_ids.assert_not_called()