Skip to content

Commit

Permalink
Merge pull request #67 from fyndata/develop
Browse files Browse the repository at this point in the history
Release v0.7.1
  • Loading branch information
glarrain committed Jun 20, 2019
2 parents bcf3f95 + 0fa4b40 commit b33ac46
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.0
current_version = 0.7.1
commit = True
tag = True

Expand Down
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
History
-------

0.7.1 (2019-06-20)
+++++++++++++++++++++++

* (PR #66, 2019-06-20) rcv.parse_csv: detect invalid value of "razon social"

0.7.0 (2019-06-13)
+++++++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion cl_sii/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"""


__version__ = '0.7.0'
__version__ = '0.7.1'
26 changes: 26 additions & 0 deletions cl_sii/rcv/parse_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import marshmallow.fields
import marshmallow.validate

import cl_sii.dte.data_models
from cl_sii.base.constants import SII_OFFICIAL_TZ
from cl_sii.extras import mm_fields
from cl_sii.libs import csv_utils
Expand Down Expand Up @@ -42,6 +43,11 @@ def parse_rcv_venta_csv_file(
Parse entries from an RV ("Registro de Ventas") (CSV file).
"""
# warning: this looks like it would be executed before the iteration begins but it is not.
if not isinstance(razon_social, str):
raise TypeError("Inappropriate type of 'razon_social'.")
cl_sii.dte.data_models.validate_contribuyente_razon_social(razon_social)

schema_context = dict(
emisor_rut=rut,
emisor_razon_social=razon_social,
Expand Down Expand Up @@ -154,6 +160,11 @@ def parse_rcv_compra_registro_csv_file(
Parse entries from an RC ("Registro de Compras") / "registro" (CSV file).
"""
# warning: this looks like it would be executed before the iteration begins but it is not.
if not isinstance(razon_social, str):
raise TypeError("Inappropriate type of 'razon_social'.")
cl_sii.dte.data_models.validate_contribuyente_razon_social(razon_social)

schema_context = dict(
receptor_rut=rut,
receptor_razon_social=razon_social,
Expand Down Expand Up @@ -235,6 +246,11 @@ def parse_rcv_compra_no_incluir_csv_file(
Parse entries from an RC ("Registro de Compras") / "no incluir" (CSV file).
"""
# warning: this looks like it would be executed before the iteration begins but it is not.
if not isinstance(razon_social, str):
raise TypeError("Inappropriate type of 'razon_social'.")
cl_sii.dte.data_models.validate_contribuyente_razon_social(razon_social)

schema_context = dict(
receptor_rut=rut,
receptor_razon_social=razon_social,
Expand Down Expand Up @@ -310,6 +326,11 @@ def parse_rcv_compra_reclamado_csv_file(
Parse entries from an RC ("Registro de Compras") / "reclamado" (CSV file).
"""
# warning: this looks like it would be executed before the iteration begins but it is not.
if not isinstance(razon_social, str):
raise TypeError("Inappropriate type of 'razon_social'.")
cl_sii.dte.data_models.validate_contribuyente_razon_social(razon_social)

schema_context = dict(
receptor_rut=rut,
receptor_razon_social=razon_social,
Expand Down Expand Up @@ -385,6 +406,11 @@ def parse_rcv_compra_pendiente_csv_file(
Parse entries from an RC ("Registro de Compras") / "pendiente" (CSV file).
"""
# warning: this looks like it would be executed before the iteration begins but it is not.
if not isinstance(razon_social, str):
raise TypeError("Inappropriate type of 'razon_social'.")
cl_sii.dte.data_models.validate_contribuyente_razon_social(razon_social)

schema_context = dict(
receptor_rut=rut,
receptor_razon_social=razon_social,
Expand Down
86 changes: 86 additions & 0 deletions tests/test_rcv_parse_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
parse_rcv_venta_csv_file,
_parse_rcv_csv_file,
)
from cl_sii.rut import Rut


class RcvVentaCsvRowSchemaTest(unittest.TestCase):
Expand Down Expand Up @@ -47,22 +48,107 @@ def test_parse_rcv_venta_csv_file(self) -> None:
# TODO: implement for 'parse_rcv_venta_csv_file'.
pass

def test_fail_parse_rcv_venta_csv_file_bad_razon_social(self) -> None:
other_kwargs = dict(rut=Rut('1-9'), input_file_path='x')

with self.assertRaises(TypeError) as cm:
next(parse_rcv_venta_csv_file(razon_social=1, **other_kwargs))
self.assertEqual(cm.exception.args, ("Inappropriate type of 'razon_social'.", ))

with self.assertRaises(ValueError) as cm:
next(parse_rcv_venta_csv_file(razon_social='', **other_kwargs))
self.assertEqual(cm.exception.args, ("Value must not be empty.", ))

with self.assertRaises(ValueError) as cm:
next(parse_rcv_venta_csv_file(razon_social=' a ', **other_kwargs))
self.assertEqual(
cm.exception.args,
("Value must not have leading or trailing whitespace.", ))

def test_parse_rcv_compra_registro_csv_file(self) -> None:
# TODO: implement for 'parse_rcv_compra_registro_csv_file'.
pass

def test_fail_parse_rcv_compra_registro_csv_file_bad_razon_social(self) -> None:
other_kwargs = dict(rut=Rut('1-9'), input_file_path='x')

with self.assertRaises(TypeError) as cm:
next(parse_rcv_compra_registro_csv_file(razon_social=1, **other_kwargs))
self.assertEqual(cm.exception.args, ("Inappropriate type of 'razon_social'.", ))

with self.assertRaises(ValueError) as cm:
next(parse_rcv_compra_registro_csv_file(razon_social='', **other_kwargs))
self.assertEqual(cm.exception.args, ("Value must not be empty.", ))

with self.assertRaises(ValueError) as cm:
next(parse_rcv_compra_registro_csv_file(razon_social=' a ', **other_kwargs))
self.assertEqual(
cm.exception.args,
("Value must not have leading or trailing whitespace.", ))

def test_parse_rcv_compra_no_incluir_csv_file(self) -> None:
# TODO: implement for 'parse_rcv_compra_no_incluir_csv_file'.
pass

def test_fail_parse_rcv_compra_no_incluir_csv_file_bad_razon_social(self) -> None:
other_kwargs = dict(rut=Rut('1-9'), input_file_path='x')

with self.assertRaises(TypeError) as cm:
next(parse_rcv_compra_no_incluir_csv_file(razon_social=1, **other_kwargs))
self.assertEqual(cm.exception.args, ("Inappropriate type of 'razon_social'.", ))

with self.assertRaises(ValueError) as cm:
next(parse_rcv_compra_no_incluir_csv_file(razon_social='', **other_kwargs))
self.assertEqual(cm.exception.args, ("Value must not be empty.", ))

with self.assertRaises(ValueError) as cm:
next(parse_rcv_compra_no_incluir_csv_file(razon_social=' a ', **other_kwargs))
self.assertEqual(
cm.exception.args,
("Value must not have leading or trailing whitespace.", ))

def test_parse_rcv_compra_reclamado_csv_file(self) -> None:
# TODO: implement for 'parse_rcv_compra_reclamado_csv_file'.
pass

def test_fail_parse_rcv_compra_reclamado_csv_file_bad_razon_social(self) -> None:
other_kwargs = dict(rut=Rut('1-9'), input_file_path='x')

with self.assertRaises(TypeError) as cm:
next(parse_rcv_compra_reclamado_csv_file(razon_social=1, **other_kwargs))
self.assertEqual(cm.exception.args, ("Inappropriate type of 'razon_social'.", ))

with self.assertRaises(ValueError) as cm:
next(parse_rcv_compra_reclamado_csv_file(razon_social='', **other_kwargs))
self.assertEqual(cm.exception.args, ("Value must not be empty.", ))

with self.assertRaises(ValueError) as cm:
next(parse_rcv_compra_reclamado_csv_file(razon_social=' a ', **other_kwargs))
self.assertEqual(
cm.exception.args,
("Value must not have leading or trailing whitespace.", ))

def test_parse_rcv_compra_pendiente_csv_file(self) -> None:
# TODO: implement for 'parse_rcv_compra_pendiente_csv_file'.
pass

def test_fail_parse_rcv_compra_pendiente_csv_file_bad_razon_social(self) -> None:
other_kwargs = dict(rut=Rut('1-9'), input_file_path='x')

with self.assertRaises(TypeError) as cm:
next(parse_rcv_compra_pendiente_csv_file(razon_social=1, **other_kwargs))
self.assertEqual(cm.exception.args, ("Inappropriate type of 'razon_social'.", ))

with self.assertRaises(ValueError) as cm:
next(parse_rcv_compra_pendiente_csv_file(razon_social='', **other_kwargs))
self.assertEqual(cm.exception.args, ("Value must not be empty.", ))

with self.assertRaises(ValueError) as cm:
next(parse_rcv_compra_pendiente_csv_file(razon_social=' a ', **other_kwargs))
self.assertEqual(
cm.exception.args,
("Value must not have leading or trailing whitespace.", ))

def test__parse_rcv_csv_file(self) -> None:
# TODO: implement for '_parse_rcv_csv_file'.
pass

0 comments on commit b33ac46

Please sign in to comment.