From 053a1514b69e65ccf868e0b99d082c9cd7cef827 Mon Sep 17 00:00:00 2001 From: nvmbrasserie Date: Wed, 20 Nov 2024 16:39:42 +0100 Subject: [PATCH] test added --- tests/test_ru_ogrn.doctest | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/test_ru_ogrn.doctest diff --git a/tests/test_ru_ogrn.doctest b/tests/test_ru_ogrn.doctest new file mode 100644 index 00000000..00f0bdd9 --- /dev/null +++ b/tests/test_ru_ogrn.doctest @@ -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'