예제 #1
0
def test_report_add_meta():
    report = Report("127.0.0.1:8545")
    assert report.meta == {}

    report.add_meta("test-key", "test-value")
    assert report.meta["test-key"] == "test-value"
    assert report.to_dict()["meta"]["test-key"] == "test-value"
예제 #2
0
def test_report_add_issue():
    report = Report("127.0.0.1:8545")
    assert report.issues == []

    issue = Issue(title="test", description="test", severity=Severity.NONE)
    report.add_issue(issue)
    assert report.issues == [issue]
    assert len(report.to_dict()["issues"])
예제 #3
0
def assert_report(report: Report, target, meta):
    assert isinstance(report.timestamp, str)
    assert isinstance(report.id, str)
    report_dict = report.to_dict()
    assert report_dict.get("issues") == []
    assert report_dict.get("meta") == meta
    assert isinstance(report_dict.get("timestamp"), str)
    assert report_dict.get("target") == target
    assert report_dict.get("ok") is True
예제 #4
0
def test_valid_report():
    target = "127.0.0.1:8545"
    report = Report(target, issues=[])
    assert report.issues == []
    assert report.target == target
    assert isinstance(report.id, str)
    assert isinstance(report.timestamp, str)
    assert report.meta == {}
    assert sorted(report.to_dict().keys()) == [
        "id",
        "issues",
        "meta",
        "ok",
        "target",
        "timestamp",
    ]