Пример #1
0
    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
Пример #2
0
    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
Пример #3
0
 def test_write_new_section_not_url(self, options: Options, config_backup):
     with pytest.raises(ValueError, match=r"Invalid URL: `foobar`."):
         options.write("foobar")