Exemplo n.º 1
0
 def test_collect_invalid_timeout(self):
     with pytest.raises(ConfigurationError,
                        match=r"^Configuration error .*"):
         parser = configparser.ConfigParser()
         parser.read_string('''[section]
                            url=nourl
                            timeout=xx''')
         NetworkMixin.collect_init_args(parser['section'])
Exemplo n.º 2
0
 def test_password_missing(self) -> None:
     with pytest.raises(ConfigurationError, match=r"^Username and.*"):
         parser = configparser.ConfigParser()
         parser.read_string(
             """
             [section]
             url=ok
             username=xxx
             """
         )
         NetworkMixin.collect_init_args(parser["section"])
Exemplo n.º 3
0
 def test_collect_timeout(self):
     parser = configparser.ConfigParser()
     parser.read_string('''[section]
                        url=nourl
                        timeout=42''')
     args = NetworkMixin.collect_init_args(parser['section'])
     assert args['timeout'] == 42
Exemplo n.º 4
0
 def test_collect_default_timeout(self) -> None:
     parser = configparser.ConfigParser()
     parser.read_string(
         """
         [section]
         url=nourl
         """
     )
     args = NetworkMixin.collect_init_args(parser["section"])
     assert args["timeout"] == 5
Exemplo n.º 5
0
 def test_collect_missing_url(self) -> None:
     with pytest.raises(ConfigurationError, match=r"^Lacks 'url'.*"):
         parser = configparser.ConfigParser()
         parser.read_string("[section]")
         NetworkMixin.collect_init_args(parser["section"])