Esempio n. 1
0
def test_leave_channel_success():
    server = Camelot_Server()
    mydb = Camelot_Database()

    client_request = json.loads(
        json.dumps({"leave_channel": "Client Team"}, indent=4))

    expected_response = json.dumps(
        {
            "leave_channel": {
                "channel": "Client Team",
                "user": "******",
                "message": "username has left the channel."
            }
        },
        indent=4)

    mydb.create_account("username", "password")
    server, mydb = login(server, mydb, 'username', 'password')
    mydb.create_channel("Client Team", None)
    mydb.add_channels_to_user_info("username", ["Client Team"])

    result = server.leave_channel(mydb, client_request)

    assert expected_response == result
    mydb.empty_tables()
Esempio n. 2
0
def test_leave_channel_not_logged_in():
    server = Camelot_Server()
    mydb = Camelot_Database()

    client_request = json.loads(
        json.dumps({"leave_channel": "Client Team"}, indent=4))

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

    result = server.leave_channel(mydb, client_request)

    assert expected_response == result
    mydb.empty_tables()
Esempio n. 3
0
def test_leave_channel_channel_does_not_exist():
    server = Camelot_Server()
    mydb = Camelot_Database()

    client_request = json.loads(
        json.dumps({"leave_channel": "Client Team"}, indent=4))

    expected_response = json.dumps(
        {"error": "The specified channel was not found."}, indent=4)

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

    result = server.leave_channel(mydb, client_request)

    assert expected_response == result
    mydb.empty_tables()