Exemplo n.º 1
0
 def test_fromJSONSha2(self):
     attachment = Attachment.from_json('{"usage_type":"test", "content_type":"test", "length":1, "sha2":"test"}')
     self.assertEqual(attachment.usage_type, 'test')
     self.assertIsNone(attachment.display)
     self.assertEqual(attachment.content_type, 'test')
     self.assertEqual(attachment.length, 1)
     self.assertEqual(attachment.sha2, 'test')
 def test_fromJSONcontent_type(self):
     attachment = Attachment.from_json('{"usage_type":"test", "content_type":"test"}')
     self.assertEqual(attachment.usage_type, "test")
     self.assertIsNone(attachment.display)
     self.assertEqual(attachment.content_type, "test")
     self.assertIsNone(attachment.length)
     self.assertIsNone(attachment.sha2)
Exemplo n.º 3
0
 def test_fromJSONDisplay(self):
     attachment = Attachment.from_json('{"usage_type":"test", "content_type":"test", "length":1, "sha2":"test", "fileurl":"test", "display":{"en-US":"test"}}')
     self.assertEqual(attachment.usage_type, 'test')
     self.assertEqual(attachment.content_type, 'test')
     self.assertEqual(attachment.length, 1)
     self.assertEqual(attachment.sha2, 'test')
     self.assertEqual(attachment.fileurl, 'test')
     self.languageMapVerificationHelper(attachment.display)
 def test_fromJSONLength(self):
     attachment = Attachment.from_json(
         '{"usage_type":"test", "content_type":"test", "length":1}')
     self.assertEqual(attachment.usage_type, 'test')
     self.assertIsNone(attachment.display)
     self.assertEqual(attachment.content_type, 'test')
     self.assertEqual(attachment.length, 1)
     self.assertIsNone(attachment.sha2)
 def test_FromJSONusage_type(self):
     attachment = Attachment.from_json('{"usage_type":"test"}')
     self.assertEqual(attachment.usage_type, 'test')
     self.assertIsNone(attachment.display)
     self.assertIsNone(attachment.description)
     self.assertIsNone(attachment.content_type)
     self.assertIsNone(attachment.length)
     self.assertIsNone(attachment.sha2)
     self.assertIsNone(attachment.fileurl)
 def test_FromJSONEmptyObject(self):
     attachment = Attachment.from_json("{}")
     self.assertIsNone(attachment.usage_type)
     self.assertIsNone(attachment.display)
     self.assertIsNone(attachment.description)
     self.assertIsNone(attachment.content_type)
     self.assertIsNone(attachment.length)
     self.assertIsNone(attachment.sha2)
     self.assertIsNone(attachment.fileurl)
 def test_FromJSONusage_type(self):
     attachment = Attachment.from_json('{"usage_type":"test"}')
     self.assertEqual(attachment.usage_type, "test")
     self.assertIsNone(attachment.display)
     self.assertIsNone(attachment.description)
     self.assertIsNone(attachment.content_type)
     self.assertIsNone(attachment.length)
     self.assertIsNone(attachment.sha2)
     self.assertIsNone(attachment.fileurl)
 def test_FromJSONEmptyObject(self):
     attachment = Attachment.from_json('{}')
     self.assertIsNone(attachment.usage_type)
     self.assertIsNone(attachment.display)
     self.assertIsNone(attachment.description)
     self.assertIsNone(attachment.content_type)
     self.assertIsNone(attachment.length)
     self.assertIsNone(attachment.sha2)
     self.assertIsNone(attachment.fileurl)
Exemplo n.º 9
0
 def test_FromJSONusage_type(self):
     attachment = Attachment.from_json('{"usage_type":"test"}')
     self.assertEqual(attachment.usage_type, 'test')
     self.assertIsNone(attachment.display)
     self.assertIsNone(attachment.content_type)
     self.assertIsNone(attachment.length)
     self.assertIsNone(attachment.sha2)
     self.assertFalse(hasattr(attachment, '_description'))
     self.assertFalse(hasattr(attachment, '_fileurl'))
