def test_noAdmain_join_list(): reset_data() A = auth_register("*****@*****.**", 'HoyaLee2019', "Hoya", "Lee") B = auth_register("*****@*****.**", "wsad1990", "Good", "Morning") Pub_channel = CF.channels_create(A['token'], 'Num2', 'True') channelID = Pub_channel['channel_id'] token1 = B['token'] CF.channel_join(token1, channelID) CF.channels_list(token1)
def test_channels_list(): ''' Function tests for channels_list ''' #Initialisation global_var.initialise_all() user1 = auth_register("*****@*****.**", \ "valid_correct_password", "valid_correct_first_name",\ "valid_correct_last_name") token1 = user1["token"] user2 = auth_register("*****@*****.**", \ "valid_correct_password", "valid_correct_first_name", \ "valid_correct_last_name") token2 = user2["token"] # Initialisation finished assert func.channels_list(token1) == {"channels": []} #user1 create a channel func.channels_create(token1, "TestChannel", True) #user2 create a channel func.channels_create(token2, "TestChannel2", True) assert func.channels_list(token1) == { "channels": [{ "channel_id": 0, "name": "TestChannel" }] } assert func.channels_list(token2) == { "channels": [{ "channel_id": 1, "name": "TestChannel2" }] } #user2 creates another channel func.channels_create(token2, "TestChannel3", True) #assert token2 is in two channels assert func.channels_list(token2) == { "channels": [{ "channel_id": 1, "name": "TestChannel2" }, { "channel_id": 2, "name": "TestChannel3" }] } # The function is called using a invalid token with pytest.raises(AccessError, match="Invalid token"): func.channels_list("12345")
def test_admain_list(): reset_data() A = auth_register("*****@*****.**", 'HoyaLee2019', "Hoya", "Lee") token = A['token'] CF.channels_list(token)
def test_DEtoken(): reset_data() token = 'NM$LW$ND6324' with pytest.raises(TF.AccessError): CF.channels_list(token)
def test_token_None(): token = None with pytest.raises(TypeError): CF.channels_list(token)
def test_invalid_AD_token(): token = A['token'] + '10010' auth_login("*****@*****.**", 'HoyaLee2019') with pytest.raises(TF.AccessError): CF.channels_list(token)
def test_Not_login_NoAd(): token = A['token'] auth_logout(token) with pytest.raises(CF.AccessError): CF.channels_list(token)
def channel_list(): """ Provides a list of all channels that the user is a member of """ token = request.args.get("token") return dumps(channel.channels_list(token))