def test_delete_account_account_does_not_exist(): server = Camelot_Server() mydb = Camelot_Database() client_request = json.loads( json.dumps( { "delete_account": { "username": "******", "password": "******" } }, indent=4)) expected_response = json.dumps( { "error": "The username/password combination do not exist in the database." }, indent=4) result = server.delete_account(mydb, client_request) assert expected_response == result mydb.empty_tables()
def test_delete_account_success(): server = Camelot_Server() mydb = Camelot_Database() client_request = json.loads( json.dumps( { "delete_account": { "username": "******", "password": "******" } }, indent=4)) expected_response = json.dumps( { "account_deleted": { "username": "******", "channels_being_deleted": ["TestChannel"] } }, indent=4) mydb.create_account("username", "password") mydb.create_channel("TestChannel", "username") result = server.delete_account(mydb, client_request) assert expected_response == result mydb.empty_tables()
def test_delete_account_invalid_json(): server = Camelot_Server() mydb = Camelot_Database() client_request = json.loads( json.dumps( { "delete_account": { "username_invalid": "username", "password": "******" } }, indent=4)) expected_response = json.dumps( {"error": "The JSON file sent didn't contain valid information."}, indent=4) result = server.delete_account(mydb, client_request) assert expected_response == result mydb.empty_tables()