@@ -510,9 +510,30 @@ def test___hash__not_equals(self):
|
510 | 510 |
|
511 | 511 | def test___repr__(self):
|
512 | 512 | field1 = self._make_one("field1", "STRING")
|
513 |
| -expected = "SchemaField('field1', 'STRING', 'NULLABLE', None, (), ())" |
| 513 | +expected = "SchemaField('field1', 'STRING', 'NULLABLE', None, (), None)" |
514 | 514 | self.assertEqual(repr(field1), expected)
|
515 | 515 |
|
| 516 | +def test___repr__evaluable_no_policy_tags(self): |
| 517 | +field = self._make_one("field1", "STRING", "REQUIRED", "Description") |
| 518 | +field_repr = repr(field) |
| 519 | +SchemaField = self._get_target_class() # needed for eval # noqa |
| 520 | + |
| 521 | +evaled_field = eval(field_repr) |
| 522 | + |
| 523 | +assert field == evaled_field |
| 524 | + |
| 525 | +def test___repr__evaluable_with_policy_tags(self): |
| 526 | +policy_tags = PolicyTagList(names=["foo", "bar"]) |
| 527 | +field = self._make_one( |
| 528 | +"field1", "STRING", "REQUIRED", "Description", policy_tags=policy_tags, |
| 529 | +) |
| 530 | +field_repr = repr(field) |
| 531 | +SchemaField = self._get_target_class() # needed for eval # noqa |
| 532 | + |
| 533 | +evaled_field = eval(field_repr) |
| 534 | + |
| 535 | +assert field == evaled_field |
| 536 | + |
516 | 537 |
|
517 | 538 | # TODO: dedup with the same class in test_table.py.
|
518 | 539 | class _SchemaBase(object):
|
@@ -786,6 +807,34 @@ def test___hash__not_equals(self):
|
786 | 807 | set_two = {policy2}
|
787 | 808 | self.assertNotEqual(set_one, set_two)
|
788 | 809 |
|
| 810 | +def test___repr__no_tags(self): |
| 811 | +policy = self._make_one() |
| 812 | +assert repr(policy) == "PolicyTagList(names=())" |
| 813 | + |
| 814 | +def test___repr__with_tags(self): |
| 815 | +policy1 = self._make_one(["foo", "bar", "baz"]) |
| 816 | +policy2 = self._make_one(["baz", "bar", "foo"]) |
| 817 | +expected_repr = "PolicyTagList(names=('bar', 'baz', 'foo'))" # alphabetical |
| 818 | + |
| 819 | +assert repr(policy1) == expected_repr |
| 820 | +assert repr(policy2) == expected_repr |
| 821 | + |
| 822 | +def test___repr__evaluable_no_tags(self): |
| 823 | +policy = self._make_one(names=[]) |
| 824 | +policy_repr = repr(policy) |
| 825 | + |
| 826 | +evaled_policy = eval(policy_repr) |
| 827 | + |
| 828 | +assert policy == evaled_policy |
| 829 | + |
| 830 | +def test___repr__evaluable_with_tags(self): |
| 831 | +policy = self._make_one(names=["foo", "bar"]) |
| 832 | +policy_repr = repr(policy) |
| 833 | + |
| 834 | +evaled_policy = eval(policy_repr) |
| 835 | + |
| 836 | +assert policy == evaled_policy |
| 837 | + |
789 | 838 |
|
790 | 839 | @pytest.mark.parametrize(
|
791 | 840 | "api,expect,key2",
|
|
0 commit comments