Skip to content

Commit 266533e

Browse files
committed
Improved IODict tests.
1 parent 73b72c4 commit 266533e

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

tests/test_io_dict.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ def test_from_base64_with_valid_file_valid_content(self):
7070

7171
def test_from_base64_with_valid_file_valid_content_invalid_format(self):
7272
filepath = self.input_path('valid-content.json')
73+
with self.assertRaises(ValueError):
74+
IODict.from_base64(filepath)
75+
filepath = self.input_path('valid-content.qs')
7376
with self.assertRaises(ValueError):
7477
IODict.from_base64(filepath)
7578
filepath = self.input_path('valid-content.toml')
@@ -180,6 +183,9 @@ def test_from_json_with_valid_file_valid_content(self):
180183

181184
def test_from_json_with_valid_file_valid_content_invalid_format(self):
182185
filepath = self.input_path('valid-content.base64')
186+
with self.assertRaises(ValueError):
187+
IODict.from_json(filepath)
188+
filepath = self.input_path('valid-content.qs')
183189
with self.assertRaises(ValueError):
184190
IODict.from_json(filepath)
185191
filepath = self.input_path('valid-content.toml')
@@ -330,14 +336,14 @@ def test_from_query_string_with_invalid_file(self):
330336
with self.assertRaises(ValueError):
331337
IODict(filepath)
332338

333-
# def test_from_query_string_with_valid_url_valid_content(self):
334-
# url = 'https://raw.githubusercontent.com/fabiocaccamo/python-benedict/master/tests/input/valid-content.qs'
335-
# # static method
336-
# d = IODict.from_query_string(url)
337-
# self.assertTrue(isinstance(d, dict))
338-
# # constructor
339-
# d = IODict(url)
340-
# self.assertTrue(isinstance(d, dict))
339+
def test_from_query_string_with_valid_url_valid_content(self):
340+
url = 'https://raw.githubusercontent.com/fabiocaccamo/python-benedict/master/tests/input/valid-content.qs'
341+
# static method
342+
d = IODict.from_query_string(url)
343+
self.assertTrue(isinstance(d, dict))
344+
# constructor
345+
d = IODict(url)
346+
self.assertTrue(isinstance(d, dict))
341347

342348
def test_from_query_string_with_valid_url_invalid_content(self):
343349
url = 'https://github.com/fabiocaccamo/python-benedict'
@@ -412,6 +418,9 @@ def test_from_toml_with_valid_file_valid_content_invalid_format(self):
412418
# with self.assertRaises(ValueError):
413419
# d = IODict.from_toml(filepath)
414420
filepath = self.input_path('valid-content.json')
421+
with self.assertRaises(ValueError):
422+
IODict.from_toml(filepath)
423+
filepath = self.input_path('valid-content.qs')
415424
with self.assertRaises(ValueError):
416425
IODict.from_toml(filepath)
417426
filepath = self.input_path('valid-content.xml')
@@ -536,6 +545,9 @@ def test_from_xml_with_valid_file_valid_content_invalid_format(self):
536545
with self.assertRaises(ValueError):
537546
IODict.from_xml(filepath)
538547
filepath = self.input_path('valid-content.json')
548+
with self.assertRaises(ValueError):
549+
IODict.from_xml(filepath)
550+
filepath = self.input_path('valid-content.qs')
539551
with self.assertRaises(ValueError):
540552
IODict.from_xml(filepath)
541553
filepath = self.input_path('valid-content.toml')
@@ -663,6 +675,9 @@ def test_from_yaml_with_valid_file_valid_content_invalid_format(self):
663675
# filepath = self.input_path('valid-content.json')
664676
# with self.assertRaises(ValueError):
665677
# IODict.from_yaml(filepath)
678+
filepath = self.input_path('valid-content.qs')
679+
with self.assertRaises(ValueError):
680+
IODict.from_yaml(filepath)
666681
filepath = self.input_path('valid-content.toml')
667682
with self.assertRaises(ValueError):
668683
IODict.from_yaml(filepath)

0 commit comments

Comments
 (0)