def test_should_get_id_pools_ipv4_ranges_schema(self): self.resource.get_schema.return_value = [{'schema': 'schema'}] self.mock_ansible_module.params = PARAMS_GET_SCHEMA IdPoolsIpv4RangeFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(id_pools_ipv4_ranges_schema=[{'schema': 'schema'}], id_pools_ipv4_ranges=[]) )
def test_should_get_id_pools_ipv4_range_from_subnet_and_name(self): self.mock_ov_client.id_pools_ipv4_subnets.get.return_value = DEFAULT_SUBNET_TEMPLATE_2 range_1 = DEFAULT_RANGE_TEMPLATE.copy() self.resource.get_by_uri().data = range_1 self.mock_ansible_module.params = PARAMS_GET_BY_NAME_AND_SUBNET_URI IdPoolsIpv4RangeFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(id_pools_ipv4_ranges=[range_1]))
def test_should_get_id_pools_ipv4_ranges_free_fragments(self): self.resource.get_by_uri().data = DEFAULT_RANGE_TEMPLATE.copy() self.resource.get_free_fragments.return_value = [{'frag': 'testfree'}] self.mock_ansible_module.params = PARAMS_GET_FREE_FRAGMENTS IdPoolsIpv4RangeFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(id_pools_ipv4_ranges=[DEFAULT_RANGE_TEMPLATE.copy()], id_pools_ipv4_ranges_free_fragments=[{'frag': 'testfree'}]) )
def test_should_get_id_pools_ipv4_range_from_uri(self): self.resource.get_by_uri.return_value = self.resource self.resource.data = DEFAULT_RANGE_TEMPLATE.copy() self.mock_ansible_module.params = PARAMS_GET_BY_URI IdPoolsIpv4RangeFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(id_pools_ipv4_ranges=[DEFAULT_RANGE_TEMPLATE.copy()]) )
def test_should_get_all_id_pools_ipv4_ranges(self): self.mock_ov_client.id_pools_ipv4_subnets.get_all.return_value = ALL_SUBNETS range_1 = DEFAULT_RANGE_TEMPLATE.copy() range_2 = DEFAULT_RANGE_TEMPLATE.copy() range_3 = DEFAULT_RANGE_TEMPLATE.copy() range_4 = DEFAULT_RANGE_TEMPLATE.copy() ranges = [range_2, range_3, range_1, range_4] self.resource.get_by_uri().data = range_1 self.mock_ansible_module.params = PARAMS_GET_ALL IdPoolsIpv4RangeFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(id_pools_ipv4_ranges=ranges))
def test_should_get_all_id_pools_ipv4_ranges_from_subnet(self): obj = mock.Mock() obj = DEFAULT_SUBNET_TEMPLATE_2 self.mock_ov_client.id_pools_ipv4_subnets.get_by_uri.return_value = obj range_1 = DEFAULT_RANGE_TEMPLATE.copy() range_4 = DEFAULT_RANGE_TEMPLATE.copy() ranges = [range_1, range_4] self.resource.get_by_uri.return_value = self.resource self.resource.data = range_1 self.mock_ansible_module.params = PARAMS_GET_ALL_FROM_SUBNET IdPoolsIpv4RangeFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(id_pools_ipv4_ranges=ranges))