|
1 | 1 | import datetime |
| 2 | +import uuid |
2 | 3 |
|
3 | 4 | import mock |
4 | 5 | import pytest |
@@ -416,6 +417,26 @@ def test_string_format_date(self, value): |
416 | 417 |
|
417 | 418 | assert result == value |
418 | 419 |
|
| 420 | + @pytest.mark.parametrize('value', [ |
| 421 | + uuid.UUID('{12345678-1234-5678-1234-567812345678}'), |
| 422 | + ]) |
| 423 | + def test_string_format_uuid(self, value): |
| 424 | + schema = Schema('string', schema_format='uuid') |
| 425 | + |
| 426 | + result = schema.validate(value) |
| 427 | + |
| 428 | + assert result == value |
| 429 | + |
| 430 | + @pytest.mark.parametrize('value', [ |
| 431 | + b('true'), u('true'), False, 1, 3.14, [1, 3], |
| 432 | + datetime.date(2018, 1, 2), datetime.datetime(2018, 1, 2, 23, 59, 59), |
| 433 | + ]) |
| 434 | + def test_string_format_uuid_invalid(self, value): |
| 435 | + schema = Schema('string', schema_format='uuid') |
| 436 | + |
| 437 | + with pytest.raises(InvalidSchemaValue): |
| 438 | + schema.validate(value) |
| 439 | + |
419 | 440 | @pytest.mark.parametrize('value', [ |
420 | 441 | b('true'), u('true'), False, 1, 3.14, [1, 3], |
421 | 442 | datetime.date(1989, 1, 2), |
|
0 commit comments