Beispiel #1
0
    def test_should_get_network_set_by_name_without_ethernet(self):
        network_sets = [{"name": "Network Set 1", "networkUris": []}]

        self.resource.get_all_without_ethernet.return_value = network_sets
        self.mock_ansible_module.params = PARAMS_GET_BY_NAME_WITHOUT_ETHERNET

        NetworkSetFactsModule().run()

        expected_filter = "\"'name'='Network Set 1'\""
        self.resource.get_all_without_ethernet.assert_called_once_with(
            filter=expected_filter)

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False, ansible_facts=dict(network_sets=network_sets))
Beispiel #2
0
    def test_should_get_network_set_by_name(self):
        network_sets = [{
            "name": "Network Set 1",
            "networkUris": ['/rest/ethernet-networks/aaa-bbb-ccc']
        }]

        self.resource.get_by.return_value = network_sets
        self.mock_ansible_module.params = PARAMS_GET_BY_NAME

        NetworkSetFactsModule().run()

        self.resource.get_by.assert_called_once_with('name', 'Network Set 1')

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False, ansible_facts=dict(network_sets=network_sets))
Beispiel #3
0
    def test_should_get_all_network_sets_without_ethernet(self):
        network_sets = [{
            "name": "Network Set 1",
            "networkUris": []
        }, {
            "name": "Network Set 2",
            "networkUris": []
        }]

        self.resource.get_all.return_value = network_sets
        self.mock_ansible_module.params = PARAMS_GET_ALL

        NetworkSetFactsModule().run()

        self.resource.get_all.assert_called_once_with()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False, ansible_facts=dict(network_sets=network_sets))
Beispiel #4
0
    def test_should_get_all_network_sets(self):
        network_sets = [{
            "name": "Network Set 1",
            "networkUris": ['/rest/ethernet-networks/aaa-bbb-ccc']
        }, {
            "name": "Network Set 2",
            "networkUris": ['/rest/ethernet-networks/ddd-eee-fff', '/rest/ethernet-networks/ggg-hhh-fff']
        }]

        self.network_sets.get_all.return_value = network_sets
        self.mock_ansible_module.params = PARAMS_GET_ALL

        NetworkSetFactsModule().run()

        self.network_sets.get_all.assert_called_once_with()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False,
            ansible_facts=dict(network_sets=network_sets))