]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/progress: Created first unit test for progress module 28758/head
authorKamoltat (Junior) Sirivadhna <ksirivad@redhat.com>
Tue, 2 Jul 2019 19:40:58 +0000 (15:40 -0400)
committerKamoltat (Junior) Sirivadhna <ksirivad@redhat.com>
Tue, 2 Jul 2019 19:40:58 +0000 (15:40 -0400)
Changed variable some variable names and assert
call once to be call count.

Signed-off-by: Kamoltat (Junior) Sirivadhna <ksirivad@redhat.com>
src/test/mgr/test_progress.py

index fcdfdd4ab7a643406218580813fcdf7493ac80e2..80f51a1aeb01ce27b841f42f53ee2ec8fc79269c 100644 (file)
@@ -125,11 +125,11 @@ class TestModule(object):
         # bunch of attributes for testing
 
         module.PgRecoveryEvent.pg_update = Mock()
-        self.test_event = module.Module() # so we can see if an event gets created
-        self.test_event.log = Mock() # we don't need to log anything
-        self.test_event.get = Mock() # so we can call pg_update
-        self.test_event._complete = Mock() # we want just to see if this event gets called
-        self.test_event.get_osdmap = Mock() # so that self.get_osdmap().get_epoch() works
+        self.test_module = module.Module() # so we can see if an event gets created
+        self.test_module.log = Mock() # we don't need to log anything
+        self.test_module.get = Mock() # so we can call pg_update
+        self.test_module._complete = Mock() # we want just to see if this event gets called
+        self.test_module.get_osdmap = Mock() # so that self.get_osdmap().get_epoch() works
         module._module = Mock() # so that Event.refresh() works
 
     def test_osd_in_out(self):
@@ -193,11 +193,11 @@ class TestModule(object):
 
         new_map = OSDMap(new_dump, new_pg_stats)
         old_map = OSDMap(old_dump, old_pg_stats)
-        self.test_event._osd_in_out(old_map, old_dump, new_map, 3, "out")
+        self.test_module._osd_in_out(old_map, old_dump, new_map, 3, "out")
         # check if only one event is created
-        assert len(self.test_event._events) == 1
-        self.test_event._osd_in_out(old_map, old_dump, new_map, 3, "in")
+        assert len(self.test_module._events) == 1
+        self.test_module._osd_in_out(old_map, old_dump, new_map, 3, "in")
         # check if complete function is called
-        self.test_event._complete.assert_called_once() 
+        assert self.test_module._complete.call_count == 1
         # check if a PgRecovery Event was created and pg_update gets triggered
-        module.PgRecoveryEvent.pg_update.asset_called_once()
+        assert module.PgRecoveryEvent.pg_update.call_count == 2