From 491d967f2e0d6fc62724746a430fe27a9421e639 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Fri, 14 Aug 2015 15:49:05 +0300 Subject: Return symptoms and issues as two-tuples --- gsxws/repairs.py | 13 ++++++++++++- tests/test_gsxws.py | 17 +++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/gsxws/repairs.py b/gsxws/repairs.py index b7716ae..d84372c 100644 --- a/gsxws/repairs.py +++ b/gsxws/repairs.py @@ -54,9 +54,20 @@ class SymptomIssue(GsxObject): _namespace = "asp:" def fetch(self): + result = [] self._submit("requestData", "ReportedSymptomIssue", "ReportedSymptomIssueResponse") - return self._req.objects.reportedSymptomIssueResponse + r = self._req.objects.reportedSymptomIssueResponse + + if r.symptoms is not None: + for s in r.symptoms: + result.append((s.reportedSymptomCode, s.reportedSymptomDesc,)) + + if r.issues is not None: + for s in r.issues: + result.append((s.reportedIssueCode, s.reportedIssueDesc,)) + + return result class CompTiaCode(GsxObject): diff --git a/tests/test_gsxws.py b/tests/test_gsxws.py index 0a8970b..bd2d8b0 100644 --- a/tests/test_gsxws.py +++ b/tests/test_gsxws.py @@ -104,10 +104,10 @@ class RepairTestCase(RemoteTestCase): _comptia.comptiaCode = ccode self.comptia = _comptia - r = repairs.SymptomIssue(serialNumber=self.sn).fetch() - self.symptom = r.symptoms[0].reportedSymptomCode - r = repairs.SymptomIssue(reportedSymptomCode=self.symptom).fetch() - self.issue = r.issues[0].reportedIssueCode + self._symptoms = repairs.SymptomIssue(serialNumber=self.sn).fetch() + self.symptom = self._symptoms[0][0] + self._issues = repairs.SymptomIssue(reportedSymptomCode=self.symptom).fetch() + self.issue = self._issues[0][0] class TestCoreFunctions(TestCase): @@ -210,10 +210,11 @@ class TestEscalationFunctions(RemoteTestCase): class TestRepairFunctions(RepairTestCase): - def test_symptom_issue(self): - from gsxws.repairs import SymptomIssue - r = SymptomIssue(serialNumber=env['GSX_SN']).fetch() - self.assertEqual(r.symptoms[0].reportedSymptomCode, 6115) + def test_symptom_code(self): + self.assertEqual(self._symptoms[0][0], 'PD17A') + + def test_issue_code(self): + self.assertEqual(self._issues[0][0], 'PD17-01') def test_create_carryin(self): rep = repairs.CarryInRepair() -- cgit v1.2.3