Example #1
0
    def setUp(self):
        """Execute steps before each tests."""
        patch('kytos.core.helpers.run_on_thread', lambda x: x).start()
        from napps.kytos.of_l2ls.main import Main
        self.addCleanup(patch.stopall)

        self.napp = Main(get_controller_mock())
Example #2
0
    def test_controller_mock(self):
        """Test controller mock."""
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(None)
        controller = get_controller_mock(loop)

        self.assertEqual(type(controller), Controller)
Example #3
0
    def setUp(self, *args):
        """Execute steps before each tests."""
        (mock_etcd, mock_fs, _) = args
        mock_fs.return_value = MagicMock()
        mock_etcd.return_value = MagicMock()

        patch('kytos.core.helpers.run_on_thread', lambda x: x).start()
        # pylint: disable=import-outside-toplevel
        from napps.kytos.storehouse.main import Main
        self.addCleanup(patch.stopall)

        self.napp = Main(get_controller_mock())
Example #4
0
    def setUp(self):
        """Execute steps before each tests.

        Set the server_name_url_url from kytos/flow_manager
        """
        self.server_name_url = 'http://localhost:8181/api/kytos/flow_manager'

        patch('kytos.core.helpers.run_on_thread', lambda x: x).start()
        # pylint: disable=import-outside-toplevel
        from napps.kytos.flow_manager.storehouse import StoreHouse
        self.addCleanup(patch.stopall)

        self.napp = StoreHouse(get_controller_mock())
Example #5
0
    def setUp(self):
        """Execute steps before each tests."""
        self.server_name_url = 'http://127.0.0.1:8181/api/kytos/of_lldp'

        patch('kytos.core.helpers.run_on_thread', lambda x: x).start()
        # pylint: disable=bad-option-value, import-outside-toplevel
        from napps.kytos.of_lldp.main import Main
        self.addCleanup(patch.stopall)

        self.topology = get_topology_mock()
        controller = get_controller_mock()
        controller.switches = self.topology.switches

        self.napp = Main(controller)
Example #6
0
    def test_get_test_client(self):
        """Test get_test_client method."""
        napp = MagicMock()

        api_server = MagicMock()
        api_server.app.test_client.return_value = 'client'

        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(None)
        controller = get_controller_mock(loop)
        controller.api_server = api_server

        test_client = get_test_client(controller, napp)

        api_server.register_napp_endpoints.assert_called_with(napp)
        self.assertEqual(test_client, 'client')
Example #7
0
    def setUp(self):
        patch('kytos.core.helpers.run_on_thread', lambda x: x).start()
        # pylint: disable=bad-option-value
        from napps.kytos.flow_manager.main import Main
        self.addCleanup(patch.stopall)

        controller = get_controller_mock()
        self.switch_01 = get_switch_mock("00:00:00:00:00:00:00:01", 0x04)
        self.switch_01.is_enabled.return_value = True
        self.switch_01.flows = []

        self.switch_02 = get_switch_mock("00:00:00:00:00:00:00:02", 0x04)
        self.switch_02.is_enabled.return_value = False
        self.switch_02.flows = []

        controller.switches = {"00:00:00:00:00:00:00:01": self.switch_01,
                               "00:00:00:00:00:00:00:02": self.switch_02}

        self.napp = Main(controller)
Example #8
0
 def setUp(self):
     """Execute steps before each tests."""
     self.napp = Main(get_controller_mock())