Advertisement
ArturManukian

Untitled

Aug 10th, 2018
1,152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. def register(client, username, password, email, first_name, last_name, phone):
  2.     return client.post("/register", data=dict(
  3.         username=username,
  4.         password=password,
  5.         email=email,
  6.         first_name=first_name,
  7.         last_name=last_name,
  8.         phone=phone
  9.     ), follow_redirects=True)
  10.  
  11.  
  12. def login(client, email, password):
  13.     return client.post("/login", data=dict(
  14.         email=email,
  15.         password=password
  16.     ), follow_redirects=True)
  17.  
  18.  
  19. def test_register(client):
  20.     """Make sure register works."""
  21.     rv = register(client, "testuser", "testpassword", "testuser@gmail.com", "test name", "test lastname", 911)
  22.     assert b"New user: 'testuser' is SUCCESSFUL ADDED" in rv.data
  23.  
  24.  
  25. def test_login_logout(client):
  26.     """Make sure login and logout works."""
  27.  
  28.     rv = login(client, "vlad@gmail.com", "vlad")
  29.     assert b"Logged in as vlad@gmail.com" in rv.data
  30.  
  31.     rv = smoke(client)
  32.     assert b"OK" in rv.data
  33.  
  34.     rv = logout(client)
  35.     assert b"Dropped" in rv.data
  36.  
  37.     rv = smoke(client)
  38.     assert b"You are not allowed to use this resource without logging in!" in rv.data
  39.  
  40.     rv = login(client, "vlad@gmail.com" + "x", "vlad")
  41.     assert b"Could not verify your login!" in rv.data
  42.  
  43.     rv = login(client, "vlad@gmail.com" + "x", "vlad" + "x")
  44.     assert b"Could not verify your login!" in rv.data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement