Exemplo n.º 1
0
class Driver(object):
    def __init__(self, version, os_type):
        # type: (str, str) -> None
        self.config = Configuration(file_name=config.filename,
                                    config_folder=config.folder,
                                    section=self.__class__.__name__)
        self.config.set("version", version)
        self._url = self.config.url
        self.name = self.config.name
        self._version = self.config.version
        self.os_type = os_type

    def get_url(self):
        # type: () -> str
        url = "{url}/{ver}/{name}_{os}.zip"
        return url.format(url=self._url,
                          ver=self.get_version(),
                          name=self.name,
                          os=self.os_type)

    def get_version(self):
        # type: () -> str
        if self._version == "latest":
            return self.get_latest_release_version()
        return self._version

    def get_latest_release_version(self):
        # type: () -> str
        raise NotImplementedError("Please implement this method")
Exemplo n.º 2
0
 def __init__(self, version, os_type):
     self.config = Configuration(file_name=config.filename,
                                 config_folder=config.folder,
                                 section=self.__class__.__name__)
     self.config.set("version", version)
     self._url = self.config.url
     self.name = self.config.name
     self._version = self.config.version
     self.os_type = os_type
Exemplo n.º 3
0
def test_config_with_deafault_params():
    config = Configuration(config_folder=os.path.dirname(__file__),
                           section="GeckoDriver",
                           file_name="config.ini")
    assert config.driver_latest_release_url == expect_mz_latest
    assert config.mozila_release_tag == expect_mz_tag
    assert config.gh_token == expect_gh_token
Exemplo n.º 4
0
def test_config_variables_with_default_params():
    config = Configuration(section="GeckoDriver",
                           file_name="",
                           config_folder="")
    assert config.gh_token == ''
    assert config.driver_latest_release_url == expect_mz_latest
    assert config.mozila_release_tag == expect_mz_tag
Exemplo n.º 5
0
def test_config_can_get_variable_from_env():
    os.environ["OFFLINE"] = 'true'
    config = Configuration(config_folder=os.path.dirname(__file__),
                           file_name="wd_config.ini",
                           section="GeckoDriver")
    assert config.offline == 'true'
    os.environ["OFFLINE"] = 'false'
Exemplo n.º 6
0
def test_cached_driver_manual_setup():
    config = Configuration(config_folder=os.path.dirname(__file__), file_name="wd_config.ini", section="ChromeDriver")
    version = "2.26"
    os_type = "linux"
    driver = ChromeDriver(version=version,
                          os_type=os_type)
    driver.config = config
    with pytest.raises(IOError) as ex:
        cache.get_cached_binary(driver)
    assert ex.value.args[1] == 'Is a directory'
Exemplo n.º 7
0
def test_config_with_custom_file():
    config = Configuration(config_folder=os.path.dirname(__file__),
                           file_name="wd_config.ini",
                           section="GeckoDriver")
    assert config.gh_token == "test_token"
    assert config.driver_latest_release_url == "test_release"
Exemplo n.º 8
0
def test_config_can_get_variable_from_file_if_no_env_variable_set():
    config = Configuration(config_folder=os.path.dirname(__file__),
                           file_name="wd_config.ini",
                           section="GeckoDriver")
    assert config.offline == 'false'