Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/tests/test_imei.doctest
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2010-08-20 16:16:55 +0200
committerArthur de Jong <arthur@arthurdejong.org>2010-08-20 16:16:55 +0200
commit6bb04af37fb1dbcb719055eaaff23f7dbe3f1246 (patch)
tree28df79fd84fbb9213373beac48c18bb382ed683f /tests/test_imei.doctest
parentca08995dbf58d62c248d881d48979db92d7bb345 (diff)
add an IMEI (International Mobile Equipment Identity) module
git-svn-id: http://arthurdejong.org/svn/python-stdnum/python-stdnum@26 9dea7c4f-944c-4273-ac1a-574ede026edc
Diffstat (limited to 'tests/test_imei.doctest')
-rw-r--r--tests/test_imei.doctest65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/test_imei.doctest b/tests/test_imei.doctest
new file mode 100644
index 0000000..650d681
--- /dev/null
+++ b/tests/test_imei.doctest
@@ -0,0 +1,65 @@
+test_imei.doctest - more detailed doctests for stdnum.imei module
+
+Copyright (C) 2010 Arthur de Jong
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA
+
+
+This file contains more detailed doctests for the stdnum.imei module. It
+tries to test more corner cases and detailed functionality that is not
+really useful as module documentation.
+
+>>> from stdnum import imei
+
+
+Should be valid numbers:
+
+>>> imei.is_valid('49-015420-323751')
+True
+>>> imei.is_valid('35-209900-176148-1')
+True
+>>> imei.is_valid('35-209900-176148-23')
+True
+>>> imei.is_valid('350077-52-323751-3')
+True
+>>> imei.is_valid('354178036859789')
+True
+
+
+These are normal variations that should just work. Getting the type:
+
+>>> imei.imei_type('35686800-004141-20')
+'IMEISV'
+>>> imei.imei_type('35-417803-685978-9')
+'IMEI'
+>>> imei.imei_type('35-417803-685978-2') is None # invalid check digit
+True
+>>> imei.imei_type('3568680000414120')
+'IMEISV'
+
+
+The is_valid() method should be fairly robust against invalid junk passed:
+
+>>> imei.is_valid(None)
+False
+>>> imei.is_valid('')
+False
+>>> imei.is_valid(0)
+False
+>>> imei.is_valid(object())
+False
+>>> imei.is_valid('3abc6800-0041X1-20')
+False