Skip to content

Instantly share code, notes, and snippets.

@kevsmith
Created March 12, 2014 13:57
Show Gist options
  • Select an option

  • Save kevsmith/9507425 to your computer and use it in GitHub Desktop.

Select an option

Save kevsmith/9507425 to your computer and use it in GitHub Desktop.
def test_create_dupe_user():
> api.create_user(USER_TESTY, api.ADMIN_TOKEN, validate=v.write_success)
test_user.py:21:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
user = {'email': 'tess@testersons.com', 'first_name': 'Tess', 'last_name': 'Testerson', 'password': 'testing', ...}, token = 'burritos4lyfe', validate = <function write_success at 0x10a621b90>
def create_user(user, token, validate=None):
resp = requests.post(build_url('users', user['username']),
headers = {'X-Planet-Session':token, 'Content-type':'application/json'},
data = json.dumps(user))
> return validate_response(resp, validate)
api.py:43:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
resp = <Response [409]>, obj = {'error': "User 'testy' already exists."}
def write_success(resp, obj):
> assert resp.status_code == 204, 'Response code should be 204'
E AssertionError: Response code should be 204
validators.py:8: AssertionError
==================1 failed, 7 passed in 4.98 seconds =============================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment