def test_upper_case_sensitivity(self): repo = repositories.JSONContentRepository( self.MOCK_CONTENT_UPPER_CASE ) val = repo.find_one('UPPER_CASE_KEY') self.assertEqual('upper_case_value', val) self.assertIsNone(repo.find_one('upper_case_key'))
def test_no_json_object(self): with self.assertRaises(exceptions.RepositoryJSONContentException): repositories.JSONContentRepository('not_json_content')
def test_reload_content(self): repo = repositories.JSONContentRepository(self.MOCK_CONTENT) repo.content = '{"new_key": "new_value"}' data = repo.find_all() self.assertEqual({'new_key': 'new_value'}, data)
def test_find_one_wrong_key(self): repo = repositories.JSONContentRepository(self.MOCK_CONTENT) val = repo.find_one('wrong_key') self.assertIsNone(val)
def test_find_all(self): repo = repositories.JSONContentRepository(self.MOCK_CONTENT) data = repo.find_all() self.assertEqual({'key': 'value'}, data)
def test_find_one(self): repo = repositories.JSONContentRepository(self.MOCK_CONTENT) val = repo.find_one('key') self.assertEqual('value', val)
def test_constructor_validation(self): with self.assertRaises(exceptions.RepositoryDataTypeException): repositories.JSONContentRepository({})
def test_constructor(self): repo = repositories.JSONContentRepository(self.MOCK_CONTENT) self.assertEqual(repo.content, self.MOCK_CONTENT)