test_create_and_label_carry_the_id_three_ways

Tests › tests/test_wiki_issues.py

passed Passed in the packaged run.

What this test is for

Why it exists

Write side (used by `clew wiki serve`): create with title, label and marker line.

Given

  1. gh = _Fake( {("POST", "https://api.github.com/repos/acme/demo/issues"): {"number": 3, "html_url": "u3"}} )
  2. made = GitHubIssues("acme/demo", token="t", opener=gh).create("REQ-1", "Title", "Body")
4 more
  1. sent = json.loads(gh.seen[0][3])
  2. ado = _Fake( { ("POST", "https://dev.azure.com/org/proj/_apis/wit/workitems/$Issue?api-version=7.0"): { "id": 4 } } )
  3. made = AdoIssues("org/proj", token="p", opener=ado).create("REQ-1", "Title", "Body")
  4. patch = {op["path"]: op["value"] for op in json.loads(ado.seen[0][3])}
→

When

  1. —
→

Then

  1. ✓ made equals ("3", "u3")
  2. ✓ sent["labels"] equals ["req:REQ-1"]
  3. ✓ sent["body"] contains "clew-req: REQ-1"
  4. ✓ sent["title"].startswith("REQ-1") holds
  5. ✓ made equals ("4", "https://dev.azure.com/org/proj/_workitems/edit/4")
  6. ✓ patch["/fields/System.Tags"] equals "req:REQ-1"
  7. ✓ patch["/fields/System.Description"] contains "clew-req: REQ-1"
  8. ✓ ado.seen[0][2]["Content-type"] equals "application/json-patch+json"

tests/test_wiki_issues.py:148 · its file's page

What it checks (5)

  1. assert ( made == ("3", "u3") and sent["labels"] == ["req:REQ-1"] and "clew-req: REQ-1" in sent["body"] ) not attributed
  2. assert sent["title"].startswith("REQ-1") not attributed
  3. assert made == ("4", "https://dev.azure.com/org/proj/_workitems/edit/4") not attributed
  4. assert ( patch["/fields/System.Tags"] == "req:REQ-1" and "clew-req: REQ-1" in patch["/fields/System.Description"] ) not attributed
  5. assert ado.seen[0][2]["Content-type"] == "application/json-patch+json" not attributed

What it reaches

Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.

Also reaches 1 requirement

Its run touches their code; that is reach, not proof.