def test_configuration_checks_groups(self):
        extractor = passgithelper.RegexSearchExtractor('^username: (.*)$',
                                                       '_username')
        config = configparser.ConfigParser()
        config.read_string(r"""[test]
regex_username=^foo: .*$""")
        with pytest.raises(ValueError):
            extractor.configure(config['test'])
 def test_smoke(self):
     extractor = passgithelper.RegexSearchExtractor('^username: (.*)$', '')
     assert extractor.get_value(
         'foo',
         ['thepassword',
          'somethingelse',
          'username: user',
          'username: second ignored']) == 'user'
    def test_configuration(self):
        extractor = passgithelper.RegexSearchExtractor('^username: (.*)$',
                                                       '_username')
        config = configparser.ConfigParser()
        config.read_string(r"""[test]
regex_username=^foo: (.*)$""")
        extractor.configure(config['test'])
        assert extractor._regex.pattern == r'^foo: (.*)$'
Exemplo n.º 4
0
    def test_configuration_checks_groups(self) -> None:
        extractor = passgithelper.RegexSearchExtractor("^username: (.*)$",
                                                       "_username")
        config = configparser.ConfigParser()
        config.read_string(r"""[test]
regex_username=^foo: .*$""")
        with pytest.raises(ValueError, match="must contain"):
            extractor.configure(config["test"])
Exemplo n.º 5
0
    def test_configuration(self) -> None:
        extractor = passgithelper.RegexSearchExtractor("^username: (.*)$",
                                                       "_username")
        config = configparser.ConfigParser()
        config.read_string(r"""[test]
regex_username=^foo: (.*)$""")
        extractor.configure(config["test"])
        assert extractor._regex.pattern == r"^foo: (.*)$"
Exemplo n.º 6
0
 def test_smoke(self):
     extractor = passgithelper.RegexSearchExtractor("^username: (.*)$", "")
     assert (extractor.get_value(
         "foo",
         [
             "thepassword",
             "somethingelse",
             "username: user",
             "username: second ignored",
         ],
     ) == "user")
 def test_missing_group(self):
     with pytest.raises(ValueError):
         passgithelper.RegexSearchExtractor('^username: .*$', '')
Exemplo n.º 8
0
 def test_missing_group(self) -> None:
     with pytest.raises(ValueError, match="must contain"):
         passgithelper.RegexSearchExtractor("^username: .*$", "")