def test_register_with_same_deviceid_twice_fails(): unauthed_user = ScreenshotsClient() resp = unauthed_user.session.post( urljoin(unauthed_user.backend, "/api/register"), data=dict(deviceId=unauthed_user.deviceId, secret=unauthed_user.secret, deviceInfo=json.dumps(unauthed_user.deviceInfo))) print resp.text assert resp.status_code == 200 # registering twice as same user should fail resp = unauthed_user.session.post( urljoin(unauthed_user.backend, "/api/register"), data=dict(deviceId=unauthed_user.deviceId, secret=unauthed_user.secret, deviceInfo=json.dumps(unauthed_user.deviceInfo))) print resp.text assert resp.status_code == 401 # user exists unauthed_user.delete_account() # registering as second user should fail second_unauthed_user = ScreenshotsClient() resp = second_unauthed_user.session.post( urljoin(second_unauthed_user.backend, "/api/register"), data=dict(deviceId=unauthed_user.deviceId, secret=second_unauthed_user.secret, deviceInfo=json.dumps(second_unauthed_user.deviceInfo))) print resp.text assert resp.status_code == 401 # user exists
def test_register_without_deviceinfo_ok(): unauthed_user = ScreenshotsClient() resp = unauthed_user.session.post( urljoin(unauthed_user.backend, "/api/register"), data=dict(deviceId=unauthed_user.deviceId, secret=unauthed_user.secret)) print resp.text assert resp.status_code == 200 unauthed_user.delete_account()
def test_bad_id(): user = ScreenshotsClient() user.login() try: try: user.create_shot(shot_id="!!!/test.com") except HTTPError, e: if e.response.status_code != 400: raise finally: user.delete_account()
def test_put_large_image(): user = ScreenshotsClient() user.login() try: try: user.create_shot(pad_image_to_length=100 * 1000 * 1000) except HTTPError, e: if e.response.status_code != 413: raise finally: user.delete_account()