예제 #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"}'
예제 #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)
예제 #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')])
예제 #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"}'