'Test that no duplicate IPs are made on any network.'

@mock.patch('osa_toolkit.filesystem.load_environment')
@mock.patch('osa_toolkit.filesystem.load_user_configuration')
def test_duplicates(self, mock_load_config, mock_load_env):

    mock_load_config.return_value = get_config()
    mock_load_env.return_value = self.env
    mock_open = mock.mock_open()
    for i in range(0, 99):
        inventory = None
        di.ip.USED_IPS = set()
        with mock.patch('__main__.open', mock_open):
            inventory = get_inventory()
        ips = collections.defaultdict(int)
        hostvars = inventory['_meta']['hostvars']
        for (host, var_dict) in hostvars.items():
            nets = var_dict['container_networks']
            for (net, vals) in nets.items():
                if ('address' in vals.keys()):
                    addr = vals['address']
                    ips[addr] += 1
                    self.assertEqual(1, ips[addr], msg=('IP    %s    duplicated.' % addr))
