def test_subscribtions(self): dpl_1 = DPlugin() dpl_1.id = 1 dpl_2 = DPlugin() dpl_2.id = 2 dbl_1 = DBlock('DBlock1') dbl_1.id = 3 dbl_1.dplugin_id = dpl_2.id dbl_2 = DBlock('DBlock2') dbl_2.id = 4 dbl_2.dplugin_id = dpl_2.id dpl_2.add_dblock(dbl_1) dpl_2.add_dblock(dbl_2) #Check: subscribe DBlocks self.assertTrue(dpl_1.subscribe(dbl_1)) self.assertTrue(dpl_1.subscribe(dbl_2)) self.assertFalse(dpl_1.subscribe(dbl_1)) self.assertFalse(dpl_1.subscribe(dbl_2)) #Check: count of subscribtions self.assertEqual(len(dpl_1.get_subscribtions()[dpl_2.id].keys()), 2) #Check: unsubscribe DBlock self.assertTrue(dpl_1.unsubscribe(dbl_1)) #Check: count of subscribtions self.assertEqual(len(dpl_1.get_subscribtions().keys()), 1) #Check: count of subscribtions self.assertEqual(len(dpl_1.get_subscribtions()[dpl_2.id].keys()), 1)
def test_dblocks(self): dpl_1 = DPlugin() dpl_1.id = 1 dbl_1 = DBlock('Block1') dbl_1.dplugin_id = dpl_1.id dbl_2 = DBlock('Block2') dbl_2.dplugin_id = dpl_1.id #check: add Parameter self.assertTrue(dpl_1.add_dblock(dbl_1)) self.assertTrue(dpl_1.add_dblock(dbl_2)) self.assertFalse(dpl_1.add_dblock(dbl_1)) self.assertFalse(dpl_1.add_dblock(dbl_2)) #Check: count of parameters self.assertEqual(len(dpl_1.get_dblocks().keys()), 2) #Check: rm parameter self.assertTrue(dpl_1.rm_dblock(dbl_1)) self.assertEqual(len(dpl_1.get_dblocks().keys()), 1) self.assertTrue(dpl_1.rm_dblock(dbl_2)) self.assertEqual(len(dpl_1.get_dblocks().keys()), 0)