def test_should_get_id_pools_ipv4_range_from_uri(self):
        self.resource.get.return_value = 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()])
        )
예제 #2
0
    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=[])
        )
예제 #3
0
    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'}])
        )
예제 #4
0
    def test_should_get_id_pools_ipv4_range_from_subnet_and_name(self):
        obj = mock.Mock()
        obj.data = DEFAULT_SUBNET_TEMPLATE_2
        self.mock_ov_client.id_pools_ipv4_subnets.get_by_uri.return_value = obj

        range_1 = DEFAULT_RANGE_TEMPLATE.copy()
        self.resource.get_by_uri.return_value = self.resource
        self.resource.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])
        )
예제 #5
0
    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_id_pools_ipv4_range_from_subnet_and_name(self):
        self.subnets.get.return_value = DEFAULT_SUBNET_TEMPLATE_2

        range_1 = DEFAULT_RANGE_TEMPLATE.copy()
        range_4 = DEFAULT_NOT_RANGE_TEMPLATE.copy()
        range_4['name'] = range_4['name'] + '4'
        range_4['uri'] = range_4['uri'] + '4'
        ranges = [range_1, range_4]
        self.ranges.get.side_effect = ranges

        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_all_id_pools_ipv4_ranges_from_subnet(self):
        self.mock_ov_client.id_pools_ipv4_subnets.get.return_value = DEFAULT_SUBNET_TEMPLATE_2
        range_1 = DEFAULT_RANGE_TEMPLATE.copy()
        range_4 = DEFAULT_NOT_RANGE_TEMPLATE.copy()
        range_4['name'] = range_4['name'] + '4'
        range_4['uri'] = range_4['uri'] + '4'
        ranges = [range_1, range_4]

        self.resource.get.side_effect = ranges

        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)
        )
    def test_should_get_all_id_pools_ipv4_ranges(self):
        self.subnets.get_all.return_value = ALL_SUBNETS
        range_1 = DEFAULT_RANGE_TEMPLATE.copy()
        range_2 = DEFAULT_NOT_RANGE_TEMPLATE.copy()
        range_2['name'] = range_2['name'] + '2'
        range_2['uri'] = range_2['uri'] + '2'
        range_3 = DEFAULT_NOT_RANGE_TEMPLATE.copy()
        range_3['name'] = range_3['name'] + '3'
        range_3['uri'] = range_3['uri'] + '3'
        range_4 = DEFAULT_NOT_RANGE_TEMPLATE.copy()
        range_4['name'] = range_4['name'] + '4'
        range_4['uri'] = range_4['uri'] + '4'
        ranges = [range_2, range_3, range_1, range_4]

        self.ranges.get.side_effect = ranges

        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))