SND@LHC Software
Loading...
Searching...
No Matches
test_factory.py
Go to the documentation of this file.
1""" This module tests the factory. """
2import os
3import pytest
4import yaml
5
6from ..factory import APIFactory
7from ..databases.mongodb.mongodbadapter import MongoToCDBAPIAdapter
8
9
10@pytest.fixture
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
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
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")
This class creates an instance of the specified database API.
Definition factory.py:15