Example #1
0
    def test_round_trip_unicode_set(self):
        """
        Round trip a unicode set
        """
        attr = UnicodeSetAttribute()
        orig = {'foo', 'bar'}
        assert orig == attr.deserialize(attr.serialize(orig))

        orig = {'true', 'false'}
        assert orig == attr.deserialize(attr.serialize(orig))

        orig = {'1', '2.8'}
        assert orig == attr.deserialize(attr.serialize(orig))

        orig = {'[1,2,3]', '2.8'}
        assert orig == attr.deserialize(attr.serialize(orig))
Example #2
0
    def test_unicode_set_deserialize(self):
        """
        UnicodeSetAttribute.deserialize
        """
        attr = UnicodeSetAttribute()
        value = {'foo', 'bar'}
        assert attr.deserialize(value) == value

        value = {'True', 'False'}
        assert attr.deserialize(value) == value

        value = {'true', 'false'}
        assert attr.deserialize(value) == value

        value = {'1', '2.8'}
        assert attr.deserialize(value) == value
Example #3
0
    def test_unicode_set_deserialize(self):
        """
        UnicodeSetAttribute.deserialize
        """
        attr = UnicodeSetAttribute()
        value = set([six.u('foo'), six.u('bar')])
        assert attr.deserialize(value) == value

        value = set([six.u('True'), six.u('False')])
        assert attr.deserialize(value) == value

        value = set([six.u('true'), six.u('false')])
        assert attr.deserialize(value) == value

        value = set([six.u('1'), six.u('2.8')])
        assert attr.deserialize(value) == value
Example #4
0
 def test_round_trip_unicode_set(self):
     """
     Round trip a unicode set
     """
     attr = UnicodeSetAttribute()
     orig = set([six.u('foo'), six.u('bar')])
     self.assertEqual(orig, attr.deserialize(attr.serialize(orig)))
Example #5
0
    def test_round_trip_unicode_set(self):
        """
        Round trip a unicode set
        """
        attr = UnicodeSetAttribute()
        orig = set([six.u('foo'), six.u('bar')])
        assert orig == attr.deserialize(attr.serialize(orig))

        orig = set([six.u('true'), six.u('false')])
        assert orig == attr.deserialize(attr.serialize(orig))

        orig = set([six.u('1'), six.u('2.8')])
        assert orig == attr.deserialize(attr.serialize(orig))

        orig = set([six.u('[1,2,3]'), six.u('2.8')])
        assert orig == attr.deserialize(attr.serialize(orig))
Example #6
0
    def test_unicode_set_deserialize(self):
        """
        UnicodeSetAttribute.deserialize
        """
        attr = UnicodeSetAttribute()
        value = set([six.u('foo'), six.u('bar')])
        assert attr.deserialize(value) == value

        value = set([six.u('True'), six.u('False')])
        assert attr.deserialize(value) == value

        value = set([six.u('true'), six.u('false')])
        assert attr.deserialize(value) == value

        value = set([six.u('1'), six.u('2.8')])
        assert attr.deserialize(value) == value
Example #7
0
    def test_round_trip_unicode_set(self):
        """
        Round trip a unicode set
        """
        attr = UnicodeSetAttribute()
        orig = set([six.u('foo'), six.u('bar')])
        assert orig == attr.deserialize(attr.serialize(orig))

        orig = set([six.u('true'), six.u('false')])
        assert orig == attr.deserialize(attr.serialize(orig))

        orig = set([six.u('1'), six.u('2.8')])
        assert orig == attr.deserialize(attr.serialize(orig))

        orig = set([six.u('[1,2,3]'), six.u('2.8')])
        assert orig == attr.deserialize(attr.serialize(orig))
 def test_round_trip_unicode_set(self):
     """
     Round trip a unicode set
     """
     attr = UnicodeSetAttribute()
     orig = set([six.u("foo"), six.u("bar")])
     self.assertEqual(orig, attr.deserialize(attr.serialize(orig)))
Example #9
0
 def test_unicode_set_deserialize(self):
     """
     UnicodeSetAttribute.deserialize
     """
     attr = UnicodeSetAttribute()
     self.assertEqual(
         attr.deserialize([json.dumps(val) for val in sorted(set([six.u('foo'), six.u('bar')]))]),
         set([six.u('foo'), six.u('bar')])
     )
Example #10
0
 def test_unicode_set_serialize(self):
     """
     UnicodeSetAttribute.serialize
     """
     attr = UnicodeSetAttribute()
     self.assertEqual(attr.attr_type, STRING_SET)
     self.assertEqual(attr.deserialize(None), None)
     self.assertEqual(
         attr.serialize(set([six.u('foo'), six.u('bar')])),
         [json.dumps(val) for val in sorted(set([six.u('foo'), six.u('bar')]))])
Example #11
0
 def test_unicode_set_deserialize(self):
     """
     UnicodeSetAttribute.deserialize
     """
     attr = UnicodeSetAttribute()
     value = set([six.u('foo'), six.u('bar')])
     self.assertEqual(
         attr.deserialize(value),
         value
     )
Example #12
0
 def test_unicode_set_deserialize(self):
     """
     UnicodeSetAttribute.deserialize old way
     """
     attr = UnicodeSetAttribute()
     value = set([six.u('foo'), six.u('bar')])
     old_value = set([json.dumps(val) for val in value])
     self.assertEqual(
         attr.deserialize(old_value),
         value
     )
Example #13
0
    def test_unicode_set_serialize(self):
        """
        UnicodeSetAttribute.serialize
        """
        attr = UnicodeSetAttribute()
        assert attr.attr_type == STRING_SET
        assert attr.deserialize(None) is None

        expected = sorted(['foo', 'bar'])
        assert attr.serialize({'foo', 'bar'}) == expected

        expected = sorted(['True', 'False'])
        assert attr.serialize({'True', 'False'}) == expected

        expected = sorted(['true', 'false'])
        assert attr.serialize({'true', 'false'}) == expected
Example #14
0
    def test_unicode_set_serialize(self):
        """
        UnicodeSetAttribute.serialize
        """
        attr = UnicodeSetAttribute()
        assert attr.attr_type == STRING_SET
        assert attr.deserialize(None) is None

        expected = sorted([six.u('foo'), six.u('bar')])
        assert attr.serialize(set([six.u('foo'), six.u('bar')])) == expected

        expected = sorted([six.u('True'), six.u('False')])
        assert attr.serialize(set([six.u('True'), six.u('False')])) == expected

        expected = sorted([six.u('true'), six.u('false')])
        assert attr.serialize(set([six.u('true'), six.u('false')])) == expected
Example #15
0
    def test_unicode_set_serialize(self):
        """
        UnicodeSetAttribute.serialize
        """
        attr = UnicodeSetAttribute()
        assert attr.attr_type == STRING_SET
        assert attr.deserialize(None) is None

        expected = sorted([six.u('foo'), six.u('bar')])
        assert attr.serialize(set([six.u('foo'), six.u('bar')])) == expected

        expected = sorted([six.u('True'), six.u('False')])
        assert attr.serialize(set([six.u('True'), six.u('False')])) == expected

        expected = sorted([six.u('true'), six.u('false')])
        assert attr.serialize(set([six.u('true'), six.u('false')])) == expected