Skip to content

Commit

Permalink
Append MK(X)S printers for Connect
Browse files Browse the repository at this point in the history
  • Loading branch information
ondratu committed Aug 28, 2024
1 parent 8c030f1 commit ff87855
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
7 changes: 5 additions & 2 deletions prusaerrors/connect/codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from prusaerrors.shared.codes import unique_codes, Codes, Printer, Code, Category


BUDDY = ['MINI', 'MK4', 'IX', 'XL', 'MK35', 'MK39']
BUDDY = ['MINI', 'MK4', 'IX', 'XL', 'MK3.5',
'MK4S', 'MK3.9', 'MK3.9S', 'MK3.5S']


class PrinterCode(Code):
Expand Down Expand Up @@ -73,7 +74,9 @@ def decor(cls):
if code_parts["printer"] == 'XX':
if printers := entry.get("printers"):
if 'MK4' in printers:
printers.append('MK39')
printers.extend(('MK4S', 'MK3.9', 'MK3.9S'))
elif 'MK3.5' in printers:
printers.append('MK3.5S')
else: # if no printers specified code is valid for all buddy
printers = BUDDY

Expand Down
5 changes: 4 additions & 1 deletion prusaerrors/shared/codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ class Printer(IntEnum):
MK4 = 0x000D
IX = 0x0010
XL = 0x0011
MK35 = 0x0017
MK39 = 0x0015
MK35 = 0x0017
MK4S = 0x001A
MK39S = 0x001B
MK35S = 0x001C
M1 = 0x001D


Expand Down
54 changes: 52 additions & 2 deletions tests/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,65 @@

class TestErrors(unittest.TestCase):

def test_code_lookup(self):
def test_XL(self):
code = PrinterCodes.get("17505")
assert code.printer == Printer(17)
assert code.printer == Printer.XL
assert code.category == Category(5)
assert code.error == 5
assert code.title
assert code.message
assert code.id

def test_MK4(self):
code = PrinterCodes.get("13505")
assert code.printer == Printer.MK4
assert code.category == Category(5)
assert code.error == 5
assert code.title
assert code.message
assert code.id

def test_MK4S(self):
code = PrinterCodes.get("26505")
assert code.printer == Printer.MK4S
assert code.category == Category(5)
assert code.error == 5
assert code.title
assert code.message
assert code.id

def test_MK39(self):
code = PrinterCodes.get("21505")
assert code.printer == Printer.MK39
assert code.category == Category(5)
assert code.error == 5
assert code.title
assert code.message
assert code.id

def test_MK35(self):
code = PrinterCodes.get("23701")
assert code.printer == Printer.MK35
assert code.category == Category(7)
assert code.error == 1
assert code.title
assert code.message
assert code.id

def test_MK35S(self):
code = PrinterCodes.get("28701")
assert code.printer == Printer.MK35S
assert code.category == Category(7)
assert code.error == 1
assert code.title
assert code.message
assert code.id

def test_no_MK35S(self):
"""MK35S doesn't have puppies."""
code = PrinterCodes.get("28512")
assert code is None

def test_unknown_code(self):
code = PrinterCodes.get("unknown_code")
assert code is None
Expand Down

0 comments on commit ff87855

Please sign in to comment.