Skip to content

Commit 53ea91f

Browse files
committed
Fixed vignVerify and documentation
1 parent d84b192 commit 53ea91f

File tree

4 files changed

+45
-25
lines changed

4 files changed

+45
-25
lines changed

LDT.py

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -202,39 +202,51 @@ def text_back(postReturn):
202202
log.info(f"\tComparison Value:\t{messDat.get('comparison_value')}\n")
203203

204204

205-
206-
## Check output message for known-good metadata pairs...
205+
207206
def response_vign_verify(apiReturn, staffID):
208-
log.debug("\tRunning 'response_vign_verify..")
207+
log.debug("\tRunning 'response_vign_verify'...")
209208
validKeys = vignAccPairs.get(staffID)
210-
chosenKeys = {
211-
"acceptable_by": apiReturn["selected_candidate"].get("acceptable_by").lower(),
212-
"measure": apiReturn["selected_candidate"].get("measure")
213-
}
209+
selectedCPs = apiReturn["selected_candidate"].get("acceptable_by")
210+
selectedMeasure = apiReturn["selected_candidate"].get("measure")
211+
matchingCP = False
212+
matchingMeasure = False
213+
formattedValidKeys = [ # Make print statement pretty for valid pairs
214+
f"\t{item['acceptable_by'].title()}\t\t{item['measure']}" for item in validKeys
215+
]
214216

215-
# Make validKeys into a more readable format for printing
216-
formattedValidKeys = [f"\t{item['acceptable_by'].title()}\t\t{item['measure']}" for item in validKeys]
217+
if not selectedCPs or not selectedMeasure:
218+
log.warning("Selected candidate is missing 'acceptable_by' or 'measure'.")
219+
return
217220

218-
# Check keys and print results
219-
if chosenKeys in validKeys:
220-
log.info(f"VIGNETTE VERIFICATION:\tPASS\nValid pairs:")
221-
for formattedValidKey in formattedValidKeys:
222-
log.info(f"\t{formattedValidKey}")
223-
log.info(f"API returned pair:\n\t\t{chosenKeys['acceptable_by'].title()}\t\t{chosenKeys['measure']}\n")
221+
# Check if any of the selected CPs match the valid CPs
222+
for selectedCP in selectedCPs:
223+
selectedCP = selectedCP.lower()
224+
for validKey in validKeys:
225+
if (
226+
selectedCP == validKey["acceptable_by"].lower()
227+
and selectedMeasure == validKey["measure"]
228+
):
229+
matchingCP = selectedCP
230+
matchingMeasure = selectedMeasure
231+
break
232+
233+
if matchingCP and matchingMeasure:
234+
log.info("\nVIGNETTE VERIFICATION:\t\tPASS")
235+
log.info(f"Matched pair:\t\t{matchingCP.title()}\t\t{matchingMeasure}")
224236
else:
225-
log.info(f"VIGNETTE VERIFICATION:\tFAIL\nExpected valid pairs:")
237+
log.info("\nVIGNETTE VERIFICATION:\t\tFAIL")
226238
for formattedValidKey in formattedValidKeys:
227-
log.info(f"\t{formattedValidKey}")
228-
log.info(f"API returned pair:\n\t\t{chosenKeys['acceptable_by'].title()}\t\t{chosenKeys['measure']}\n")
229-
239+
log.info(f"Expected pairs:\t{formattedValidKey}")
240+
log.info(f"API returned pair:\n\t\t{selectedCPs}\t\t{selectedMeasure}")
241+
log.info(f"Text:\t{apiReturn['Message'].get('text_message')[:55]}\n")
230242

231243

232244

233245
## Check output message against requested Causal Pathway...
234246
def response_CP_verify(apiReturn, causalPathway):
235247
log.debug("\tRunning 'response_CP_verify'...")
236248
try:
237-
assert causalPathway is not None and isinstance(causalPathway, str), "Causal Pathway passed to verification function is not a valid string"
249+
assert causalPathway is not None and isinstance(causalPathway, str), "Causal Pathway passed is not a valid string"
238250
assert apiReturn["selected_candidate"].get("acceptable_by") is not None, "No 'Acceptable By' keys returned by API"
239251
except AssertionError as e:
240252
log.critical("Assertion error: " + str(e))
@@ -255,6 +267,7 @@ def response_CP_verify(apiReturn, causalPathway):
255267
log.info(f"No matching causal pathway found for '{causalPathway}'.\n")
256268

257269

270+
258271
## Save PFP API responses for manual review...
259272
def save_API_resp(postReturn, requestID):
260273
log.debug("\tRunning 'save_API_resp'...")

LDT_Addendum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Version of the Leakdown Tester
2-
ldtVersion = "1.0.1-beta"
2+
ldtVersion = "1.0.1"
33

44

55
## JSON content 'header' wrapper section for in-situ payload compilation:

changelog.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
# Leakdown Tester Changelog
22
## Version 1.0.1
3-
*Released TBD*
3+
*Released 9/6/23*
44

55
**Patch:** Fixed V&V functions with new structure of 'acceptable_by' key
66
- Restored causal pathway verification with `--cpVerify`
77
- Iterates through acceptable_by pathways and searches for a match
8-
- *Planned*: Verify against candidate message template links to restore specificity verification
9-
-
8+
9+
- Restored vignette verification with `--vignVerify`
10+
- Searches for matches in message template keys, which correlate 1:1 to causal pathways
11+
- Searches for matches in measures chosen to create feedback from
12+
13+
- *Planned:* Verify selected measures by comparing message templates
14+
- Currently unnecessary, but may add functionality for further refinement of testing in the future
15+
1016
**Improvement:** *(Documentation only)* Retroactively changed version numbers from V1 to V0 for pre-release versions
1117
- Updated in GitHub
1218
- Changelog updated
1319

1420
## Version 1.0.0
1521
*Released 8/31/2023*
1622

17-
**Versioned:** All releases > 1.6.0 will 'live' in a new, independent repository
23+
**Versioned:** All releases > 0.6.0 will 'live' in a new, independent repository
1824
- Repo is at [Display-lab/Leakdown-Tester](https://github.com/Display-Lab/Leakdown-Tester)
1925
- Liscensed with GNU General Public Liscense 3.0 (share-alike)
2026
- Earlier versions can be found in the caches of the [precision-feedback-pipeline](https://github.com/Display-Lab/precision-feedback-pipeline) repo

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Format for the below argument specifications:
5858
- Default: None
5959
- SetTrue: Sends performance data JSON payload from addendum file.
6060
+ Name references the Postman API which is a solid API testing standalone service with extensive features. The major advantage for PFP testing is the ability to rapidly configure and test individual POST requests, which postwoman can also accomplish with the proper IDE setup.
61+
6162
`--useGit` `string`
6263
- Default: None
6364
- Connects to an input message source at GitHub.com to send the target API.

0 commit comments

Comments
 (0)