def test_successful_removal_of_last_member_of_active_group(self, _: Any) -> None: # Setup user_input = UserInput('rm Alice') window = TxWindow(window_contacts=[self.contact_list.get_contact_by_address_or_nick("Alice")], type=WIN_TYPE_GROUP, name='test_group') group = self.group_list.get_group('test_group') group.members = [self.contact_list.get_contact_by_address_or_nick("Alice")] pub_key = nick_to_pub_key('Alice') # Test for g in self.group_list: self.assertIsInstance(g, Group) self.assertTrue(g.has_member(pub_key)) self.assertEqual(len(group), 1) self.assertIsNone(remove_contact(user_input, window, *self.args)) for g in self.group_list: self.assertIsInstance(g, Group) self.assertFalse(g.has_member(pub_key)) self.assertFalse(self.contact_list.has_pub_key(pub_key)) self.assertEqual(self.queues[COMMAND_PACKET_QUEUE].qsize(), 1) km_data = self.queues[KEY_MANAGEMENT_QUEUE].get() self.assertEqual(km_data, (KDB_REMOVE_ENTRY_HEADER, pub_key))
def test_no_contact_found_on_transmitter(self, *_: Any) -> None: # Setup user_input = UserInput(f'rm {nick_to_onion_address("Charlie")}') contact_list = ContactList(nicks=['Bob']) window = TxWindow(window_contact=[contact_list.get_contact_by_address_or_nick('Bob')], type=WIN_TYPE_GROUP) # Test self.assertIsNone(remove_contact(user_input, window, *self.args)) self.assertEqual(self.queues[COMMAND_PACKET_QUEUE].qsize(), 1) self.assertEqual(self.queues[RELAY_PACKET_QUEUE].qsize(), 1) command_packet = self.queues[COMMAND_PACKET_QUEUE].get() self.assertIsInstance(command_packet, bytes)
def test_successful_removal_of_contact(self, _: Any) -> None: # Setup window = TxWindow(window_contacts=[self.contact_list.get_contact_by_address_or_nick('Alice')], type=WIN_TYPE_CONTACT, uid=self.pub_key) # Test for g in self.group_list: self.assertIsInstance(g, Group) self.assertTrue(g.has_member(self.pub_key)) self.assertIsNone(remove_contact(UserInput('rm Alice'), window, *self.args)) self.assertEqual(self.queues[COMMAND_PACKET_QUEUE].qsize(), 1) km_data = self.queues[KEY_MANAGEMENT_QUEUE].get() self.assertEqual(km_data, (KDB_REMOVE_ENTRY_HEADER, self.pub_key)) self.assertFalse(self.contact_list.has_pub_key(self.pub_key)) for g in self.group_list: self.assertIsInstance(g, Group) self.assertFalse(g.has_member(self.pub_key))