SND@LHC Software
Loading...
Searching...
No Matches
test_factory.py
Go to the documentation of this file.
1
""" This module tests the factory. """
2
import
os
3
import
pytest
4
import
yaml
5
6
from
..factory
import
APIFactory
7
from
..databases.mongodb.mongodbadapter
import
MongoToCDBAPIAdapter
8
9
10
@pytest.fixture
11
def
supply_dbAPI
():
12
"""
13
This function creates an instance of the CDB API.
14
This can be used by other functions.
15
"""
16
factory =
APIFactory
()
17
db_api = factory.construct_DB_API()
18
return
db_api
19
20
@pytest.mark.smoke_test
21
def
test_create_mongo_api
():
22
"""
23
This test checks if the factory can create an instance of the API for MongoDB.
24
"""
25
factory =
APIFactory
()
26
db_api = factory.construct_DB_API()
27
assert
isinstance(db_api, MongoToCDBAPIAdapter)
28
29
@pytest.mark.smoke_test
30
def
test_create_unknown_api
():
31
"""
32
This function checks if the factory can raise a proper exception
33
if an unsupported database type is specified in the configuration file.
34
"""
35
factory =
APIFactory
()
36
home_dir = os.getenv(
'FAIRSHIP'
)
37
38
with
pytest.raises(NotImplementedError):
39
assert
factory.construct_DB_API(home_dir +
"/conditionsDatabase/tests/test_config.yml"
)
conditionsDatabase.factory.APIFactory
This class creates an instance of the specified database API.
Definition
factory.py:15
conditionsDatabase.tests.test_factory.test_create_mongo_api
test_create_mongo_api()
Definition
test_factory.py:21
conditionsDatabase.tests.test_factory.supply_dbAPI
supply_dbAPI()
Definition
test_factory.py:11
conditionsDatabase.tests.test_factory.test_create_unknown_api
test_create_unknown_api()
Definition
test_factory.py:30
conditionsDatabase
tests
test_factory.py
Generated by
1.9.8