Exemplo n.º 1
0
 def test_stores_and_retrieves_binary_data(self):
     data = b"\x01\x02\xff\xff\xfe\xff\xff\xfe"
     binary_item = BinaryFieldModel(data=Bin(data))
     self.assertEqual(data, binary_item.data)
     binary_item.save()
     self.assertEqual(
         data, BinaryFieldModel.objects.get(id=binary_item.id).data)
Exemplo n.º 2
0
 def test_does_not_truncate_at_zero_bytes(self):
     data = b"BEFORE THE ZERO\x00AFTER THE ZERO"
     binary_item = BinaryFieldModel(data=Bin(data))
     self.assertEqual(data, binary_item.data)
     binary_item.save()
     self.assertEqual(
         data, BinaryFieldModel.objects.get(id=binary_item.id).data)
Exemplo n.º 3
0
 def test_looks_up_data(self):
     data = b"Binary item"
     binary_item = BinaryFieldModel(data=Bin(data))
     binary_item.save()
     self.assertEqual(
         binary_item, BinaryFieldModel.objects.get(data=Bin(data)))
Exemplo n.º 4
0
 def test_returns_bytes_not_text(self):
     binary_item = BinaryFieldModel(data=Bin(b"Data"))
     binary_item.save()
     retrieved_data = BinaryFieldModel.objects.get(id=binary_item.id).data
     self.assertIsInstance(retrieved_data, str)
Exemplo n.º 5
0
 def test_stores_and_retrieves_empty_data(self):
     binary_item = BinaryFieldModel(data=Bin(b''))
     self.assertEqual(b'', binary_item.data)
     binary_item.save()
     self.assertEqual(
         b'', BinaryFieldModel.objects.get(id=binary_item.id).data)
Exemplo n.º 6
0
 def test_stores_and_retrieves_None(self):
     binary_item = BinaryFieldModel()
     self.assertIsNone(binary_item.data)
     binary_item.save()
     self.assertIsNone(
         BinaryFieldModel.objects.get(id=binary_item.id).data)
Exemplo n.º 7
0
 def test_stores_and_retrieves_empty_data(self):
     binary_item = BinaryFieldModel(data=Bin(b''))
     self.assertEqual(b'', binary_item.data)
     binary_item.save()
     self.assertEqual(b'',
                      BinaryFieldModel.objects.get(id=binary_item.id).data)
Exemplo n.º 8
0
 def test_stores_and_retrieves_None(self):
     binary_item = BinaryFieldModel()
     self.assertIsNone(binary_item.data)
     binary_item.save()
     self.assertIsNone(BinaryFieldModel.objects.get(id=binary_item.id).data)
Exemplo n.º 9
0
 def test_looks_up_data(self):
     data = b"Binary item"
     binary_item = BinaryFieldModel(data=Bin(data))
     binary_item.save()
     self.assertEqual(binary_item,
                      BinaryFieldModel.objects.get(data=Bin(data)))
Exemplo n.º 10
0
 def test_returns_bytes_not_text(self):
     binary_item = BinaryFieldModel(data=Bin(b"Data"))
     binary_item.save()
     retrieved_data = BinaryFieldModel.objects.get(id=binary_item.id).data
     self.assertIsInstance(retrieved_data, bytes)