Ejemplo n.º 1
0
def test_login_no_channels_available():
    server = Camelot_Server()
    mydb = Camelot_Database()

    client_request = json.loads(
        json.dumps(
            {"login": {
                "username": "******",
                "password": "******",
            }},
            indent=4))

    expected_response = json.dumps(
        {"error": "No channels exist in the database."}, indent=4)

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

    assert expected_response == result
    mydb.empty_tables()
Ejemplo n.º 2
0
def test_login_success():
    server = Camelot_Server()
    mydb = Camelot_Database()

    client_request = json.loads(
        json.dumps(
            {"login": {
                "username": "******",
                "password": "******",
            }},
            indent=4))

    expected_response = json.dumps({"channels": ["ChannelTest"]}, indent=4)

    mydb.create_account("username", "password")
    mydb.create_channel("ChannelTest", "username")

    result = server.login(mydb, client_request)

    assert expected_response == result
    mydb.empty_tables()
Ejemplo n.º 3
0
def test_login_invalid_json():
    server = Camelot_Server()
    mydb = Camelot_Database()

    client_request = json.loads(
        json.dumps(
            {
                "login": {
                    "username_invalid": "username",
                    "password": "******",
                }
            },
            indent=4))

    expected_response = json.dumps(
        {"error": "The JSON file sent didn't contain valid information."},
        indent=4)

    result = server.login(mydb, client_request)

    assert expected_response == result
    mydb.empty_tables()
Ejemplo n.º 4
0
def test_login_user_password_combination_not_in_database():
    server = Camelot_Server()
    mydb = Camelot_Database()

    client_request = json.loads(
        json.dumps(
            {"login": {
                "username": "******",
                "password": "******",
            }},
            indent=4))

    expected_response = json.dumps(
        {
            "error":
            "The username/password combination do not exist in the database."
        },
        indent=4)

    result = server.login(mydb, client_request)

    assert expected_response == result
    mydb.empty_tables()