Mikhail Korobov avatar Mikhail Korobov committed 45c44de

balance is now float; is_phone_valid no longer raises an exception if phone format is invalid; bump version.

Comments (0)

Files changed (3)

         Returns current balance.
-        return self._http_get(self.BALANCE_URL, {}).decode('utf8')
+        return float(self._http_get(self.BALANCE_URL, {}).decode('utf8'))
     def is_valid_phone(self, phone):
             code = int(res)
+            if code == -9: # invalid phone format
+                return False
             raise ImobisError(code)
         except ValueError:
             raise ImobisError(res)
     def test_balance(self, urlopen):
         urlopen.return_value.read.return_value = b'100'
-        self.assertEqual(self.im.get_balance(), '100')
+        self.assertEqual(self.im.get_balance(), 100.0)
     def test_is_valid_phone(self, urlopen):
         urlopen.return_value.read.return_value = b'OK'
+    def test_is_valid_phone_error_format(self, urlopen):
+        urlopen.return_value.read.return_value = b'-9'
+        self.assertFalse(self.im.is_valid_phone('1234234234'))
     def test_is_valid_phone_error(self, urlopen):
         urlopen.return_value.read.return_value = b'-10'
     # python3 doesn't need this
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.