Skip to content

Commit

Permalink
Agrego test de regex para accrualPeriodicity, y permito anexar mensaj…
Browse files Browse the repository at this point in the history
…es propios al final de los mensajes por default en los assert
  • Loading branch information
capitantoto committed Dec 14, 2016
1 parent 8d8250b commit e2259b7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/test_pydatajson.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def get_sample(cls, sample_filename):
def setUpClass(cls):
cls.dj = pydatajson.DataJson()
cls.maxDiff = None
cls.longMessage = True

@classmethod
def tearDownClass(cls):
Expand Down Expand Up @@ -263,6 +264,34 @@ def test_validate_catalog_remote_datajson(self):
res = self.dj.validate_catalog(datajson)
self.assertEqual(exp, res)

def test_correctness_of_accrualPeriodicity_regex(self):
"""Prueba que la regex de validación de
dataset["accrualPeriodicity"] sea correcta."""

datajson_path = "tests/samples/full_data.json"
datajson = json.load(open(datajson_path))

valid_values = ['R/P10Y', 'R/P4Y', 'R/P3Y', 'R/P2Y', 'R/P1Y',
'R/P6M', 'R/P4M', 'R/P3M', 'R/P2M', 'R/P1M',
'R/P0.5M', 'R/P0.33M', 'R/P1W', 'R/P0.5W',
'R/P0.33W', 'R/P1D', 'R/PT1H', 'R/PT1S',
'eventual']

for value in valid_values:
datajson["dataset"][0]["accrualPeriodicity"] = value
res = self.dj.is_valid_catalog(datajson)
self.assertTrue(res, msg=value)

invalid_values = ['RP10Y', 'R/PY', 'R/P3', 'RR/P2Y', 'R/PnY',
'R/P6MT', 'R/PT', 'R/T1M', 'R/P0.M', '/P0.33M',
'R/P1Week', 'R/P.5W', 'R/P', 'R/T', 'R/PT1H3M',
'eventual ', '']

for value in invalid_values:
datajson["dataset"][0]["accrualPeriodicity"] = value
res = self.dj.is_valid_catalog(datajson)
self.assertFalse(res, msg=value)


if __name__ == '__main__':
nose.run(defaultTest=__name__)

0 comments on commit e2259b7

Please sign in to comment.