コード例 #1
0
ファイル: test_tweets.py プロジェクト: jayxt96/pds-stardust
def test_delete_tweet(wait_for_api):
    request_session, api_url = wait_for_api

    user_id = post(urljoin(api_url, 'users'), {'pseudo': 'tests'}).json()['id']

    tweet_id = post(urljoin(api_url, 'users/{}/tweets'.format(user_id)), {'message': 'My tests tweet !'}).json()['id']

    resp = delete(urljoin(api_url, 'users/{}/tweets/{}'.format(user_id, tweet_id)))

    assert resp.status_code == 204, "Tweet not deleted"

    resp = get(urljoin(api_url, 'users/{}/tweets'.format(user_id)))

    body = resp.json()

    assert body is not None
    assert len(body) == 0, "Expected no tweet"

    resp = get(urljoin(api_url, 'users/{}'.format(user_id)))

    assert resp.status_code == 200, "User not found"

    body = resp.json()

    assert body is not None
コード例 #2
0
ファイル: test_tweets.py プロジェクト: jayxt96/pds-stardust
def test_detail_tweet(wait_for_api):
    request_session, api_url = wait_for_api

    user_id = post(urljoin(api_url, 'users'), {'pseudo': 'tests'}).json()['id']

    tweet = post(urljoin(api_url, 'users/{}/tweets'.format(user_id)), {'message': 'My tests tweet !'}).json()

    resp = get(urljoin(api_url, 'users/{}/tweets/{}'.format(user_id, tweet['id'])))

    assert resp.status_code == 200, "Tweet not found"

    body = resp.json()

    assert body is not None
    assert body['id'] == tweet['id']
    assert body['message'] == tweet['message']
コード例 #3
0
ファイル: test_tweets.py プロジェクト: jayxt96/pds-stardust
def test_create_tweet(wait_for_api):
    request_session, api_url = wait_for_api

    user = post(urljoin(api_url, 'users'), {'pseudo': 'tests'}).json()

    payload = {'message': 'My tests tweet !'}

    resp = post(urljoin(api_url, 'users/{}/tweets'.format(user['id'])), payload)

    assert resp.status_code == 201, "Tweet not successfully created"

    body = resp.json()

    assert body is not None
    assert user['id'] is not None
    assert body['message'] == 'My tests tweet !'
コード例 #4
0
ファイル: test_tweets.py プロジェクト: jayxt96/pds-stardust
def test_update_tweet(wait_for_api):
    request_session, api_url = wait_for_api

    user_id = post(urljoin(api_url, 'users'), {'pseudo': 'tests'}).json()['id']

    tweet_id = post(urljoin(api_url, 'users/{}/tweets'.format(user_id)), {'message': 'My tests tweet !'}).json()['id']

    payload = {'message': 'My updated tweet !'}

    resp = patch(urljoin(api_url, 'users/{}/tweets/{}'.format(user_id, tweet_id)), payload)

    assert resp.status_code == 200, "Tweet not updated"

    body = resp.json()

    assert body is not None
    assert body['id'] is not None
    assert body['message'] == 'My updated tweet !'
コード例 #5
0
ファイル: test_users.py プロジェクト: jayxt96/pds-stardust
def test_list_user(wait_for_api):
    request_session, api_url = wait_for_api

    post(urljoin(api_url, 'users'), {'pseudo': 'tests'})

    resp = get(urljoin(api_url, 'users'))

    assert resp.status_code == 200, "Status code not equals"

    body = resp.json()

    assert body is not None
    assert len(body) == 1, "Expected one user"

    user = body[0]

    assert user is not None
    assert user['id'] is not None
    assert user['pseudo'] == 'tests'
コード例 #6
0
ファイル: test_tweets.py プロジェクト: jayxt96/pds-stardust
def test_ist_tweet(wait_for_api):
    request_session, api_url = wait_for_api

    user_id = post(urljoin(api_url, 'users'), {'pseudo': 'tests'}).json()['id']

    post(urljoin(api_url, 'users/{}/tweets'.format(user_id)), {'message': 'My tests tweet !'})

    resp = get(urljoin(api_url, 'users/{}/tweets'.format(user_id)))

    assert resp.status_code == 200, "Status code not equals"

    body = resp.json()

    assert body is not None
    assert len(body) == 1, "Expected one tweet"

    tweet = body[0]

    assert tweet is not None
    assert tweet['id'] is not None
    assert tweet['message'] == 'My tests tweet !'
コード例 #7
0
ファイル: test_users.py プロジェクト: jayxt96/pds-stardust
def test_detail_user(wait_for_api):
    request_session, api_url = wait_for_api

    user = post(urljoin(api_url, 'users'), {'pseudo': 'tests'}).json()

    resp = get(urljoin(api_url, 'users/{}'.format(user['id'])))

    assert resp.status_code == 200, "User not found"

    body = resp.json()

    assert body is not None
    assert body['id'] == user['id']
    assert body['pseudo'] == user['pseudo']
コード例 #8
0
ファイル: test_users.py プロジェクト: jayxt96/pds-stardust
def test_create_user(wait_for_api):
    request_session, api_url = wait_for_api

    payload = {'pseudo': 'tests'}

    resp = post(urljoin(api_url, 'users'), payload)

    assert resp.status_code == 201, "User not successfully created"

    body = resp.json()

    assert body is not None
    assert body['id'] is not None
    assert body['pseudo'] == 'tests'
コード例 #9
0
ファイル: test_users.py プロジェクト: jayxt96/pds-stardust
def test_delete_user(wait_for_api):
    request_session, api_url = wait_for_api

    user = post(urljoin(api_url, 'users'), {'pseudo': 'tests'}).json()

    resp = delete(urljoin(api_url, 'users/{}'.format(user['id'])))

    assert resp.status_code == 204, "User not deleted"

    resp = get(urljoin(api_url, 'users'))

    body = resp.json()

    assert body is not None
    assert len(body) == 0, "Expected no user"
コード例 #10
0
ファイル: test_users.py プロジェクト: jayxt96/pds-stardust
def test_update_user(wait_for_api):
    request_session, api_url = wait_for_api

    user = post(urljoin(api_url, 'users'), {'pseudo': 'tests'}).json()

    payload = {'pseudo': 'updated'}

    resp = patch(urljoin(api_url, 'users/{}'.format(user['id'])), payload)

    assert resp.status_code == 200, "User not updated"

    body = resp.json()

    assert body is not None
    assert body['id'] is not None
    assert body['pseudo'] == 'updated'