def test_from_plist_with_invalid_file(self):
     filepath = self.input_path('invalid-file.plist')
     # static method
     with self.assertRaises(ValueError):
         IODict.from_plist(filepath)
     # constructor
     with self.assertRaises(ValueError):
         IODict(filepath, format='plist')
 def test_from_plist_with_invalid_url(self):
     url = 'https://github.com/fabiocaccamo/python-benedict-invalid'
     # static method
     with self.assertRaises(ValueError):
         IODict.from_plist(url)
     # constructor
     with self.assertRaises(ValueError):
         IODict(url, format='plist')
 def test_from_plist_with_invalid_data(self):
     j = 'Lorem ipsum est in ea occaecat nisi officia.'
     # static method
     with self.assertRaises(ValueError):
         IODict.from_plist(j)
     # constructor
     with self.assertRaises(ValueError):
         IODict(j, format='plist')
 def test_to_plist(self):
     # example data taken from:
     # https://docs.python.org/3/library/plistlib.html#examples
     d = IODict(self._dict)
     s = d.to_plist()
     # print(s)
     self.assertEqual(d, IODict.from_plist(s))
 def test_from_plist_with_valid_url_valid_content(self):
     url = self.input_url('valid-content.plist')
     # static method
     d = IODict.from_plist(url)
     self.assertTrue(isinstance(d, dict))
     # constructor
     d = IODict(url, format='plist')
     self.assertTrue(isinstance(d, dict))
     # constructor with format autodetection
     d = IODict(url)
     self.assertTrue(isinstance(d, dict))
 def test_from_plist_with_valid_file_valid_content(self):
     filepath = self.input_path('valid-content.plist')
     # static method
     d = IODict.from_plist(filepath)
     self.assertTrue(isinstance(d, dict))
     # constructor
     d = IODict(filepath, format='plist')
     self.assertTrue(isinstance(d, dict))
     # constructor with format autodetection
     d = IODict(filepath)
     self.assertTrue(isinstance(d, dict))
 def test_from_plist_with_valid_data(self):
     j = self._plist
     # static method
     d = IODict.from_plist(j)
     self.assertTrue(isinstance(d, dict))
     self.assertEqual(d.get('aDate'), self._dict.get('aDate'))
     self.assertEqual(d, self._dict)
     # constructor
     d = IODict(j, format='plist')
     self.assertTrue(isinstance(d, dict))
     self.assertEqual(d, self._dict)
 def test_to_plist_file(self):
     d = IODict(self._dict)
     filepath = self.output_path('test_to_plist_file.plist')
     d.to_plist(filepath=filepath)
     self.assertFileExists(filepath)
     self.assertEqual(d, IODict.from_plist(filepath))
 def test_from_plist_with_valid_file_valid_content_invalid_format(self):
     filepath = self.input_path('valid-content.base64')
     with self.assertRaises(ValueError):
         IODict.from_plist(filepath)
     filepath = self.input_path('valid-content.csv')
     with self.assertRaises(ValueError):
         IODict.from_plist(filepath)
     filepath = self.input_path('valid-content.json')
     with self.assertRaises(ValueError):
         IODict.from_plist(filepath)
     filepath = self.input_path('valid-content.pickle')
     with self.assertRaises(ValueError):
         IODict.from_plist(filepath)
     filepath = self.input_path('valid-content.qs')
     with self.assertRaises(ValueError):
         IODict.from_plist(filepath)
     filepath = self.input_path('valid-content.toml')
     with self.assertRaises(ValueError):
         IODict.from_plist(filepath)
     filepath = self.input_path('valid-content.xml')
     with self.assertRaises(ValueError):
         IODict.from_plist(filepath)
     filepath = self.input_path('valid-content.yml')
     with self.assertRaises(ValueError):
         IODict.from_plist(filepath)