Skip to content

Commit

Permalink
test_kcidb: Add tests for kcidb-ingest
Browse files Browse the repository at this point in the history
Fix: #242
  • Loading branch information
danghai committed Dec 3, 2023
1 parent 92b925f commit 774a242
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions test_kcidb.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,93 @@ def test_notify_main():
"Subject: Test build: .*\x00"
"Subject: Test test: .*\x00"
"Subject: Test test: .*\x00")


def test_ingest_main():
"""Check kcidb-ingest works"""
assert_executes('', "kcidb.notify_main")
assert_executes('{', "kcidb.ingest_main",
status=1, stderr_re=".*JSONParseError.*")
assert_executes('{}', "kcidb.notify_main",
status=1, stderr_re=".*ValidationError.*")
empty = json.dumps(dict(version=dict(major=SCHEMA.major,
minor=SCHEMA.minor)))
assert_executes(empty, "kcidb.ingest_main")
assert_executes(empty + empty, "kcidb.ingest_main")
git_commit_hash1 = "4ff6a2469104218a044ff595a0c1eb469ca7ea01"
git_commit_hash2 = "fe3fc1bc47d6333d7d06bc530c6e0c1044bab536"

one_of_everything = json.dumps(dict(
version=dict(major=SCHEMA.major, minor=SCHEMA.minor),
checkouts=[
dict(id="test:checkout:1",
git_commit_hash=git_commit_hash1,
patchset_hash="",
origin="test")
],
builds=[
dict(id="test:build:1",
origin="test",
checkout_id="test:checkout:1",
valid=False)
],
tests=[
dict(id="test:test:1",
origin="test",
build_id="test:build:1",
waived=False,
status="PASS")
]
))
assert_executes(one_of_everything, "kcidb.ingest_main",
stdout_re="Subject: Test revision: .*\x00"
"Subject: Test checkout: .*\x00"
"Subject: Test build: .*\x00"
"Subject: Test test: .*\x00")

two_of_everything = json.dumps(dict(
version=dict(major=SCHEMA.major, minor=SCHEMA.minor),
checkouts=[
dict(id="test:checkout:1",
git_commit_hash=git_commit_hash1,
patchset_hash="",
origin="test"),
dict(id="test:checkout:2",
git_commit_hash=git_commit_hash2,
patchset_hash="",
origin="test"),
],
builds=[
dict(id="test:build:1",
origin="test",
checkout_id="test:checkout:1",
valid=False),
dict(id="test:build:2",
origin="test",
checkout_id="test:checkout:2",
valid=False),
],
tests=[
dict(id="test:test:1",
origin="test",
build_id="test:build:1",
waived=False,
status="PASS"),
dict(id="test:test:2",
origin="test",
build_id="test:build:2",
waived=False,
status="FAIL"),
]
))

assert_executes(two_of_everything,
"kcidb.ingest_main",
stdout_re="Subject: Test revision: .*\x00"
"Subject: Test revision: .*\x00"
"Subject: Test checkout: .*\x00"
"Subject: Test checkout: .*\x00"
"Subject: Test build: .*\x00"
"Subject: Test build: .*\x00"
"Subject: Test test: .*\x00"
"Subject: Test test: .*\x00")

0 comments on commit 774a242

Please sign in to comment.