コード例 #1
0
ファイル: test_fetchers.py プロジェクト: tribe29/checkmk
 def test_fetcher_deserialization(self, fetcher: IPMIFetcher) -> None:
     other = type(fetcher).from_json(json_identity(fetcher.to_json()))
     assert isinstance(other, type(fetcher))
     assert other.file_cache == fetcher.file_cache
     assert other.address == fetcher.address
     assert other.username == fetcher.username
     assert other.password == fetcher.password
コード例 #2
0
ファイル: test_fetchers.py プロジェクト: bbaumer/checkmk
 def fetcher(self, file_cache):
     return IPMIFetcher(
         file_cache,
         address="1.2.3.4",
         username="******",
         password="******",
     )
コード例 #3
0
ファイル: test_fetchers.py プロジェクト: tribe29/checkmk
 def fetcher(self, file_cache: DefaultAgentFileCache) -> IPMIFetcher:
     return IPMIFetcher(
         file_cache,
         address="1.2.3.4",
         username="******",
         password="******",
     )
コード例 #4
0
ファイル: test_fetchers.py プロジェクト: sebastian823/checkmk
 def test_parse_sensor_reading_standard_case(self):
     reading = SensorReading(  #
         ['lower non-critical threshold'], 1, "Hugo", None, "", [42],
         "hugo-type", None, 0)
     assert IPMIFetcher._parse_sensor_reading(  #
         0,
         reading) == [b"0", b"Hugo", b"hugo-type", b"N/A", b"", b"WARNING"]
コード例 #5
0
ファイル: test_fetchers.py プロジェクト: sebastian823/checkmk
 def test_parse_sensor_reading_false_positive(self):
     reading = SensorReading(  #
         ['Present'], 1, "Dingeling", 0.2, b"\xc2\xb0C", [], "FancyDevice",
         3.14159265, 1)
     assert IPMIFetcher._parse_sensor_reading(  #
         0, reading) == [
             b"0", b"Dingeling", b"FancyDevice", b"3.14", b"C", b"Present"
         ]
コード例 #6
0
ファイル: test_fetchers.py プロジェクト: tribe29/checkmk
 def test_parse_sensor_reading_false_positive(self, fetcher: IPMIFetcher) -> None:
     reading = SensorReading(  #
         ["Present"], 1, "Dingeling", 0.2, b"\xc2\xb0C", [], "FancyDevice", 3.14159265, 1
     )
     assert fetcher._parse_sensor_reading(0, reading) == [  #
         b"0",
         b"Dingeling",
         b"FancyDevice",
         b"3.14",
         b"C",
         b"Present",
     ]
コード例 #7
0
ファイル: test_fetchers.py プロジェクト: tribe29/checkmk
 def test_parse_sensor_reading_standard_case(self, fetcher: IPMIFetcher) -> None:
     reading = SensorReading(  #
         ["lower non-critical threshold"], 1, "Hugo", None, "", [42], "hugo-type", None, 0
     )
     assert fetcher._parse_sensor_reading(0, reading) == [  #
         b"0",
         b"Hugo",
         b"hugo-type",
         b"N/A",
         b"",
         b"lower non-critical threshold",
     ]
コード例 #8
0
ファイル: test_fetchers.py プロジェクト: maxmalysh/checkmk
    def test_command_raises_IpmiException_handling(self, file_cache, monkeypatch):
        def open_(*args):
            raise IpmiException()

        monkeypatch.setattr(IPMIFetcher, "open", open_)

        with pytest.raises(MKFetcherError):
            with IPMIFetcher(
                    file_cache,
                    address="127.0.0.1",
                    username="",
                    password="",
            ):
                pass
コード例 #9
0
ファイル: test_fetchers.py プロジェクト: LinuxHaus/checkmk
    def test_command_raises_IpmiException_handling(
            self, file_cache: AgentFileCache,
            monkeypatch: MonkeyPatch) -> None:
        def open_(*args):
            raise IpmiException()

        monkeypatch.setattr(IPMIFetcher, "open", open_)

        with IPMIFetcher(
                file_cache,
                address="127.0.0.1",
                username="",
                password="",
        ) as fetcher:
            fetched = fetcher.fetch(Mode.CHECKING)

        assert isinstance(fetched.error, MKFetcherError)
コード例 #10
0
ファイル: test_fetchers.py プロジェクト: LinuxHaus/checkmk
    def test_with_cached_does_not_open(self, file_cache: AgentFileCache,
                                       monkeypatch: MonkeyPatch) -> None:
        def open_(*args):
            raise IpmiException()

        monkeypatch.setattr(IPMIFetcher, "open", open_)

        file_cache.write(AgentRawData(b"<<<whatever>>>"), Mode.CHECKING)
        with IPMIFetcher(
                file_cache,
                address="127.0.0.1",
                username="",
                password="",
        ) as fetcher:
            fetched = fetcher.fetch(Mode.CHECKING)

        assert fetched.is_ok()