def test_initialize_local_options(self, options: Options): options.password = "******" options.timeout = 1337 d = Downloader(options) assert d._options is not options assert str(d._options) == str(options) assert str(d._options) != str(opt) options.password = "******" assert d._options.password == "foo"
def test_write_new_section(self, options: Options, config_backup): options.timeout = 42 options.write("https://foo.bar") new_opt = Options.from_config("https://foo.bar") assert options is not new_opt for k, v in options.__dict__.items(): if k == "url": assert v == options.url assert new_opt.url == "https://foo.bar" elif k == "cache": assert type(new_opt.cache) == type(options.cache) # noqa: E721 else: assert getattr(new_opt, k) == v
def test_write_config(self, options: Options, config_backup): options.timeout = 1337 options.license = License.COMMERCIAL options.password = "******" options.write() new_opt = Options.from_config() for k, v in options.__dict__.items(): if k == "cache": assert type(new_opt.cache) == type(options.cache) # noqa: E721 elif k == "password": # don't store the password in the file assert getattr(new_opt, k) is None elif k not in ("timeout", "license"): assert getattr(new_opt, k) == v assert new_opt.timeout == 1337 assert new_opt.license == License.COMMERCIAL
def test_invalid_timeout(self, options: Options): with pytest.raises(ValueError): options.timeout = 0