Ejemplo n.º 1
0
    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'))
Ejemplo n.º 2
0
 def test_no_json_object(self):
     with self.assertRaises(exceptions.RepositoryJSONContentException):
         repositories.JSONContentRepository('not_json_content')
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    def test_find_one_wrong_key(self):
        repo = repositories.JSONContentRepository(self.MOCK_CONTENT)
        val = repo.find_one('wrong_key')

        self.assertIsNone(val)
Ejemplo n.º 5
0
    def test_find_all(self):
        repo = repositories.JSONContentRepository(self.MOCK_CONTENT)
        data = repo.find_all()

        self.assertEqual({'key': 'value'}, data)
Ejemplo n.º 6
0
    def test_find_one(self):
        repo = repositories.JSONContentRepository(self.MOCK_CONTENT)
        val = repo.find_one('key')

        self.assertEqual('value', val)
Ejemplo n.º 7
0
 def test_constructor_validation(self):
     with self.assertRaises(exceptions.RepositoryDataTypeException):
         repositories.JSONContentRepository({})
Ejemplo n.º 8
0
    def test_constructor(self):
        repo = repositories.JSONContentRepository(self.MOCK_CONTENT)

        self.assertEqual(repo.content, self.MOCK_CONTENT)