Пример #1
0
def do_post_delete_test():
    test_user1 = ('test1', '*****@*****.**', '1234qwer')
    test_user2 = ('test2', '*****@*****.**', '1234qwer')

    # post user which will be used for test
    utils.delete_user(test_user1[0])
    utils.delete_user(test_user2[0])
    utils.sign_up_success(test_user1[0], test_user1[1], test_user1[2])
    utils.sign_up_success(test_user2[0], test_user2[1], test_user2[2])

    # post postings for test
    post_text = 'text'
    post1_0 = utils.posting_success(test_user1[0], test_user1[2], post_text)
    post1_1 = utils.posting_success(test_user1[0], test_user1[2], post_text)
    post1_2 = utils.posting_success(test_user1[0], test_user1[2], post_text)

    # delete & put fail test
    utils.post_delete_fail((test_user2[0], test_user2[2]),
                           post1_0.json()['id'])

    utils.post_put_fail((test_user2[0], test_user2[2]), post1_0.json()['id'])

    # delete & put success test
    utils.post_delete_success((test_user1[0], test_user1[2]),
                              post1_1.json()['id'])

    utils.post_put_success((test_user1[0], test_user1[2]),
                           post1_2.json()['id'])

    print('post delete test success')
Пример #2
0
def do_posting_success_test(userNum):

    for i in range(0, userNum):
        username = "******" + str(i)
        password = "******"
        text = "This is test text."

        utils.posting_success(username, password, text)

    print('posting by normal users success\n')
Пример #3
0
def do_timeline_permission_test():
    #create test user
    test_users = []
    for i in range(0, 2):
        username = '******' + str(i)
        test_user = (username, username + '@test.com', '1234qwer')
        utils.delete_user(test_user[0])
        utils.sign_up_success(test_user[0], test_user[1], test_user[2])
        test_users.append(test_user)

    utils.posting_success(test_users[0][0], test_users[0][2],
                          'test0 posts this posting')
    utils.posting_success(test_users[1][0], test_users[1][2],
                          'test1 posts this posting')

    postList = requests.get(urls.posts_url(),
                            auth=(test_users[1][0], test_users[1][2]))

    for post in postList.json():
        if post['user'] == test_user[0][0]:
            print(
                'error: test1 can access post by test0 who is not friend of him.'
            )

    utils.post_friendrequest((test_users[0][0], test_users[0][2]),
                             test_users[1][0])
    request_id = []
    request_id.append(0)
    request_id.append(
        utils.get_friendrequest((test_users[1][0], test_users[1][2]),
                                test_users[0][0]))

    utils.accept_friendrequest((test_users[1][0], test_users[1][2]),
                               request_id[1])

    postList = requests.get(urls.posts_url(),
                            auth=(test_users[1][0], test_users[1][2]))

    friendPostShow = False
    for post in postList.json():
        # print( post )
        if post['user'] == test_users[0][0]:
            friendPostShow = True

    if not friendPostShow:
        print('error: test1 cannot access post by test0 who is his friend')
        exit(1)