def test_ignore_no_such_process(self, monkeypatch) -> None:
        def data():
            return [self.RaisingProcess()]

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

        Processes("foo", ["dummy"]).check()
    def test_non_matching_process(self, monkeypatch) -> None:
        def data():
            return [self.StubProcess("asdfasdf"), self.StubProcess("nonmatching")]

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

        assert Processes("foo", ["dummy", "blubb", "other"]).check() is None
Exemplo n.º 3
0
    def test_ignore_no_such_process(self, monkeypatch):

        def data():
            return [self.RaisingProcess()]
        monkeypatch.setattr(psutil, 'process_iter', data)

        Processes('foo', ['dummy']).check()
Exemplo n.º 4
0
    def test_matching_process(self, monkeypatch):

        def data():
            return [self.StubProcess('blubb'), self.StubProcess('nonmatching')]
        monkeypatch.setattr(psutil, 'process_iter', data)

        assert Processes(
            'foo', ['dummy', 'blubb', 'other']).check() is not None
 def test_create(self) -> None:
     parser = configparser.ConfigParser()
     parser.read_string(
         """
         [section]
         processes = foo, bar, narf
         """
     )
     assert Processes.create("name", parser["section"])._processes == [
         "foo",
         "bar",
         "narf",
     ]
 def test_create_no_entry(self) -> None:
     parser = configparser.ConfigParser()
     parser.read_string("""[section]""")
     with pytest.raises(ConfigurationError):
         Processes.create("name", parser["section"])
 def create_instance(self, name):
     return Processes(name, ["foo"])
Exemplo n.º 8
0
 def test_create_no_entry(self):
     parser = configparser.ConfigParser()
     parser.read_string('''[section]''')
     with pytest.raises(ConfigurationError):
         Processes.create('name', parser['section'])
Exemplo n.º 9
0
 def test_create(self):
     parser = configparser.ConfigParser()
     parser.read_string('''[section]
                        processes = foo, bar, narf''')
     assert Processes.create(
         'name', parser['section'])._processes == ['foo', 'bar', 'narf']