Beispiel #1
0
def test_logout_not_logged_in():
    server = Camelot_Server()
    mydb = Camelot_Database()

    client_request = json.loads(json.dumps({"logout": "logout"}, indent=4))

    expected_response = json.dumps(
        {"error": "A user must be signed in to access this function."},
        indent=4)

    result = server.logout(mydb, client_request)

    assert expected_response == result
    mydb.empty_tables()
Beispiel #2
0
def test_logout_success():
    server = Camelot_Server()
    mydb = Camelot_Database()

    client_request = json.loads(json.dumps({"logout": "logout"}, indent=4))

    expected_response = json.dumps(
        {"success": "username has successfully logged out."}, indent=4)

    mydb.create_account("username", "password")
    server, mydb = login(server, mydb, 'username', 'password')

    result = server.logout(mydb, client_request)

    assert expected_response == result
    mydb.empty_tables()