Something something like soundcloud but not like soundcloud.
Log in, upload records, done.
Simple, easy, KISS.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

helpers.py 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import json
  2. from os.path import join, dirname
  3. from jsonschema import validate
  4. def login(client, email, password):
  5. return client.post("/login", data=dict(email=email, password=password), follow_redirects=True)
  6. def logout(client):
  7. return client.get("/logout", follow_redirects=True)
  8. def register(c, email, password, name):
  9. logout(c)
  10. resp = c.post(
  11. "/register",
  12. data=dict(email=email, password=password, password_confirm=password, name=name),
  13. follow_redirects=True,
  14. )
  15. # should be directly logged
  16. assert b"Logged as" in resp.data
  17. assert resp.status_code == 200
  18. # logout
  19. logout(c)
  20. resp = c.get("/")
  21. assert b"Logged as" not in resp.data
  22. def assert_valid_schema(data, schema_file):
  23. """ Checks whether the given data matches the schema """
  24. schema = _load_json_schema(schema_file)
  25. return validate(data, schema)
  26. def _load_json_schema(filename):
  27. """ Loads the given schema file """
  28. relative_path = join("schemas", filename)
  29. absolute_path = join(dirname(__file__), relative_path)
  30. with open(absolute_path) as schema_file:
  31. return json.loads(schema_file.read())