Ejemplo n.º 1
0
    def test_should_get_all_without_ethernet(self):
        logical_downlinks = [LOGICAL_DOWNLINK]

        self.logical_downlinks.get_all_without_ethernet.return_value = logical_downlinks

        self.mock_ansible_module.params = PARAMS_FOR_GET_ALL_WITHOUT_ETHERNET

        LogicalDownlinksFactsModule().run()

        self.logical_downlinks.get_all_without_ethernet.assert_called_once()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False,
            ansible_facts=dict(logical_downlinks=logical_downlinks))
Ejemplo n.º 2
0
    def test_should_get_all_logical_downlinks(self):
        logical_downlinks = [dict(name="test1"), dict(name="test2")]

        self.logical_downlinks.get_all.return_value = logical_downlinks

        self.mock_ansible_module.params = PARAMS_FOR_GET_ALL

        LogicalDownlinksFactsModule().run()

        self.logical_downlinks.get_all.assert_called_once()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False,
            ansible_facts=dict(logical_downlinks=logical_downlinks))
Ejemplo n.º 3
0
    def test_should_get_by_name(self):
        logical_downlinks = [LOGICAL_DOWNLINK]

        self.logical_downlinks.get_by.return_value = logical_downlinks

        self.mock_ansible_module.params = PARAMS_FOR_GET_BY_NAME

        LogicalDownlinksFactsModule().run()

        self.logical_downlinks.get_by.assert_called_once_with(
            "name", LOGICAL_DOWNLINK_NAME)

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False,
            ansible_facts=dict(logical_downlinks=logical_downlinks))
Ejemplo n.º 4
0
    def test_should_not_get_without_ethernet_when_not_found(self):
        logical_downlinks = []

        self.logical_downlinks.get_by.return_value = logical_downlinks
        self.logical_downlinks.get_without_ethernet.return_value = None

        self.mock_ansible_module.params = PARAMS_FOR_GET_WITHOUT_ETHERNET

        LogicalDownlinksFactsModule().run()

        self.logical_downlinks.get_by.assert_called_once_with(
            'name', LOGICAL_DOWNLINK_NAME)
        self.logical_downlinks.get_without_ethernet.not_been_called()

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False, ansible_facts=dict(logical_downlinks=[]))
Ejemplo n.º 5
0
    def test_should_get_without_ethernet(self):
        logical_downlinks = [LOGICAL_DOWNLINK]

        self.logical_downlinks.get_by.return_value = logical_downlinks
        self.logical_downlinks.get_without_ethernet.return_value = {
            'name': 'Logical Downlink Without Ethernet'
        }

        self.mock_ansible_module.params = PARAMS_FOR_GET_WITHOUT_ETHERNET

        LogicalDownlinksFactsModule().run()

        self.logical_downlinks.get_by.assert_called_once_with(
            'name', LOGICAL_DOWNLINK_NAME)
        self.logical_downlinks.get_without_ethernet.assert_called_once_with(
            id_or_uri=LOGICAL_DOWNLINK_URI)

        self.mock_ansible_module.exit_json.assert_called_once_with(
            changed=False,
            ansible_facts=dict(
                logical_downlinks=[{
                    'name': 'Logical Downlink Without Ethernet'
                }]))