lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.14-6-g3a592e4

[Date Prev][Date Next] [Thread Prev][Thread Next]

python-stdnum branch master updated. 1.14-6-g3a592e4



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".

The branch, master has been updated
       via  3a592e472ffd841dcb0c77488b77489fbe1eee99 (commit)
      from  c5eb2d89ae93bf3960f50f4a6f09e6aa022250a9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=3a592e472ffd841dcb0c77488b77489fbe1eee99

commit 3a592e472ffd841dcb0c77488b77489fbe1eee99
Author: Jonas Geuens <jonasgeuens@gmail.com>
Date:   Fri Oct 2 16:18:05 2020 +0200

    Expanded validation for BE VAT numbers
    
    Specifically invalidated all-zero numbers
    
    Closes https://github.com/arthurdejong/python-stdnum/pull/240

diff --git a/stdnum/be/vat.py b/stdnum/be/vat.py
index e7bbfb9..1722022 100644
--- a/stdnum/be/vat.py
+++ b/stdnum/be/vat.py
@@ -61,7 +61,7 @@ def validate(number):
     """Check if the number is a valid VAT number. This checks the length,
     formatting and check digit."""
     number = compact(number)
-    if not isdigits(number):
+    if not isdigits(number) or int(number) <= 0:
         raise InvalidFormat()
     if len(number) != 10:
         raise InvalidLength()
diff --git a/tests/test_be_vat.doctest b/tests/test_be_vat.doctest
new file mode 100644
index 0000000..5d68441
--- /dev/null
+++ b/tests/test_be_vat.doctest
@@ -0,0 +1,37 @@
+test_be_vat.doctest - more detailed doctests for stdnum.be.vat module
+
+Copyright (C) 2020 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.be.vat module. It
+tries to test more corner cases and detailed functionality that is not
+really useful as module documentation.
+
+>>> from stdnum.be import vat
+
+
+Tests for corner cases.
+
+>>> vat.validate('BE0000000000')
+Traceback (most recent call last):
+    ...
+InvalidFormat: ...
+>>> vat.validate('000000')
+Traceback (most recent call last):
+    ...
+InvalidFormat: ...

-----------------------------------------------------------------------

Summary of changes:
 stdnum/be/vat.py                                   |  2 +-
 tests/{test_ch_ssn.doctest => test_be_vat.doctest} | 20 ++++++++++++--------
 2 files changed, 13 insertions(+), 9 deletions(-)
 copy tests/{test_ch_ssn.doctest => test_be_vat.doctest} (65%)


hooks/post-receive
-- 
python-stdnum