def test_add_new_user_3(self): crud = CRUD() crud.add_new_user("*****@*****.**", "2021-02-09") crud.remove_user(0) crud.remove_user_group('1', 'default') user_data = crud.update_users(1, "Trust", 70) self.assertEqual(user_data, self.test_user_3)
def test_remove_user_group_6(self): crud = CRUD() crud.remove_user_group('0', 'default') crud.update_users(0, "Trust", 50) crud.add_new_user("*****@*****.**", "2021-02-09") user_data = crud.remove_user(1) self.assertEqual(user_data, self.test_user_2)
def test_add_new_user_1(self): crud = CRUD() crud.add_new_user("*****@*****.**", "2021-02-10") crud.update_users(0, "name", "*****@*****.**") crud.remove_user_group('2', 'default') user_data = crud.remove_user(1) self.assertEqual(user_data, self.test_user)
def test_remove_user_group_1(self): crud = CRUD() crud.remove_user_group('0', "default") crud.add_new_user("*****@*****.**", "2021-02-09") crud.update_users(1, "name", "*****@*****.**") user_data = crud.remove_user(1) self.assertEqual(user_data, self.test_user_2)
def test_add_new_user_Passes_correct_data_to_modify_users_file( self, mock_modify_users_file, mock_read_users_file): mock_read_users_file.return_value = self.users_data crud = CRUD() crud.add_new_user("*****@*****.**", "2021-02-09") mock_modify_users_file.assert_called_once_with(self.users_data) """Description: il faut utiliser les mocks des fonctions "read_users_file",
def test_crud_update_users_6(self): crud = CRUD(False) crud.update_users('1', 'SpamN', 5) crud.remove_user(1) crud.remove_user_group('1', 'default') crud.add_new_user('*****@*****.**', '2020-11-16') self.assertEqual(crud.read_users_file(), {'1': self.user_2})
def test_crud_update_users_3(self): crud = CRUD(False) crud.update_users('1', 'Trust', 15) crud.remove_user_group('1', 'colleague') crud.remove_user(1) crud.add_new_user('*****@*****.**', '2020-11-16') self.assertEqual(crud.read_users_file(), {'1': self.user_2})
def test_crud_remove_user_group_4(self): crud = CRUD(False) crud.remove_user_group('1', 'colleagues') crud.remove_user(1) crud.update_users('1', 'Trust', 10) crud.add_new_user("*****@*****.**", "2020-11-16") expected_user = self.user_2 self.assertEqual(crud.read_users_file(), {'1': expected_user})
def test_crud_update_users_5(self): crud = CRUD(False) crud.update_users('1', 'HamN', 2) crud.remove_user(1) crud.add_new_user('*****@*****.**', '2020-11-16') crud.remove_user_group('1', 'default') expected_user = self.user_2 expected_user['Groups'].remove('default') self.assertEqual(crud.read_users_file(), {'1': expected_user})
def test_crud_remove_user_3(self): crud = CRUD(False) crud.remove_user(1) crud.remove_user_group('1', 'default') crud.add_new_user('*****@*****.**', '2020-11-16') crud.update_users('1', 'Trust', 15) expected_user = self.user_2 expected_user['Trust'] = 15 self.assertEqual(crud.read_users_file(), {'1': expected_user})
def test_crud_add_new_user_5(self): crud = CRUD(False) crud.add_new_user("*****@*****.**", "2020-11-16") crud.remove_user_group('1', 'default') crud.update_users('2', 'SpamN', 1) crud.remove_user(1) expected_user = self.user_2 expected_user["SpamN"] = 1 self.assertEqual(crud.read_users_file(), {'2': expected_user})
def test_crud_remove_user_2(self): crud = CRUD(False) crud.remove_user(1) crud.add_new_user("*****@*****.**", "2020-11-16") crud.remove_user_group('1', 'default') crud.update_users('1', 'Trust', 95) expected_user = self.user_2 expected_user['Trust'] = 95 expected_user['Groups'].remove('default') self.assertEqual(crud.read_users_file(), {'1': expected_user})
def test_crud_add_new_user_add_new_user(self): crud = CRUD(True) # add_new_user self.assertEqual(crud.add_new_user("*****@*****.**", "2020-11-16"), True) self.assertEqual(crud.read_users_file().get('1'), self.user_2) # add_new_user self.assertEqual(crud.add_new_user("*****@*****.**", "2020-11-16"), True) self.assertEqual(crud.read_users_file().get('2'), self.user)
def test_crud_update_users_4(self): crud = CRUD(False) crud.update_users('1', 'Trust', 20) crud.remove_user_group('1', 'colleagues') crud.add_new_user('*****@*****.**', '2020-11-16') crud.remove_user(2) expected_user = self.user expected_user['Trust'] = 20 expected_user['Groups'].remove('colleagues') self.assertEqual(crud.read_users_file(), {'1': expected_user})
def test_crud_update_users_2(self): crud = CRUD(False) crud.update_users('1', 'Date_of_last_seen_message', 1605762353) crud.add_new_user('*****@*****.**', '2020-11-16') crud.remove_user_group('1', 'default') crud.remove_user(2) expected_user = self.user expected_user['Date_of_last_seen_message'] = 1605762353 expected_user['Groups'].remove('default') self.assertEqual(crud.read_users_file(), {'1': expected_user})
def test_crud_update_users_remove_user(self): crud = CRUD(True) crud.add_new_user("*****@*****.**", "2020-11-16") crud.update_users(1, "Trust", 0) self.assertEqual(crud.get_user_data(1, 'Trust'), 0) # remove_user self.assertEqual(crud.remove_user(1), True) self.assertEqual(crud.read_users_file(), {})
def test_crud_add_new_user_1(self): crud = CRUD(False) crud.add_new_user("*****@*****.**", "2020-11-16") crud.update_users('2', "Trust", 60) crud.remove_user_group('2', 'default') crud.remove_user(1) modified_user = self.user_2 modified_user["Groups"].remove('default') modified_user["Trust"] = 60 self.assertEqual(crud.read_users_file(), {'2': modified_user})
def test_crud_add_new_user_3(self): crud = CRUD(False) crud.add_new_user("*****@*****.**", "2020-11-16") crud.remove_user(2) crud.update_users('1', 'Trust', 75) crud.remove_user_group('1', 'default') expected_user = self.user expected_user["Groups"].remove('default') expected_user["Trust"] = 75 self.assertEqual(crud.read_users_file(), {'1': expected_user})
def test_crud_add_new_user_remove_user_group(self): crud = CRUD(True) # add_new_user crud.add_new_user("*****@*****.**", "2020-11-16") self.assertEqual(crud.read_users_file().get('1'), self.user_2) # remove_user_group crud.remove_user_group(1, 'default') self.assertEqual(crud.get_user_data(1, 'Groups'), [])
def test_crud_add_new_user_remove_user(self): crud = CRUD(True) # add_new_user crud.add_new_user("*****@*****.**", "2020-11-16") self.assertEqual(crud.read_users_file().get('1'), self.user_2) # remove_user self.assertEqual(crud.remove_user(1), True) self.assertEqual(crud.read_users_file(), {})
def test_crud_add_new_user_get_user_data(self): crud = CRUD(True) # add_new_user crud.add_new_user("*****@*****.**", "2020-11-16") self.assertEqual(crud.read_users_file().get('1'), self.user_2) # get_user_data trust1 = crud.get_user_data(1, 'Trust') self.assertEqual(trust1, 50)
def test_crud_add_new_user_update_users(self): crud = CRUD(True) # add_new_user crud.add_new_user("*****@*****.**", "2020-11-16") self.assertEqual(crud.read_users_file().get('1'), self.user_2) # update_users crud.update_users(1, "Trust", 0) self.assertEqual(crud.get_user_data(1, 'Trust'), 0)
def test_add_new_user_4(self): crud = CRUD() crud.add_new_user("*****@*****.**", "2021-02-09") crud.remove_user(1) crud.update_users(0, "Trust", 60) user_data = crud.remove_user_group('0', 'default') test_user = self.test_user_2 test_user['0']['Trust'] = 60 self.assertEqual(user_data, test_user)
def test_add_new_user_5(self): crud = CRUD() crud.add_new_user("*****@*****.**", "2021-02-09") crud.remove_user_group('0', 'default') crud.update_users(1, "Trust", 70) user_data = crud.remove_user(0) test_user = self.test_user_3 test_user['1']['Groups'].append('default') self.assertEqual(user_data, test_user)
def test_crud_remove_user_group_add_new_user(self): crud = CRUD(True) crud.add_new_user("*****@*****.**", "2020-11-16") # remove_user_group crud.remove_user_group(1, 'default') self.assertEqual(crud.get_user_data(1, 'Groups'), []) # add_new_user self.assertEqual(crud.add_new_user("*****@*****.**", "2020-11-16"), True) self.assertEqual(crud.read_users_file().get('2'), self.user)
def test_crud_remove_user_group_update_users(self): crud = CRUD(True) crud.add_new_user("*****@*****.**", "2020-11-16") # remove_user_group crud.remove_user_group(1, 'default') self.assertEqual(crud.get_user_data(1, 'Groups'), []) # update_users crud.update_users(1, "Trust", 0) self.assertEqual(crud.get_user_data(1, 'Trust'), 0)
def test_crud_get_user_data_remove_user(self): crud = CRUD(True) crud.add_new_user("*****@*****.**", "2020-11-16") # get_user_data trust1 = crud.get_user_data(1, 'Trust') self.assertEqual(trust1, 50) # remove_user self.assertEqual(crud.remove_user(1), True) self.assertEqual(crud.read_users_file(), {})
def test_crud_remove_user_group_get_user_data(self): crud = CRUD(True) crud.add_new_user("*****@*****.**", "2020-11-16") # remove_user_group crud.remove_user_group(1, 'default') self.assertEqual(crud.get_user_data(1, 'Groups'), []) # get_user_data trust1 = crud.get_user_data(1, 'Trust') self.assertEqual(trust1, 50)
def test_crud_remove_user_group_remove_user(self): crud = CRUD(True) crud.add_new_user("*****@*****.**", "2020-11-16") # remove_user_group crud.remove_user_group(1, 'default') self.assertEqual(crud.get_user_data(1, 'Groups'), []) # remove_user self.assertEqual(crud.remove_user(1), True) self.assertEqual(crud.read_users_file(), {})
def test_crud_update_users_update_users(self): crud = CRUD(True) crud.add_new_user("*****@*****.**", "2020-11-16") # update_users crud.update_users(1, "Trust", 0) self.assertEqual(crud.get_user_data(1, 'Trust'), 0) # update_users crud.update_users(1, 'Trust', 100) self.assertEqual(crud.get_user_data(1, 'Trust'), 100)