diff options
author | Filipp Lepalaan <filipp@mac.com> | 2015-10-09 10:39:05 +0300 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2015-10-09 10:39:05 +0300 |
commit | d278969719a9fd089fe39eb74c31fcfe1ddac4fd (patch) | |
tree | f14c4f24e0ed684e394a4bfeca4e7e63f38ffc74 | |
parent | c6c71309b48062ef9f0315b0d2fe69d6b65fe301 (diff) | |
download | py-gsxws-d278969719a9fd089fe39eb74c31fcfe1ddac4fd.tar.gz py-gsxws-d278969719a9fd089fe39eb74c31fcfe1ddac4fd.tar.bz2 py-gsxws-d278969719a9fd089fe39eb74c31fcfe1ddac4fd.zip |
Return diagnostic suites as two-tuple
-rw-r--r-- | gsxws/comptia.py | 11 | ||||
-rw-r--r-- | gsxws/core.py | 4 | ||||
-rw-r--r-- | gsxws/diagnostics.py | 25 | ||||
-rw-r--r-- | gsxws/repairs.py | 6 | ||||
-rw-r--r-- | tests/test_gsxws.py | 4 |
5 files changed, 35 insertions, 15 deletions
diff --git a/gsxws/comptia.py b/gsxws/comptia.py index 4884c2e..a12c046 100644 --- a/gsxws/comptia.py +++ b/gsxws/comptia.py @@ -51,11 +51,11 @@ class CompTIA(GsxObject): The CompTIA Codes Lookup API retrieves a list of CompTIA groups and modifiers. Context: - The CompTIA Codes (Symptom Codes) are the current available selections based on - the component group code for parts. + The CompTIA Codes (Symptom Codes) are the current available selections + based on the component group code for parts. The API can be executed only after valid Authentication. - Users can use the API at any point to retrieve the CompTIA code and modifier details, - in order to create or update repairs. + Users can use the API at any point to retrieve the CompTIA code and + modifier details, in order to create or update repairs. >>> CompTIA().fetch() # doctest: +ELLIPSIS {u'A': {'989': u'Remote Inoperable', ... @@ -63,7 +63,8 @@ class CompTIA(GsxObject): if self._cache.get('comptia'): return self._cache.get('comptia') - doc = self._submit("ComptiaCodeLookupRequest", "ComptiaCodeLookup", "comptiaInfo", raw=True) + doc = self._submit("ComptiaCodeLookupRequest", "ComptiaCodeLookup", + "comptiaInfo", raw=True) root = doc.find('.//comptiaInfo') for el in root.findall(".//comptiaGroup"): diff --git a/gsxws/core.py b/gsxws/core.py index 0beed92..4c3c4a4 100644 --- a/gsxws/core.py +++ b/gsxws/core.py @@ -320,6 +320,10 @@ class GsxRequest(object): # @hack FetchDiagnosticDetails doesn't follow the naming conventions if method.endswith('FetchDiagnosticDetails'): request_name = 'FetchDiagnosticDetailsRequestData' + + # @hack FetchDiagnosticSuites doesn't follow the naming conventions + if method.endswith('FetchDiagnosticSuites'): + request_name = 'FetchDiagnosticSuitesRequestData' request = ET.SubElement(root, request_name) request.append(GSX_SESSION) diff --git a/gsxws/diagnostics.py b/gsxws/diagnostics.py index d6e9c6a..79a7975 100644 --- a/gsxws/diagnostics.py +++ b/gsxws/diagnostics.py @@ -8,10 +8,11 @@ class Diagnostics(GsxObject): def initiate(self): """ - The Initiate iOS Diagnostic API allows users to initiate Diagnostic Request for iOS Device. + The Initiate iOS Diagnostic API allows users to initiate + Diagnostic Request for iOS Device. Then it sends the diagnostic URL (diags://<Ticket Number >) as an email or SMS - to the email address or phone number based on the information provided in the request. - The ticket is generated within GSX system. + to the email address or phone number based on the information provided + in the request. The ticket is generated within GSX system. """ self._submit("initiateRequestData", "InitiateIOSDiagnostic", "initiateResponseData") @@ -21,8 +22,8 @@ class Diagnostics(GsxObject): def fetch(self): """ The Fetch Diagnostic Details API allows users to fetch diagnostic test details - of all Devices. This API will retrieve diagnostic tests performed on the device - as well as profile and report data for the tests. + of all Devices. This API will retrieve diagnostic tests performed on + the device as well as profile and report data for the tests. >>> Diagnostics(diagnosticEventNumber='12942008007242012052919').fetch() """ @@ -32,12 +33,17 @@ class Diagnostics(GsxObject): def fetch_suites(self): """ - The Fetch Diagnostic Suite API allows user to fetch associated Diagnostic Suite IDs - for a given serial number from Apple Diagnostic Repository irrespective of Service Account. + The Fetch Diagnostic Suite API allows user to fetch associated + Diagnostic Suite IDs for a given serial number + from Apple Diagnostic Repository irrespective of Service Account. """ + suites = [] self._submit("diagnosticSuitesRequestData", "FetchDiagnosticSuites", "diagnosticSuitesResponseData") - return self._req.objects + for i in self._req.objects.diagnosticSuiteDetails: + suites.append((i.suiteId, i.suiteName,)) + + return suites def fetch_dc_url(self): """ @@ -62,7 +68,8 @@ class Diagnostics(GsxObject): def run(self): """ The Run Diagnostic Test API allows users to run a specific or - all the diagnostic tests on a device. User has to first invoke Fetch Diagnostic Suite API + all the diagnostic tests on a device. + User has to first invoke Fetch Diagnostic Suite API to fetch associated suite ID's for given serial number. """ self._submit("diagnosticTestRequestData", "RunDiagnosticTest", diff --git a/gsxws/repairs.py b/gsxws/repairs.py index 0d877a1..989c94d 100644 --- a/gsxws/repairs.py +++ b/gsxws/repairs.py @@ -274,12 +274,16 @@ class CarryInRepair(Repair): """ self._namespace = "emea:" result = self._submit("repairData", "CreateCarryIn", "repairConfirmation") + + if hasattr(result, 'repairConfirmation'): + messages = result.repairConfirmation.messages + raise GsxError(messages) + self.dispatchId = result.confirmationNumber return result def update(self, newdata): """ - Description The Update Carry-In Repair API allows the service providers to update the existing open carry-in repairs. This API assists in addition/deletion of parts and addition of notes diff --git a/tests/test_gsxws.py b/tests/test_gsxws.py index b2ada9f..22372ab 100644 --- a/tests/test_gsxws.py +++ b/tests/test_gsxws.py @@ -67,6 +67,10 @@ class DiagnosticsTestCase(TestCase): for r in res.diagnosticProfileData.report.reportData.key: self.assertUnicodeOrInt(r.value) + def test_fetch_suites(self): + suites = self.diag.fetch_suites() + self.assertIsInstance(suites[0][0], int) + def test_fetch_dc_url(self): url = self.diag.fetch_dc_url() self.assertRegexpMatches(url, r'^https://') |