Example #1
0
    def test_behavior_consistency_1(self):
        """It should return the server's response after several queries
        with status code 500, as the requests library would do"""

        url = 'http://localhost:7654/status_code=500'

        res = obstinate.oget(url, o_status_forcelist=['5xx'])

        self.assertEqual(res.status_code, 500)
Example #2
0
    def test_code_200(self):
        """It should returns the server's response when everthing works
        fine"""

        url = 'http://localhost:7654/status_code=200'

        res = obstinate.oget(url)

        self.assertEqual(res.status_code, 200)
Example #3
0
    def test_status_forcelist_2(self):
        """It should not make several attemps when the status code
        received wasn't listed in `o_status_forcelist`"""

        url = 'http://localhost:7654/status_code=500'

        # start counting the number of requests received
        self.http_server.reset_counter()

        res = obstinate.oget(url, o_status_forcelist=['501'], o_max_attempts=2)

        self.assertEqual(1, self.http_server.counter())
Example #4
0
 def f():
     url = 'htp:/url-with-wrong-format.error'
     res = obstinate.oget(url)