Beispiel #1
0
    def test_get_stream(self):
        with closing(http.get('/stream', stream=True)) as r:
            x = r.iter_content()
            content = b""
            for i in x:
                content += i

        self.assertEqual(r.status_code, 200)
        self.assertEqual(
            content.decode("utf-8"),
            "".join([x.decode("utf-8") for x in generate_bytes()]))
    def test_simple_get(self):
        http.get("/")

        self.assertThat(SIMPLE_GET).is_stored()
    def test_withPathParameter(self):
        http.get("/path/foobar")

        self.assertThat(GET_WITH_PATH_PARAMETER + " foobar").is_stored()
    def test_givenMissingOrMalformedQueryParams_thenReturn400BadRequest(self):
        response = http.get("/params?query=foo&age=a")

        self.assertEqual(400, response.status_code)
        self.assertThat(GET_WITH_PARAMETERS + " foo a").is_never_stored()
    def test_getWithQueryParameters(self):
        response = http.get("/params?query=foo&age=13")

        self.assertEqual(200, response.status_code)
        self.assertThat(GET_WITH_PARAMETERS).is_contained()
Beispiel #6
0
    def test_lazy_singleton_is_instantiated_once_and_only_once(self):
        res = http.get("/dependency/lazybean")
        http.get("/dependency/lazybean")

        self.assertEqual(200, res.status_code)
        self.assertThat(INSTANTIATED_LAZY_BEAN).is_stored_only_once()
Beispiel #7
0
def do_test_request_scope_query(_):
    res = http.get("/dependency/request-scoped")
    return res.content.decode("utf-8")
Beispiel #8
0
    def test_request_scoped_component_is_instantiated_once_for_a_single_request(self):
        res = http.get("/dependency/request-scoped")

        self.assertEqual(200, res.status_code)
        self.assertThat(INSTANTIATED_REQUEST_SCOPED_BEAN + res.content.decode("utf-8")).is_stored_only_once()
Beispiel #9
0
    def test_sendEvent(self):
        http.get("/event")

        self.assertThat(RUNNABLE_EVENT_HANDLER).is_stored()
        self.assertThat(INSTANTIATED_EVENT_HANDLER).is_stored()
        self.assertThat(FUNCTION_EVENT_HANDLER).is_stored()
Beispiel #10
0
    def test_filterIsCalled(self):
        http.get("/")

        self.assertThat(FILTER).is_stored()