示例#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)
示例#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, [])
示例#3
0
    def test_stop_monitoring(self, log_info):
        mvm_ref = MagicMock()
        dm = DockerMonitor()
        thevm = MonitoredVM(MagicMock(), ref=mvm_ref)

        dm.register(thevm)
        dm.stop_monitoring(mvm_ref)

        self.assertEqual(thevm._stop_monitoring_request, ["stop"])
示例#4
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)
示例#5
0
 def test_registration_exception(self):
     mock_vm = MagicMock()
     dm = DockerMonitor()
     self.assertRaises(Exception, dm.register(mock_vm))
示例#6
0
 def test_is_registered(self):
     mock_vm = MagicMock()
     dm = DockerMonitor()
     self.assertEqual(dm.is_registered(mock_vm), False)
     dm.register(mock_vm)
     self.assertEqual(dm.is_registered(mock_vm), True)