Exemplo n.º 10
0
 def test_FromJSONEmptyObject(self):
     attachment = Attachment.from_json('{}')
     self.assertIsNone(attachment.usage_type)
     self.assertIsNone(attachment.display)
     self.assertFalse(hasattr(attachment, '_description'))
     self.assertIsNone(attachment.content_type)
     self.assertIsNone(attachment.length)
     self.assertIsNone(attachment.sha2)
     self.assertFalse(hasattr(attachment, '_fileurl'))
 def test_fromJSONFileUrl(self):
     attachment = Attachment.from_json(
         '{"usage_type":"test", "content_type":"test", "length":1, "sha2":"test", "fileurl":"test"}'
     )
     self.assertEqual(attachment.usage_type, 'test')
     self.assertIsNone(attachment.display)
     self.assertEqual(attachment.content_type, 'test')
     self.assertEqual(attachment.length, 1)
     self.assertEqual(attachment.sha2, 'test')
     self.assertEqual(attachment.fileurl, 'test')
 def test_fromJSONDisplay(self):
     attachment = Attachment.from_json(
         '{"usage_type":"test", "content_type":"test", "length":1, '
         '"sha2":"test", "fileurl":"test", "display":{"en-US":"test"}}')
     self.assertEqual(attachment.usage_type, 'test')
     self.assertEqual(attachment.content_type, 'test')
     self.assertEqual(attachment.length, 1)
     self.assertEqual(attachment.sha2, 'test')
     self.assertEqual(attachment.fileurl, 'test')
     self.languageMapVerificationHelper(attachment.display)
 def test_fromJSONFileUrl(self):
     attachment = Attachment.from_json(
         '{"usage_type":"test", "content_type":"test", "length":1, "sha2":"test", "fileurl":"test"}'
     )
     self.assertEqual(attachment.usage_type, "test")
     self.assertIsNone(attachment.display)
     self.assertEqual(attachment.content_type, "test")
     self.assertEqual(attachment.length, 1)
     self.assertEqual(attachment.sha2, "test")
     self.assertEqual(attachment.fileurl, "test")
Exemplo n.º 14
0
 def test_ToJSONFromJSON(self):
     json_str = '''{"sha2": "test", "description": {"en-US": "test"}, "usage_type": "test", "length": 1, "content_type": "test", "fileurl": "test", "display": {"en-US": "test"}}'''
     attachment = Attachment.from_json(json_str)
     self.assertEqual(attachment.usage_type, 'test')
     self.assertEqual(attachment.content_type, 'test')
     self.assertEqual(attachment.length, 1)
     self.assertEqual(attachment.sha2, 'test')
     self.assertEqual(attachment.fileurl, 'test')
     self.languageMapVerificationHelper(attachment.description)
     self.languageMapVerificationHelper(attachment.display)
     self.assertEqual(attachment.to_json(), '{"sha2": "test", "contentType": "test", "description": {"en-US": "test"}, "usageType": "test", "length": 1, "fileUrl": "test", "display": {"en-US": "test"}}')
 def test_ToJSONFromJSON(self):
     json_str = '''{"sha2": "test", "description": {"en-US": "test"}, "usage_type": "test",
     "length": 1, "content_type": "test", "fileurl": "test", "display": {"en-US": "test"}}'''
     attachment = Attachment.from_json(json_str)
     self.assertEqual(attachment.usage_type, 'test')
     self.assertEqual(attachment.content_type, 'test')
     self.assertEqual(attachment.length, 1)
     self.assertEqual(attachment.sha2, 'test')
     self.assertEqual(attachment.fileurl, 'test')
     self.languageMapVerificationHelper(attachment.description)
     self.languageMapVerificationHelper(attachment.display)
     self.assertEqual(
         attachment.to_json(),
         '{"sha2": "test", "contentType": "test", "description": {"en-US": "test"}, '
         '"usageType": "test", "length": 1, "fileUrl": "test", "display": {"en-US": "test"}}'
     )
Exemplo n.º 16
0
 def test_FromJSONExceptionEmpty(self):
     with self.assertRaises(ValueError):
         attachment = Attachment.from_json('')
 def test_FromJSONExceptionEmpty(self):
     with self.assertRaises(ValueError):
         Attachment.from_json('')