Download backend/tests/test_db_settings.py from jessejohnson/plg4-dev-server: direct link, hf CLI and curl.
- Browser
- Download file 1.69 kB
-
https://huggingface.co/spaces/jessejohnson/plg4-dev-server/resolve/main/backend/tests/test_db_settings.py
- Command line
-
hf download hf://spaces/jessejohnson/plg4-dev-server/backend/tests/test_db_settings.py
-
curl -L -o test_db_settings.py https://huggingface.co/spaces/jessejohnson/plg4-dev-server/resolve/main/backend/tests/test_db_settings.py
1.69 kB
| import unittest | |
| import os | |
| from unittest.mock import patch | |
| from backend.config.database import db_settings | |
| class TestMongoAtlasSettings(unittest.TestCase): | |
| def test_mongo_settings(self): | |
| """ | |
| Test mongodb config contains expected fields when VECTOR_STORE_PROVIDER is set | |
| """ | |
| # reinitialize db_settings instance | |
| db_settings.__init__() | |
| db_config = db_settings.get_vector_store_config() | |
| self.assertTrue('collection_name' in db_config) | |
| self.assertTrue('index_name' in db_config) | |
| self.assertTrue('text_field' in db_config) | |
| class TestChromaDBSettings(unittest.TestCase): | |
| def test_mongo_settings(self): | |
| """ | |
| Test chromadb config contains expected fields when VECTOR_STORE_PROVIDER is set | |
| """ | |
| # reinitialize db_settings instance | |
| db_settings.__init__() | |
| db_config = db_settings.get_vector_store_config() | |
| self.assertTrue('collection_name' in db_config) | |
| self.assertTrue('persist_directory' in db_config) | |
| self.assertTrue('refresh_on_start' in db_config) | |
| class TestInvalidDBSettings(unittest.TestCase): | |
| def test_mongo_settings(self): | |
| """ | |
| Test invalid db config raises correct error | |
| """ | |
| # reinitialize db_settings instance | |
| db_settings.__init__() | |
| with self.assertRaisesRegex(ValueError, "Unsupported"): | |
| db_settings.get_vector_store_config() | |