Files
feedcrawler/testenv/tests/utilities/testjsonutilities.py
2014-05-18 23:18:01 +02:00

28 lines
855 B
Python

__author__ = 'stubbfel'
import unittest
from utilities.jsonutility import JsonFile
import os.path
class JsonUtilitiesTest(unittest.TestCase):
def setUp(self):
self.__jf = JsonFile("test.json")
self.__jf.check_and_remove_file()
def test_write_json(self):
self.__jf.write_json({1: "4711", "123": "0815"})
self.assertTrue(os.path.isfile("test.json"))
self.__jf.check_and_remove_file()
def test_write_json_returns_error_if_json_object_is_emptystring(self):
self.assertRaises(ValueError, self.__jf.write_json, "")
self.__jf.check_and_remove_file()
def test_write_json_returns_error_if_json_object_is_wrong_json_string(self):
self.assertRaises(ValueError, self.__jf.write_json, "{1}")
self.__jf.check_and_remove_file()
if __name__ == '__main__':
unittest.main()