def test_create_regex_error(self):
        parser = configparser.ConfigParser()
        parser.read_string('''[section]
                           name = name.*name
                           terminal = term.[[a-9]term
                           host = host.*host''')

        with pytest.raises(ConfigurationError):
            Users.create('name', parser['section'])
    def test_create_regex_error(self) -> None:
        parser = configparser.ConfigParser()
        parser.read_string(
            """
            [section]
            name = name.*name
            terminal = term.[[a-9]term
            host = host.*host
            """
        )

        with pytest.raises(ConfigurationError):
            Users.create("name", parser["section"])
    def test_matching_users(self, monkeypatch):

        def data():
            return [self.create_suser('foo', 'pts1', 'host', 12345, 12345)]
        monkeypatch.setattr(psutil, 'users', data)

        assert Users('users', re.compile('.*'), re.compile('.*'),
                     re.compile('.*')).check() is not None
    def test_no_users(self, monkeypatch):

        def data():
            return []
        monkeypatch.setattr(psutil, 'users', data)

        assert Users('users', re.compile('.*'), re.compile('.*'),
                     re.compile('.*')).check() is None
    def test_matching_users(self, monkeypatch) -> None:
        def data():
            return [self.create_suser("foo", "pts1", "host", 12345, 12345)]

        monkeypatch.setattr(psutil, "users", data)

        assert (
            Users("users", re.compile(".*"), re.compile(".*"), re.compile(".*")).check()
            is not None
        )
    def test_no_users(self, monkeypatch) -> None:
        def data():
            return []

        monkeypatch.setattr(psutil, "users", data)

        assert (
            Users("users", re.compile(".*"), re.compile(".*"), re.compile(".*")).check()
            is None
        )
    def test_create(self):
        parser = configparser.ConfigParser()
        parser.read_string('''[section]
                           name = name.*name
                           terminal = term.*term
                           host = host.*host''')

        check = Users.create('name', parser['section'])

        assert check._user_regex == re.compile('name.*name')
        assert check._terminal_regex == re.compile('term.*term')
        assert check._host_regex == re.compile('host.*host')
    def test_create(self) -> None:
        parser = configparser.ConfigParser()
        parser.read_string(
            """
            [section]
            name = name.*name
            terminal = term.*term
            host = host.*host
            """
        )

        check = Users.create("name", parser["section"])

        assert check._user_regex == re.compile("name.*name")
        assert check._terminal_regex == re.compile("term.*term")
        assert check._host_regex == re.compile("host.*host")
 def test_smoke(self) -> None:
     Users("users", re.compile(".*"), re.compile(".*"), re.compile(".*")).check()
 def create_instance(self, name):
     return Users(name, re.compile(".*"), re.compile(".*"), re.compile(".*"))
 def test_smoke(self):
     Users('users', re.compile('.*'), re.compile('.*'),
           re.compile('.*')).check()
 def create_instance(self, name):
     return Users(name, re.compile('.*'), re.compile('.*'),
                  re.compile('.*'))