diff options
author | Filipp Lepalaan <f@230.to> | 2013-07-19 10:56:31 +0300 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-07-19 10:56:31 +0300 |
commit | ce8ada78e4b285f51ae83ad78990b16582588a36 (patch) | |
tree | 00bdd3126aaf3a7ad5b65e4653ea93f1bafee5d2 | |
parent | 151b3893395bae90f5795b50e27812d30403b91e (diff) | |
download | py-gsxws-ce8ada78e4b285f51ae83ad78990b16582588a36.tar.gz py-gsxws-ce8ada78e4b285f51ae83ad78990b16582588a36.tar.bz2 py-gsxws-ce8ada78e4b285f51ae83ad78990b16582588a36.zip |
Added Product.is_unlocked()
-rw-r--r-- | gsxws/objectify.py | 2 | ||||
-rw-r--r-- | gsxws/products.py | 10 | ||||
-rw-r--r-- | tests/test_gsxws.py | 4 |
3 files changed, 15 insertions, 1 deletions
diff --git a/gsxws/objectify.py b/gsxws/objectify.py index 96b7c6e..43d6426 100644 --- a/gsxws/objectify.py +++ b/gsxws/objectify.py @@ -48,7 +48,7 @@ def gsx_date(value): def gsx_boolean(value): - return value == 'Y' + return value == 'Y' or value == 'true' class GsxPriceElement(): diff --git a/gsxws/products.py b/gsxws/products.py index 8905b2b..654bef3 100644 --- a/gsxws/products.py +++ b/gsxws/products.py @@ -137,6 +137,16 @@ class Product(GsxObject): self.serialNumber = ad.serialNumber return ad + def is_unlocked(self, ad=None): + """ + Returns true if this iOS device is unlocked + """ + import re + return ad.unlocked or (re.search("Unlock", ad.nextTetherPolicyDetails) is not None) + + def is_locked(self): + return not self.is_unlocked() + if __name__ == '__main__': import sys diff --git a/tests/test_gsxws.py b/tests/test_gsxws.py index 089d916..6982542 100644 --- a/tests/test_gsxws.py +++ b/tests/test_gsxws.py @@ -35,6 +35,10 @@ class TestActivation(TestCase): self.assertIs(type(self.data.unlocked), bool) self.assertTrue(self.data.unlocked) + from gsxws.products import Product + p = Product() + self.assertTrue(p.is_unlocked(self.data)) + class TestPartsLookup(TestCase): def setUp(self): |