diff --git a/cl_sii/libs/csv_utils.py b/cl_sii/libs/csv_utils.py index c3a910d9..f8fa0a47 100644 --- a/cl_sii/libs/csv_utils.py +++ b/cl_sii/libs/csv_utils.py @@ -22,14 +22,7 @@ def create_csv_dict_reader( :return: a CSV DictReader """ - # note: mypy wrongly complains: it does not accept 'fieldnames' to be None but that value - # is completely acceptable, and it even is the default! - # > error: Argument "fieldnames" to "DictReader" has incompatible type "None"; expected - # > "Sequence[str]" - # note: mypy wrongly complains: - # > Argument "dialect" to "DictReader" has incompatible type "Type[Dialect]"; - # > expected "Union[str, Dialect]" - csv_reader = csv.DictReader( # type: ignore + csv_reader = csv.DictReader( text_stream, fieldnames=None, # the values of the first row will be used as the fieldnames restkey=row_dict_extra_fields_key, @@ -38,6 +31,10 @@ def create_csv_dict_reader( if expected_fields_strict: if expected_field_names: + if csv_reader.fieldnames is None: + raise Exception( + "Programming error: when a 'csv.DictReader' instance is created with" + "'fieldnames=None', the attribute will be set to the values of the first row.") if tuple(csv_reader.fieldnames) != expected_field_names: raise ValueError( "CSV file field names do not match those expected, or their order.", diff --git a/requirements/base.txt b/requirements/base.txt index 231da77b..b8e1b349 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -2,9 +2,9 @@ # note: it is mandatory to register all dependencies of the required packages. # Required packages: -cryptography==2.8 +cryptography==2.9 defusedxml==0.6.0 -jsonschema==3.1.1 +jsonschema==3.2.0 lxml==4.5.0 marshmallow==2.19.5 pyOpenSSL==18.0.0 @@ -17,12 +17,12 @@ signxml==2.6.0 # - pycparser # - six # - jsonschema -# - setuptools -# - six # - attrs -# - importlib-metadata +# - importlib-metadata (python_version<'3.8') # - zipp # - pyrsistent +# - setuptools +# - six # - signxml: # - asn1crypto # - certifi @@ -35,13 +35,13 @@ signxml==2.6.0 # - six asn1crypto==1.3.0 attrs==19.3.0 -certifi==2019.11.28 -cffi==1.13.2 +certifi==2020.4.5.1 +cffi==1.14.0 eight==0.4.2 future==0.16.0 -importlib-metadata==0.23 -pycparser==2.19 -pyrsistent==0.15.7 +importlib-metadata==1.6.0; python_version<'3.8' +pycparser==2.20 +pyrsistent==0.16.0 # setuptools six==1.14.0 -zipp==2.1.0 +zipp==3.1.0 diff --git a/requirements/release.txt b/requirements/release.txt index 9a0d0dbe..84a17473 100644 --- a/requirements/release.txt +++ b/requirements/release.txt @@ -4,7 +4,7 @@ # Required packages: bumpversion==0.5.3 -setuptools==45.1.0 +setuptools==46.1.3 twine==3.1.1 wheel==0.34.2 @@ -21,9 +21,11 @@ wheel==0.34.2 # - pkginfo # - readme-renderer: # - bleach +# - six # - webencodings # - docutils # - Pygments +# - six # - requests: # - certifi # - chardet @@ -38,16 +40,17 @@ wheel==0.34.2 # cryptography # docutils # idna -importlib-metadata==0.23 +importlib-metadata==1.6.0 # jeepney -keyring==21.1.0 +keyring==21.2.0 pkginfo==1.5.0.1 # Pygments -readme-renderer==24.0 -requests==2.22.0 +readme-renderer==25.0 +requests==2.23.0 requests-toolbelt==0.9.1 # SecretStorage -tqdm==4.42.0 +# six +tqdm==4.45.0 # urllib3 # webencodings # zipp diff --git a/requirements/test.txt b/requirements/test.txt index b26df23b..afdfb56c 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -3,11 +3,11 @@ -r extras.txt # Required packages: -codecov==2.0.15 +codecov==2.0.22 coverage==4.5.3 -flake8==3.7.7 -mypy==0.711 -tox==3.13.1 +flake8==3.7.9 +mypy==0.770 +tox==3.14.6 # Packages dependencies: # - codecov: @@ -25,6 +25,7 @@ tox==3.13.1 # - mypy: # - mypy-extensions # - typed-ast +# - typing-extensions # - tox: # - filelock # - importlib-metadata @@ -33,25 +34,35 @@ tox==3.13.1 # - pyparsing # - pluggy # - py +# - six # - toml # - virtualenv +# - appdirs +# - distlib +# - filelock +# - importlib-metadata +# - six +# appdirs # certifi # chardet +# distlib entrypoints==0.3 filelock==3.0.12 # idna -importlib-metadata==0.23 +importlib-metadata==1.6.0 mccabe==0.6.1 mypy-extensions==0.4.3 -packaging==20.1 +packaging==20.3 pluggy==0.13.1 py==1.8.1 pycodestyle==2.5.0 pyflakes==2.1.1 # pyparsing # requests +# six toml==0.10.0 typed-ast==1.4.1 +typing-extensions==3.7.4.2 # urllib3 -virtualenv==16.7.9 +virtualenv==20.0.16 # zipp diff --git a/tests/test_libs_crypto_utils.py b/tests/test_libs_crypto_utils.py index 2ed1ac72..95fb7f05 100644 --- a/tests/test_libs_crypto_utils.py +++ b/tests/test_libs_crypto_utils.py @@ -80,11 +80,6 @@ def test_load_der_x509_cert_ok(self) -> None: ####################################################################### self.assertEqual(len(x509_cert.issuer.rdns), 3) - self.assertEqual( - x509_cert.issuer.rfc4514_string(), - 'C=US,' - 'O=Google Trust Services,' - 'CN=Google Internet Authority G3') self.assertEqual( x509_cert.issuer.get_attributes_for_oid(oid.NameOID.COUNTRY_NAME)[0].value, 'US') @@ -100,13 +95,6 @@ def test_load_der_x509_cert_ok(self) -> None: ####################################################################### self.assertEqual(len(x509_cert.subject.rdns), 5) - self.assertEqual( - x509_cert.subject.rfc4514_string(), - 'C=US,' - 'ST=California,' - 'L=Mountain View,' - 'O=Google LLC,' - 'CN=*.google.com') self.assertEqual( x509_cert.subject.get_attributes_for_oid(oid.NameOID.COUNTRY_NAME)[0].value, 'US') @@ -257,15 +245,6 @@ def test_load_der_x509_cert_ok_cert_real_dte_1(self) -> None: ####################################################################### self.assertEqual(len(x509_cert.issuer.rdns), 7) - self.assertEqual( - x509_cert.issuer.rfc4514_string(), - 'C=CL,ST=Region Metropolitana,' - 'L=Santiago,' - 'O=E-CERTCHILE,' - 'OU=Autoridad Certificadora,' - 'CN=E-CERTCHILE CA FIRMA ELECTRONICA SIMPLE,' - '1.2.840.113549.1.9.1=sclientes@e-certchile.cl') - self.assertEqual( x509_cert.issuer.get_attributes_for_oid(oid.NameOID.COUNTRY_NAME)[0].value, 'CL') @@ -293,15 +272,6 @@ def test_load_der_x509_cert_ok_cert_real_dte_1(self) -> None: ####################################################################### self.assertEqual(len(x509_cert.subject.rdns), 7) - self.assertEqual( - x509_cert.subject.rfc4514_string(), - 'C=CL,' - 'ST=VALPARAISO\\ ,' - 'L=Quillota,' - 'O=Servicios Bonilla y Lopez y Cia. Ltda.,' - 'OU=Ingeniería y Construcción,' - 'CN=Ramon humberto Lopez Jara,' - '1.2.840.113549.1.9.1=enaconltda@gmail.com') self.assertEqual( x509_cert.subject.get_attributes_for_oid(oid.NameOID.COUNTRY_NAME)[0].value, 'CL') @@ -482,14 +452,6 @@ def test_load_der_x509_cert_ok_cert_real_dte_3(self) -> None: ####################################################################### self.assertEqual(len(x509_cert.issuer.rdns), 5) - self.assertEqual( - x509_cert.issuer.rfc4514_string(), - 'C=CL,' - 'O=E-Sign S.A.,' - 'OU=Terms of use at www.esign-la.com/acuerdoterceros,' - 'CN=E-Sign Class 2 Firma Tributaria CA,' - '1.2.840.113549.1.9.1=e-sign@esign-la.com') - self.assertEqual( x509_cert.issuer.get_attributes_for_oid(oid.NameOID.COUNTRY_NAME)[0].value, 'CL') @@ -511,13 +473,6 @@ def test_load_der_x509_cert_ok_cert_real_dte_3(self) -> None: ####################################################################### self.assertEqual(len(x509_cert.subject.rdns), 5) - self.assertEqual( - x509_cert.subject.rfc4514_string(), - 'C=CL,' - 'O=E-Sign S.A.,' - 'OU=Terms of use at www.esign-la.com/acuerdoterceros,' - 'CN=Jorge Enrique Cabello Ortiz,' - '1.2.840.113549.1.9.1=jcabello@nic.cl') self.assertEqual( x509_cert.subject.get_attributes_for_oid(oid.NameOID.COUNTRY_NAME)[0].value, 'CL') @@ -683,14 +638,6 @@ def test_load_der_x509_cert_ok_prueba_sii(self) -> None: ####################################################################### self.assertEqual(len(x509_cert.issuer.rdns), 6) - self.assertEqual( - x509_cert.issuer.rfc4514_string(), - 'ST=Region Metropolitana,' - 'L=Santiago,' - 'CN=E-Certchile CA Intermedia,' - 'OU=Empresa Nacional de Certificacion Electronica,' - 'O=E-CERTCHILE,' - 'C=CL') self.assertEqual( x509_cert.issuer.get_attributes_for_oid(oid.NameOID.COUNTRY_NAME)[0].value, 'CL') @@ -715,15 +662,6 @@ def test_load_der_x509_cert_ok_prueba_sii(self) -> None: ####################################################################### self.assertEqual(len(x509_cert.subject.rdns), 7) - self.assertEqual( - x509_cert.subject.rfc4514_string(), - 'ST=Region Metropolitana,' - 'OU=Servicio de Impuestos Internos,' - 'O=Servicio de Impuestos Internos,' - 'L=Santiago,' - '1.2.840.113549.1.9.1=wgonzalez@sii.cl,' - 'CN=Wilibaldo Gonzalez Cabrera,' - 'C=CL') self.assertEqual( x509_cert.subject.get_attributes_for_oid(oid.NameOID.COUNTRY_NAME)[0].value, 'CL')