Skip to content

Commit

Permalink
[Matrix 1000] Acknowledge the fact that the convertToProgramDump on t…
Browse files Browse the repository at this point in the history
…he Matrix 1000 is not idempotent, it actually might change the message without being incorrect given there are two different ways to express a program dump.
  • Loading branch information
christofmuc committed Oct 2, 2022
1 parent f0d37d5 commit 7e4a6cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion adaptions/Matrix1000.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,6 @@ def programs(messages):
yield {"message": patch_message, "name": 'BNK2: 16', "number": 1}

# Matrix1000 only has uppercase letters, so we need to specify a rename target name for the test
return {"program_generator": programs, "rename_name": "NEW NAME"}
# Flag for the generic tests that converting a program dump to a program dump might yield a new result, as there are two different
# ways to express a program dump and we cannot guarantee that this always is idempotent
return {"program_generator": programs, "rename_name": "NEW NAME", "not_idempotent": True}
13 changes: 9 additions & 4 deletions adaptions/test_adaptations.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ def test_convert_to_edit_buffer(adaptation, test_data: TestData):
if not hasattr(adaptation, "convertToProgramDump"):
# Not much more we can test here
return
idempotent = adaptation.convertToProgramDump(0x00, program, previous_number)
assert knobkraft.list_compare(idempotent, program)
if "not_idempotent" in test_data.test_dict:
pass
else:
idempotent = adaptation.convertToProgramDump(0x00, program, previous_number)
assert knobkraft.list_compare(idempotent, program)
program_buffer = adaptation.convertToProgramDump(0x00, edit_buffer, 11)
elif adaptation.isEditBufferDump(program):
program_buffer = adaptation.convertToProgramDump(0x00, program, 11)
Expand Down Expand Up @@ -154,7 +157,8 @@ def test_fingerprinting(adaptation, test_data: TestData):
if hasattr(adaptation, "calculateFingerprint"):
for program in test_data.programs:
md5 = adaptation.calculateFingerprint(program["message"])
if hasattr(adaptation, "isSingleProgramDump") and hasattr(adaptation, "convertToProgramDump") and adaptation.isSingleProgramDump(program["message"]):
if hasattr(adaptation, "isSingleProgramDump") and hasattr(adaptation, "convertToProgramDump") and adaptation.isSingleProgramDump(
program["message"]):
# Change program place and make sure the fingerprint didn't change
changed_position = adaptation.convertToProgramDump(0x09, program["message"], 0x21)
assert adaptation.calculateFingerprint(changed_position) == md5
Expand All @@ -175,7 +179,8 @@ def test_device_detection(adaptation, test_data: TestData):
@skip_targets("test_data")
def test_program_dump_request(adaptation, test_data: TestData):
if "program_dump_request" in test_data.test_dict:
assert knobkraft.list_compare(adaptation.createProgramDumpRequest(0x00, 0x00), knobkraft.stringToSyx(test_data.test_dict["program_dump_request"]))
assert knobkraft.list_compare(adaptation.createProgramDumpRequest(0x00, 0x00),
knobkraft.stringToSyx(test_data.test_dict["program_dump_request"]))


@skip_targets("test_data")
Expand Down

0 comments on commit 7e4a6cd

Please sign in to comment.