Example #1
0
    def test_restart_http_mock(self):

        update_http_rules(rules)

        start_http_mock()

        response = requests.get('https://duckduckgo.com/?q=mock-services')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'Coincoin!')

        self.assertTrue(stop_http_mock())

        # already stopped
        self.assertFalse(stop_http_mock())

        response = requests.get('https://duckduckgo.com/?q=mock-services')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content[:15], '<!DOCTYPE html>')

        self.assertTrue(start_http_mock())

        response = requests.get('https://duckduckgo.com/?q=mock-services')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'Coincoin!')

        # already started
        self.assertFalse(start_http_mock())
Example #2
0
    def test_restart_http_mock(self):

        update_http_rules(rules)

        start_http_mock()

        response = requests.get('https://duckduckgo.com/?q=mock-services')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, b'Coincoin!')

        self.assertTrue(stop_http_mock())

        # already stopped
        self.assertFalse(stop_http_mock())

        response = requests.get('https://duckduckgo.com/?q=mock-services')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content[:15], b'<!DOCTYPE html>')

        self.assertTrue(start_http_mock())

        response = requests.get('https://duckduckgo.com/?q=mock-services')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, b'Coincoin!')

        # already started
        self.assertFalse(start_http_mock())
Example #3
0
 def setUp(self):
     stop_http_mock()
     reset_rules()
     http_mock.set_allow_external(False)
Example #4
0
 def tearDown(self):
     mock_services.stop_http_mock()
Example #5
0
 def setUp(self):
     stop_http_mock()
     reset_rules()
Example #6
0
 def tearDown(self):
     mock_services.stop_http_mock()
Example #7
0
 def setUp(self):
     stop_http_mock()
     reset_rules()
     http_mock.set_allow_external(False)
Example #8
0
 def setUp(self):
     stop_http_mock()
     reset_rules()