Skip to content

Commit

Permalink
test added
Browse files Browse the repository at this point in the history
  • Loading branch information
nvmbrasserie committed Nov 20, 2024
1 parent 3744f80 commit 053a151
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions tests/test_ru_ogrn.doctest
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
test_ogrn.doctest - more detailed doctests for the stdnum.ogrn module

Copyright (C) 2010-2024 Arthur de Jong and others

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.ru.ogrn module.

These tests validate the format, normalization, and validity of various
OGRN numbers, ensuring they conform to expected behavior.

>>> from stdnum.ru import ogrn
>>> from stdnum.exceptions import *

This is a list of OGRNs that should all be valid numbers:

>>> valid_numbers = [
... "1027739552642", "1137847171846", "1159102022738",
... "1022600000092", "1022500001930", "1022500001061",
... "1022500000566", "1022700000685", "1022500001325",
... "1027100000311", "1022500000786", "1024100000121",
... "1022400007508", "1022400000160", "1022400010005",
... "1022300001811", "1020500003919", "1022300003703",
... "1022300000502", "1022200531484", "1022200525819"
... ]
>>> all(ogrn.is_valid(x) for x in valid_numbers)
True

These are some numbers that should be invalid:

>>> invalid_numbers = [
... "1027739552", "", "1027739",
... "11677", "315774600002662123"
... ]
>>> all(not ogrn.is_valid(x) for x in invalid_numbers)
True

Testing normalization of OGRN strings:

>>> ogrn.normalize("1027739552642")
'1027739552642'
>>> ogrn.normalize("OGRN 1027739552642")
'1027739552642'
>>> ogrn.normalize("102773955")
>>> ogrn.normalize("10277395587984375943")

Ensure OGRN can be formatted as expected:

>>> ogrn.format("1027739552642")
'1027739552642'

0 comments on commit 053a151

Please sign in to comment.