예제 #1
0
 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
 def fetcher(self, file_cache):
     return IPMIFetcher(
         file_cache,
         address="1.2.3.4",
         username="******",
         password="******",
     )
예제 #3
0
 def fetcher(self, file_cache: DefaultAgentFileCache) -> IPMIFetcher:
     return IPMIFetcher(
         file_cache,
         address="1.2.3.4",
         username="******",
         password="******",
     )
예제 #4
0
 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
 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
 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
 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
    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
    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
    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()