From d1ea36c16454c15e9792c33e52d3f548936402ff Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Wed, 17 Jul 2013 13:06:42 +0300 Subject: Fixed GSX element matching, added more tests --- tests/fixtures/ios_activation.xml | 41 +++++++++++++++++ tests/fixtures/onsite_dispatch_detail.xml | 76 +++++++++++++++++++++++++++++++ tests/fixtures/parts_lookup.xml | 47 +++++++++++++++++++ tests/test_gsxws.py | 67 ++++++++++++++++++++++++--- 4 files changed, 225 insertions(+), 6 deletions(-) create mode 100644 tests/fixtures/ios_activation.xml create mode 100644 tests/fixtures/onsite_dispatch_detail.xml create mode 100644 tests/fixtures/parts_lookup.xml (limited to 'tests') diff --git a/tests/fixtures/ios_activation.xml b/tests/fixtures/ios_activation.xml new file mode 100644 index 0000000..7b18d6b --- /dev/null +++ b/tests/fixtures/ios_activation.xml @@ -0,0 +1,41 @@ + + + + + + 1e62913276430159203556d + + 2J141331A4S + 010648001526755 + + 897010266884541917 + 01/16/12 + 01/18/12 + + true + true + 01/18/12 + 4.2.1 + 1 + + Unassigned factory default - Apple carriers only. + SIM Swap triggers rebricking. + 152 + Russia MegaFon. + 1 + + Unassigned factory default - Apple carriers only. + SIM Swap triggers rebricking. + + + iPhone4 16GB BLACKE + + + + + diff --git a/tests/fixtures/onsite_dispatch_detail.xml b/tests/fixtures/onsite_dispatch_detail.xml new file mode 100644 index 0000000..4025dd0 --- /dev/null +++ b/tests/fixtures/onsite_dispatch_detail.xml @@ -0,0 +1,76 @@ + + + + + + 8a6231310158348248 + + G101260028 + YM1432NELFB + + 0000511590 + 0000022296 + AppleCare Protection Plan + iMac (Summer 2001) + iMac 500MHz/128M/20G/CD-RW/RUltra/56K/FW + 503017 + Customer Reported Symptom: + System crashes after logging in. + Sold-To Diagnosis: + System crashes after logging in. + Notes: + TR01 + + 2323 E. Mountain Gate Pass2323 E. Mountain Gate Pass + US + 85024 + Madera + PHOENIX + AZ + 005 + Christopher + Howard + PVUSD + 480-650-3876 + + + 2323 E. Mountain Gate Pass2323 E. Mountain Gate Pass + US + 85024 + Madera + PHOENIX + AZ + 005 + Hogan + Patrick + PVUSD + 602-867-5252 + + + 8545 N BLACK CANYON HWY + United States + 85021 + Madera + PHOENIX + AZ + 005 + CDS GROUP INC + + 602-242-5101 + + + 661-2447 + Board, Logic, 500 MHz + AppleCare Protection Plan + 581 + B + Known Bad Board + Y + 123456789 + + + + + + + diff --git a/tests/fixtures/parts_lookup.xml b/tests/fixtures/parts_lookup.xml new file mode 100644 index 0000000..c1ffcb6 --- /dev/null +++ b/tests/fixtures/parts_lookup.xml @@ -0,0 +1,47 @@ + + + + + + AnK6lhP8j4Zw8hHYswYMGCthSKGnzy9O + + DC18,DC19,DC20,YLW,YVL + 14.4 + Y + + SVC,REMOTE + 661-4448 + Module + 17.1 + 17.1 + 5 + 661-2549 + + + 59T + 19 + Y + + Power Adapter w/Plug, Ultra-Compact, USB, iPhone/iPod-US/CAN/JPN/TWN + 661-4954 + Module + 26.1 + 3 + + + + + 19 + N + + SVC,STEREO HEADSET + 661-5028 + Module + 26.1 + 6 + 922-8629 + + + + + diff --git a/tests/test_gsxws.py b/tests/test_gsxws.py index d7feac6..089d916 100644 --- a/tests/test_gsxws.py +++ b/tests/test_gsxws.py @@ -1,21 +1,76 @@ # -*- coding: utf-8 -*- -import unittest from datetime import date +from unittest import main, TestCase from gsxws.objectify import parse -class TestWarrantyFunctions(unittest.TestCase): +class TestWarrantyFunctions(TestCase): def setUp(self): - self.wty = parse('tests/fixtures/warranty_status.xml', 'warrantyDetailInfo') + self.data = parse('tests/fixtures/warranty_status.xml', 'warrantyDetailInfo') def test_purchase_date(self): - self.assertIsInstance(self.wty.estimatedPurchaseDate.pyval, date) + self.assertIsInstance(self.data.estimatedPurchaseDate, date) def test_config_description(self): - self.assertEqual(self.wty.configDescription, 'IPHONE 4,16GB BLACK') + self.assertEqual(self.data.configDescription, 'IPHONE 4,16GB BLACK') + def test_limited_warranty(self): + self.assertTrue(self.data.limitedWarranty) + + def test_parts_covered(self): + self.assertIsInstance(self.data.partCovered, bool) + self.assertTrue(self.data.partCovered) + + +class TestActivation(TestCase): + def setUp(self): + self.data = parse('tests/fixtures/ios_activation.xml', 'activationDetailsInfo') + + def test_unlock_date(self): + self.assertIsInstance(self.data.unlockDate, date) + + def test_unlocked(self): + self.assertIs(type(self.data.unlocked), bool) + self.assertTrue(self.data.unlocked) + + +class TestPartsLookup(TestCase): + def setUp(self): + self.data = parse('tests/fixtures/parts_lookup.xml', 'PartsLookupResponse') + self.part = self.data.parts[0] + + def test_parts(self): + self.assertEqual(len(self.data.parts), 3) + + def test_exchange_price(self): + self.assertEqual(self.part.exchangePrice, 14.4) + + def test_stock_price(self): + self.assertEqual(self.part.stockPrice, 17.1) + + def test_serialized(self): + self.assertIsInstance(self.part.isSerialized, bool) + self.assertTrue(self.part.isSerialized) + + def test_description(self): + self.assertEqual(self.part.partDescription, 'SVC,REMOTE') + + +class TestOnsiteDispatchDetail(TestCase): + def setUp(self): + self.data = parse('tests/fixtures/onsite_dispatch_detail.xml', 'onsiteDispatchDetails') + + def test_details(self): + self.assertEqual(self.data.dispatchId, 'G101260028') + + def test_address(self): + self.assertEqual(self.data.primaryAddress.zipCode, 85024) + self.assertEqual(self.data.primaryAddress.firstName, 'Christopher') + + def test_orderlines(self): + self.assertIsInstance(self.data.dispatchOrderLines.isSerialized, bool) if __name__ == '__main__': - unittest.main() + main() -- cgit v1.2.3