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

        self.assertIsNone(val)
Exemple #5
0
    def test_find_all(self):
        repo = repositories.JSONContentRepository(self.MOCK_CONTENT)
        data = repo.find_all()

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

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

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