Skip to content

Commit

Permalink
Merge bb8312b into 4c9d97b
Browse files Browse the repository at this point in the history
  • Loading branch information
nielstron authored Sep 24, 2020
2 parents 4c9d97b + bb8312b commit 2b2a2bc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
14 changes: 9 additions & 5 deletions pysyncthru/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,19 @@ def toner_status(self, filter_supported: bool = True) -> Dict[str, Any]:
def input_tray_status(self, filter_supported: bool = True) -> Dict[int, Any]:
"""Return the state of all input trays."""
tray_status = {}
for i in range(1, 5):
for tray in (
*("{}_{}".format(SyncThru.TRAY, i) for i in range(1, 6)),
"mp", # TODO what does mp stand for?
"manual",
):
try:
tray_stat = self.data.get("{}{}".format(SyncThru.TRAY, i), {})
if filter_supported and tray_stat.get("opt", 0) == 0:
tray_stat = self.data.get(tray.replace("_", ""), {})
if filter_supported and tray_stat.get("opt", 0) != 1:
continue
else:
tray_status[i] = tray_stat
tray_status[tray] = tray_stat
except (KeyError, AttributeError):
tray_status[i] = {}
tray_status[tray] = {}
return tray_status

def output_tray_status(self) -> Dict[int, Dict[str, str]]:
Expand Down
37 changes: 32 additions & 5 deletions pysyncthru/tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_input_tray_filter(self):
self.assertEqual(
self.syncthru.input_tray_status(True),
{
1: {
"tray_1": {
"capa": 150,
"newError": "",
"opt": 1,
Expand All @@ -108,7 +108,7 @@ def test_input_tray_no_filter(self):
self.assertEqual(
self.syncthru.input_tray_status(False),
{
1: {
"tray_1": {
"capa": 150,
"newError": "",
"opt": 1,
Expand All @@ -117,7 +117,7 @@ def test_input_tray_no_filter(self):
"paper_type1": 2,
"paper_type2": 0,
},
2: {
"tray_2": {
"capa": 0,
"newError": "",
"opt": 0,
Expand All @@ -126,7 +126,7 @@ def test_input_tray_no_filter(self):
"paper_type1": 2,
"paper_type2": 0,
},
3: {
"tray_3": {
"capa": 0,
"newError": "",
"opt": 0,
Expand All @@ -135,7 +135,7 @@ def test_input_tray_no_filter(self):
"paper_type1": 2,
"paper_type2": 0,
},
4: {
"tray_4": {
"capa": 0,
"newError": "",
"opt": 0,
Expand All @@ -144,6 +144,33 @@ def test_input_tray_no_filter(self):
"paper_type1": 2,
"paper_type2": 0,
},
"tray_5": {
"opt": 0,
"paper_size1": 0,
"paper_size2": 0,
"paper_type1": 0,
"paper_type2": 0,
"capa": 0,
"newError": "0",
},
"mp": {
"opt": 0,
"paper_size1": 0,
"paper_size2": 0,
"paper_type1": 2,
"paper_type2": 0,
"capa": 0,
"newError": "",
},
"manual": {
"opt": 0,
"paper_size1": 0,
"paper_size2": 0,
"paper_type1": 2,
"paper_type2": 0,
"capa": 0,
"newError": "",
},
},
)

Expand Down

0 comments on commit 2b2a2bc

Please sign in to comment.