Exemple #1
0
def test_auth_missing_body():
    with Session() as sess:
        request = Request('GET', '/auth')
        with pytest.raises(BackendAPIError) as e:
            with request.fetch():
                pass
        assert e.value.status == 400
Exemple #2
0
 def test_auth_missing_body(self):
     with Session() as sess:
         request = Request(sess, 'GET', '/auth')
         with pytest.raises(BackendAPIError) as e:
             with request.fetch():
                 pass
         assert e.value.status == 400
Exemple #3
0
def test_auth_malformed():
    with Session() as sess:
        request = Request('GET', '/auth')
        request.set_content(
            b'<this is not json>',
            content_type='application/json',
        )
        with pytest.raises(BackendAPIError) as e:
            with request.fetch():
                pass
        assert e.value.status == 400
Exemple #4
0
 def test_auth_malformed(self):
     with Session() as sess:
         request = Request(sess, 'GET', '/auth')
         request.set_content(
             b'<this is not json>',
             content_type='application/json',
         )
         with pytest.raises(BackendAPIError) as e:
             with request.fetch():
                 pass
         assert e.value.status == 400
Exemple #5
0
async def test_async_auth():
    random_msg = uuid.uuid4().hex
    async with AsyncSession() as sess:
        request = Request('GET', '/auth')
        request.set_json({
            'echo': random_msg,
        })
        async with request.fetch() as resp:
            assert resp.status == 200
            data = await resp.json()
            assert data['authorized'] == 'yes'
            assert data['echo'] == random_msg
Exemple #6
0
 async def test_async_auth(self):
     random_msg = uuid.uuid4().hex
     async with AsyncSession() as sess:
         request = Request(sess, 'GET', '/auth')
         request.set_json({
             'echo': random_msg,
         })
         async with request.fetch() as resp:
             assert resp.status == 200
             data = await resp.json()
             assert data['authorized'] == 'yes'
             assert data['echo'] == random_msg