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)
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, [])
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"])
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)
def test_registration_exception(self): mock_vm = MagicMock() dm = DockerMonitor() self.assertRaises(Exception, dm.register(mock_vm))
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)