Ejemplo n.º 1
0
 def test_is_a_set_immediately(self):
     s = BigCharSetModel()
     assert s.field == set()
     s.field.add("bold")
     s.field.add("brave")
     s.save()
     assert s.field == {"bold", "brave"}
     s = BigCharSetModel.objects.get(id=s.id)
     assert s.field == {"bold", "brave"}
Ejemplo n.º 2
0
 def test_is_a_set_immediately(self):
     s = BigCharSetModel()
     assert s.field == set()
     s.field.add("bold")
     s.field.add("brave")
     s.save()
     assert s.field == {"bold", "brave"}
     s = BigCharSetModel.objects.get(id=s.id)
     assert s.field == {"bold", "brave"}
Ejemplo n.º 3
0
 def test_empty(self):
     instance = BigCharSetModel(field=set())
     data = serializers.serialize('json', [instance])
     objs = list(serializers.deserialize('json', data))
     instance = objs[0].object
     assert instance.field == set()
Ejemplo n.º 4
0
 def test_dumping(self):
     big_set = {six.text_type(i**2) for i in six.moves.range(1000)}
     instance = BigCharSetModel(field=big_set)
     data = json.loads(serializers.serialize('json', [instance]))[0]
     field = data['fields']['field']
     assert sorted(field.split(',')) == sorted(big_set)