Exemple #1
0
 def test_get_registered(self):
     dm = DockerMonitor()
     n = 5
     for i in range(n):
         dm.register(MagicMock())
     registered = dm.get_registered()
     self.assertEqual(len(registered), n)
Exemple #2
0
    def test_unregister_vm(self):
        mock_vm = MagicMock()

        dm = DockerMonitor()
        dm.register(mock_vm)
        dm.deregister(mock_vm)
        registered = dm.get_registered()

        self.assertEqual(registered, [])
Exemple #3
0
    def test_register_vm(self):
        mock_vm = MagicMock()

        dm = DockerMonitor()
        dm.register(mock_vm)
        registered = dm.get_registered()

        # Asserts
        self.assertEqual(len(registered), 1)
        self.assertEqual(registered.pop(), mock_vm)
Exemple #4
0
    def test_start_monitoring(self, mstart_new_thread, mxenapiclient,
                              log_info):
        mvm_ref = MagicMock()
        dm = DockerMonitor(host=MagicMock())

        dm.start_monitoring(mvm_ref)
        registered = dm.get_registered()[0]

        mstart_new_thread.assert_called_with(registered._monitoring_loop,
                                             tuple())