def test_AnonymousUser():
    u = auth.AnonymousUser()
    eq_(u.type, 'anonymous')
    eq_(str(u), 'anonymous:')
    eq_(u.is_authenticated, False)
    eq_(u.is_active, False)
    eq_(u.is_anonymous, True)
    eq_(u.permissions, set())
Example #2
0
    assert_no_upload_rows(app)


@moto.mock_s3
@test_context
def test_upload_batch_author(app, client):
    """A POST to /upload with an author is rejected."""
    batch = mkbatch()
    batch['author'] = 'me'  # matches authentication
    resp = upload_batch(client, batch)
    eq_(resp.status_code, 400)
    assert_no_upload_rows(app)


@moto.mock_s3
@test_context.specialize(user=auth.AnonymousUser())
def test_upload_batch_no_user(app, client):
    """A POST to /upload with non-user-associated authentication fails"""
    batch = mkbatch()
    resp = upload_batch(client, batch)
    eq_(resp.status_code, 400)
    assert_no_upload_rows(app)


@moto.mock_s3
@test_context
def test_upload_batch_empty_files(app, client):
    """A POST to /upload with no files is rejected."""
    batch = mkbatch()
    batch['files'] = {}
    resp = upload_batch(client, batch)