Esempio n. 1
0
    def test_response(self):
        e = EventFactory.Generic(status_code=401, content='{"hello":"there"}')

        response = e.response()

        assert isinstance(response, HttpResponse)
        assert response.status_code == 401
        assert response.content == b'{"hello":"there"}'
Esempio n. 2
0
    def test_extend(self):

        e = EventFactory.Generic(status_code=401, content='{"hello":"there"}')
        extended = e.extend(method='POST', path='/hi/there')

        assert extended.method == 'POST'
        assert extended.path == '/hi/there'
        assert isinstance(extended, EventFactory.Generic)
Esempio n. 3
0
    def test_log(self):

        e = EventFactory.Generic(status_code=401, content='{"hello":"there"}')
        e.logger = Mock()

        e.extend(method='POST', path='/hi/there').log()

        assert e.logger.info.call_args_list == (
            [call('[POST /hi/there] -> 401')])
Esempio n. 4
0
    def test_init(self):

        e = EventFactory.Generic(status_code=401, content='{"hello":"there"}')

        assert e.status_code == 401
        assert e.content == '{"hello":"there"}'