Exemplo n.º 1
0
def test_coerce_cycle_point():
    """Test coerce_cycle_point."""
    validator = VDR()
    # The good
    for value, result in [('', None), ('3', '3'), ('2018', '2018'),
                          ('20181225T12Z', '20181225T12Z'),
                          ('2018-12-25T12:00+11:00', '2018-12-25T12:00+11:00')
                          ]:
        assert validator.coerce_cycle_point(value, ['whatever']) == result
    # The bad
    for value in ['None', ' Who cares? ', 'True', '1, 2', '20781340E10']:
        with pytest.raises(IllegalValueError):
            validator.coerce_cycle_point(value, ['whatever'])
Exemplo n.º 2
0
 def test_coerce_cycle_point(self):
     """Test coerce_cycle_point."""
     validator = VDR()
     # The good
     for value, result in [('', None), ('3', '3'), ('2018', '2018'),
                           ('20181225T12Z', '20181225T12Z'),
                           ('2018-12-25T12:00+11:00',
                            '2018-12-25T12:00+11:00')]:
         self.assertEqual(validator.coerce_cycle_point(value, ['whatever']),
                          result)
     # The bad
     for value in ['None', ' Who cares? ', 'True', '1, 2', '20781340E10']:
         self.assertRaises(IllegalValueError, validator.coerce_cycle_point,
                           value, ['whatever'])
Exemplo n.º 3
0
 def test_coerce_cycle_point(self):
     """Test coerce_cycle_point."""
     validator = VDR()
     # The good
     for value, result in [
             ('', None),
             ('3', '3'),
             ('2018', '2018'),
             ('20181225T12Z', '20181225T12Z'),
             ('2018-12-25T12:00+11:00', '2018-12-25T12:00+11:00')]:
         self.assertEqual(
             validator.coerce_cycle_point(value, ['whatever']), result)
     # The bad
     for value in [
             'None', ' Who cares? ', 'True', '1, 2', '20781340E10']:
         self.assertRaises(
             IllegalValueError,
             validator.coerce_cycle_point, value, ['whatever'])