@@ -87,14 +87,14 @@ def test_from_base64_with_invalid_file(self):
8787 with self .assertRaises (ValueError ):
8888 d = IODict (filepath )
8989
90- # def test_from_base64_with_valid_url_valid_content(self):
91- # url = 'https://raw.githubusercontent.com/fabiocaccamo/python-benedict/master/tests/input/valid-content.base64'
92- # # static method
93- # d = IODict.from_base64(url)
94- # self.assertTrue(isinstance(d, dict))
95- # # constructor
96- # d = IODict(url)
97- # self.assertTrue(isinstance(d, dict))
90+ def test_from_base64_with_valid_url_valid_content (self ):
91+ url = 'https://raw.githubusercontent.com/fabiocaccamo/python-benedict/master/tests/input/valid-content.base64'
92+ # static method
93+ d = IODict .from_base64 (url )
94+ self .assertTrue (isinstance (d , dict ))
95+ # constructor
96+ d = IODict (url )
97+ self .assertTrue (isinstance (d , dict ))
9898
9999 def test_from_base64_with_valid_url_invalid_content (self ):
100100 url = 'https://github.com/fabiocaccamo/python-benedict'
@@ -165,6 +165,20 @@ def test_from_json_with_valid_file_valid_content(self):
165165 d = IODict (filepath )
166166 self .assertTrue (isinstance (d , dict ))
167167
168+ def test_from_json_with_valid_file_valid_content_invalid_format (self ):
169+ filepath = self .input_path ('valid-content.base64' )
170+ with self .assertRaises (ValueError ):
171+ d = IODict .from_json (filepath )
172+ filepath = self .input_path ('valid-content.toml' )
173+ with self .assertRaises (ValueError ):
174+ d = IODict .from_json (filepath )
175+ filepath = self .input_path ('valid-content.xml' )
176+ with self .assertRaises (ValueError ):
177+ d = IODict .from_json (filepath )
178+ filepath = self .input_path ('valid-content.yml' )
179+ with self .assertRaises (ValueError ):
180+ d = IODict .from_json (filepath )
181+
168182 def test_from_json_with_valid_file_invalid_content (self ):
169183 filepath = self .input_path ('invalid-content.json' )
170184 # static method
@@ -274,6 +288,20 @@ def test_from_toml_with_valid_file_valid_content(self):
274288 d = IODict (filepath )
275289 self .assertTrue (isinstance (d , dict ))
276290
291+ def test_from_toml_with_valid_file_valid_content_invalid_format (self ):
292+ # filepath = self.input_path('valid-content.base64')
293+ # with self.assertRaises(ValueError):
294+ # d = IODict.from_toml(filepath)
295+ filepath = self .input_path ('valid-content.json' )
296+ with self .assertRaises (ValueError ):
297+ d = IODict .from_toml (filepath )
298+ filepath = self .input_path ('valid-content.xml' )
299+ with self .assertRaises (ValueError ):
300+ d = IODict .from_toml (filepath )
301+ filepath = self .input_path ('valid-content.yml' )
302+ with self .assertRaises (ValueError ):
303+ d = IODict .from_toml (filepath )
304+
277305 def test_from_toml_with_valid_file_invalid_content (self ):
278306 filepath = self .input_path ('invalid-content.toml' )
279307 # static method
@@ -384,6 +412,20 @@ def test_from_xml_with_valid_file_valid_content(self):
384412 d = IODict (filepath )
385413 self .assertTrue (isinstance (d , dict ))
386414
415+ def test_from_xml_with_valid_file_valid_content_invalid_format (self ):
416+ filepath = self .input_path ('valid-content.base64' )
417+ with self .assertRaises (ValueError ):
418+ d = IODict .from_xml (filepath )
419+ filepath = self .input_path ('valid-content.json' )
420+ with self .assertRaises (ValueError ):
421+ d = IODict .from_xml (filepath )
422+ filepath = self .input_path ('valid-content.toml' )
423+ with self .assertRaises (ValueError ):
424+ d = IODict .from_xml (filepath )
425+ filepath = self .input_path ('valid-content.yml' )
426+ with self .assertRaises (ValueError ):
427+ d = IODict .from_xml (filepath )
428+
387429 def test_from_xml_with_valid_file_invalid_content (self ):
388430 filepath = self .input_path ('invalid-content.xml' )
389431 # static method
@@ -402,14 +444,14 @@ def test_from_xml_with_invalid_file(self):
402444 with self .assertRaises (ValueError ):
403445 d = IODict (filepath )
404446
405- # def test_from_xml_with_valid_url_valid_content(self):
406- # url = 'https://raw.githubusercontent.com/fabiocaccamo/python-benedict/master/tests/input/valid-content.xml'
407- # # static method
408- # d = IODict.from_xml(url)
409- # self.assertTrue(isinstance(d, dict))
410- # # constructor
411- # d = IODict(url)
412- # self.assertTrue(isinstance(d, dict))
447+ def test_from_xml_with_valid_url_valid_content (self ):
448+ url = 'https://raw.githubusercontent.com/fabiocaccamo/python-benedict/master/tests/input/valid-content.xml'
449+ # static method
450+ d = IODict .from_xml (url )
451+ self .assertTrue (isinstance (d , dict ))
452+ # constructor
453+ d = IODict (url )
454+ self .assertTrue (isinstance (d , dict ))
413455
414456 def test_from_xml_with_valid_url_invalid_content (self ):
415457 url = 'https://github.com/fabiocaccamo/python-benedict'
@@ -495,6 +537,20 @@ def test_from_yaml_with_valid_file_valid_content(self):
495537 d = IODict (filepath )
496538 self .assertTrue (isinstance (d , dict ))
497539
540+ def test_from_yaml_with_valid_file_valid_content_invalid_format (self ):
541+ filepath = self .input_path ('valid-content.base64' )
542+ with self .assertRaises (ValueError ):
543+ d = IODict .from_yaml (filepath )
544+ # filepath = self.input_path('valid-content.json')
545+ # with self.assertRaises(ValueError):
546+ # d = IODict.from_yaml(filepath)
547+ filepath = self .input_path ('valid-content.toml' )
548+ with self .assertRaises (ValueError ):
549+ d = IODict .from_yaml (filepath )
550+ filepath = self .input_path ('valid-content.xml' )
551+ with self .assertRaises (ValueError ):
552+ d = IODict .from_yaml (filepath )
553+
498554 def test_from_yaml_with_valid_file_invalid_content (self ):
499555 filepath = self .input_path ('invalid-content.yml' )
500556 # static method
0 commit comments