Exemplo n.º 1
0
    def test_should_get_enet_by_name_with_options(self):
        self.resource.data = PRESENT_ENETS

        self.resource.get_associated_profiles.return_value = ENET_ASSOCIATED_PROFILE_URIS
        self.resource.get_associated_uplink_groups.return_value = ENET_ASSOCIATED_UPLINK_GROUP_URIS

        profiles = []
        for data in ENET_ASSOCIATED_PROFILES:
            obj = mock.Mock()
            obj.data = data
            profiles.append(obj)

        uplinks = []
        for data in ENET_ASSOCIATED_UPLINK_GROUPS:
            obj = mock.Mock()
            obj.data = data
            uplinks.append(obj)

        self.mock_ov_client.server_profiles.get_by_uri.side_effect = profiles
        self.mock_ov_client.uplink_sets.get_by_uri.side_effect = uplinks

        self.mock_ansible_module.params = PARAMS_GET_BY_NAME_WITH_OPTIONS

        EthernetNetworkFactsModule().run()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False,
            ansible_facts=dict(
                ethernet_networks=PRESENT_ENETS,
                enet_associated_profiles=ENET_ASSOCIATED_PROFILES,
                enet_associated_uplink_groups=ENET_ASSOCIATED_UPLINK_GROUPS))
    def test_should_get_enet_by_name(self):
        self.resource.get_by.return_value = PRESENT_ENETS
        self.mock_ansible_module.params = PARAMS_GET_BY_NAME

        EthernetNetworkFactsModule().run()

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