def test_firefox_default(self): url = 'http://fox.example.com' target = self.config.target(url) with self.assertRaises(Exception) as context: browser(target, url).command() self.assertTrue( 'Unsupported Browser: firefox' in str(context.exception))
def test_strip_trailing_slash(self): url = 'https://gitlab.com/exampleuser/' target = self.config.target(url) command = browser(target, url).command() self.assertEqual( command, '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --profile-directory="Profile 2" "https://gitlab.com/exampleuser/" >> /dev/null &' )
def test_https_schema(self): url = 'https://schema.example.com/johndoe/' target = self.config.target(url) command = browser(target, url).command() self.assertEqual( command, '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --profile-directory="Profile 2" "https://schema.example.com/johndoe/" >> /dev/null &' )
def test_chrome_guest_overwrite_incognito(self): url = 'http://my-guest-not-incognito.example.com' target = self.config.target(url) command = browser(target, url).command() self.assertEqual( command, '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --guest "http://my-guest-not-incognito.example.com" >> /dev/null &' )
def test_chrome_incognito(self): url = 'http://secret.example.com' target = self.config.target(url) command = browser(target, url).command() self.assertEqual( command, '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --profile-directory="Default" --incognito "http://secret.example.com" >> /dev/null &' )
def test_start_null(self): url = 'http://www.bad-site.com/' target = self.config.target(url) command = browser(target, url).command() self.assertEqual( command, 'echo "Url http://www.bad-site.com/ was not opened" >> /dev/null &' )
def test_chrome_profile1(self): url = 'http://github.com/johndoe' target = self.config.target(url) command = browser(target, url).command() self.assertEqual( command, '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --profile-directory="Profile 1" "http://github.com/johndoe" >> /dev/null &' )
def run(self, url): target = self.config.target(url) logging.getLogger('history').info("open: %s\t\turl: %s" % (target, url)) command_to_execute = browser(target, url).command() logging.getLogger('application').info(command_to_execute) return os.system(command_to_execute)