def test_StartSever_fresh_replaymode(self, wpr_mock):
        wpr_server = chrome_proxy_utils.WPRServer()
        wpr_archive_file = os.path.abspath(__file__)
        wpr_server.StartServer(wpr_archive_file)

        wpr_mock.assert_called_once_with(wpr_archive_file,
                                         '127.0.0.1',
                                         http_port=0,
                                         https_port=0,
                                         replay_options=[])

        self.assertEqual(wpr_server._archive_path, wpr_archive_file)
        self.assertTrue(wpr_server._server)
 def test_StartSever_notReuseServer(self, stop_server_mock,
                                    start_server_mock):
     wpr_server = chrome_proxy_utils.WPRServer()
     wpr_server._server = webpagereplay_go_server.ReplayServer(
         os.path.abspath(__file__),
         chrome_proxy_utils.PROXY_HOST_IP,
         http_port=0,
         https_port=0,
         replay_options=[])
     wpr_server._archive_path = ''
     wpr_server.StartServer(os.path.abspath(__file__))
     start_server_mock.assert_called_once()
     stop_server_mock.assert_called_once()
 def test_StopServer(self, stop_server_mock):
   wpr_server = chrome_proxy_utils.WPRServer()
   wpr_server._server = webpagereplay_go_server.ReplayServer(
       os.path.abspath(__file__),
       chrome_proxy_utils.PROXY_HOST_IP,
       http_port=0,
       https_port=0,
       replay_options=[])
   wpr_server.StopServer()
   stop_server_mock.assert_called_once()
   self.assertFalse(wpr_server._server)
   self.assertFalse(wpr_server._archive_path)
   self.assertFalse(wpr_server.http_port)
   self.assertFalse(wpr_server.https_port)
 def test_SetWPRRecordMode(self):
   wpr_server = chrome_proxy_utils.WPRServer()
   wpr_server.record_mode = True
   self.assertTrue(wpr_server.record_mode)
   wpr_server.record_mode = False
   self.assertFalse(wpr_server.record_mode)