def test_create_chrome_browser_succeeds(self, mock_chrome):
        mock_browser_driver = mock.Mock('mock chrome driver')
        mock_browser_driver.quit = mock.Mock()
        mock_browser_driver.set_page_load_timeout = mock.Mock()
        mock_chrome.return_value = mock_browser_driver

        with browser_client_common.create_browser(names.CHROME) as driver:
            self.assertTrue(mock_chrome.called)
            self.assertEqual(mock_browser_driver, driver)
            self.assertFalse(mock_browser_driver.quit.called)
            self.assertTrue(
                mock_browser_driver.set_page_load_timeout.called_once_with(10))

        self.assertTrue(mock_browser_driver.quit.called)
    def test_create_safari_browser_succeeds(self, mock_safari):
        mock_browser_driver = mock.Mock('mock safari driver')
        mock_browser_driver.quit = mock.Mock()
        mock_browser_driver.set_page_load_timeout = mock.Mock()
        mock_safari.return_value = mock_browser_driver

        with browser_client_common.create_browser(names.SAFARI) as driver:
            self.assertTrue(mock_safari.called)
            self.assertEqual(mock_browser_driver, driver)
            self.assertFalse(mock_browser_driver.quit.called)
            self.assertTrue(
                mock_browser_driver.set_page_load_timeout.called_once_with(10))

        self.assertTrue(mock_browser_driver.quit.called)
    def test_create_firefox_browser_succeeds(self, mock_firefox):
        mock_browser_driver = mock.Mock('mock firefox driver')
        mock_browser_driver.quit = mock.Mock()
        mock_browser_driver.set_page_load_timeout = mock.Mock()
        mock_firefox.return_value = mock_browser_driver

        with browser_client_common.create_browser(names.FIREFOX) as driver:
            self.assertTrue(mock_firefox.called)
            self.assertEqual(mock_browser_driver, driver)
            self.assertFalse(mock_browser_driver.quit.called)
            self.assertTrue(
                mock_browser_driver.set_page_load_timeout.called_once_with(10))

        self.assertTrue(mock_browser_driver.quit.called)
    def test_create_safari_browser_succeeds(self, mock_safari):
        mock_browser_driver = mock.Mock('mock safari driver')
        mock_browser_driver.quit = mock.Mock()
        mock_browser_driver.set_page_load_timeout = mock.Mock()
        mock_safari.return_value = mock_browser_driver

        with browser_client_common.create_browser(names.SAFARI) as driver:
            self.assertTrue(mock_safari.called)
            self.assertEqual(mock_browser_driver, driver)
            self.assertFalse(mock_browser_driver.quit.called)
            self.assertTrue(
                mock_browser_driver.set_page_load_timeout.called_once_with(10))

        self.assertTrue(mock_browser_driver.quit.called)
    def test_create_chrome_browser_succeeds(self, mock_chrome):
        mock_browser_driver = mock.Mock('mock chrome driver')
        mock_browser_driver.quit = mock.Mock()
        mock_browser_driver.set_page_load_timeout = mock.Mock()
        mock_chrome.return_value = mock_browser_driver

        with browser_client_common.create_browser(names.CHROME) as driver:
            self.assertTrue(mock_chrome.called)
            self.assertEqual(mock_browser_driver, driver)
            self.assertFalse(mock_browser_driver.quit.called)
            self.assertTrue(
                mock_browser_driver.set_page_load_timeout.called_once_with(10))

        self.assertTrue(mock_browser_driver.quit.called)
    def test_create_firefox_browser_succeeds(self, mock_firefox):
        mock_browser_driver = mock.Mock('mock firefox driver')
        mock_browser_driver.quit = mock.Mock()
        mock_browser_driver.set_page_load_timeout = mock.Mock()
        mock_firefox.return_value = mock_browser_driver

        with browser_client_common.create_browser(names.FIREFOX) as driver:
            self.assertTrue(mock_firefox.called)
            self.assertEqual(mock_browser_driver, driver)
            self.assertFalse(mock_browser_driver.quit.called)
            self.assertTrue(
                mock_browser_driver.set_page_load_timeout.called_once_with(10))

        self.assertTrue(mock_browser_driver.quit.called)
 def test_create_unrecognized_browser_raises_error(self):
     with self.assertRaises(ValueError):
         with browser_client_common.create_browser('foo'):
             pass
 def test_create_unrecognized_browser_raises_error(self):
     with self.assertRaises(ValueError):
         with browser_client_common.create_browser('foo'):
             pass