def test_render_component_logs():
    entries = [LogEntry({"id": "log-01", "level": "info", "message": "hello"})]
    html = render_component("logs", data=entries)
    # TODO: smarter html checks?
    assert '"id": "log-01"' in html
    assert '"level": "info"' in html
    assert '"message": "hello"' in html
def test_log_entry_basic_kwargs():
    log = LogEntry(id="log01", level="info", message="hello")
    assert log["id"] == "log01"
    assert log.id == "log01"
    assert log["level"] == "info"
    assert log.level == "info"
    assert log["message"] == "hello"
    assert log.message == "hello"
def test_log_entry_basic_dict():
    data = {"id": "log01", "level": "info", "message": "hello"}
    log = LogEntry(data)
    assert log["id"] == "log01"
    assert log.id == "log01"
    assert log["level"] == "info"
    assert log.level == "info"
    assert log["message"] == "hello"
    assert log.message == "hello"
Esempio n. 4
0
 def logs(self, offset=None) -> List[LogEntry]:
     """ Retrieve service logs."""
     url = "/service/{}/logs".format(self.service_id)
     logs = self.connection.get(url,
                                params={
                                    'offset': offset
                                },
                                expected_status=200).json()["logs"]
     entries = [LogEntry(log) for log in logs]
     return VisualList('logs', data=entries)
Esempio n. 5
0
 def logs(self, offset=None) -> List[LogEntry]:
     """ Retrieve job logs."""
     # TODO: option to filter on level? Or move filtering functionality to a separate batch job logs class?
     url = "/jobs/{}/logs".format(self.job_id)
     logs = self.connection.get(url,
                                params={
                                    'offset': offset
                                },
                                expected_status=200).json()["logs"]
     entries = [LogEntry(log) for log in logs]
     return VisualList('logs', data=entries)
def test_log_entry_empty():
    with pytest.raises(ValueError, match="Missing required fields"):
        _ = LogEntry()
def test_log_entry_legacy():
    log = LogEntry(id="log01", level="info", message="hello")
    assert log.log_id == "log01"