Exemple #1
0
def getServiceInfo(**kwargs) -> Dict:
    """Show information about this service.

    Returns:
        Service info object.
    """
    service_info = RegisterServiceInfo()
    return service_info.get_service_info()
Exemple #2
0
    def test_set_service_info_from_config(self):
        """Test for setting service info from config."""
        app = Flask(__name__)
        app.config['FOCA'] = Config(
            db=MongoConfig(**MONGO_CONFIG),
            endpoints=ENDPOINT_CONFIG,
        )
        app.config['FOCA'].db.dbs[DB].collections[coll] \
            .client = mongomock.MongoClient().db.collection

        with app.app_context():
            service_info = RegisterServiceInfo()
            service_info.set_service_info_from_config()
            assert service_info.get_service_info() == SERVICE_INFO_CONFIG
Exemple #3
0
    def test_get_service_info(self):
        """Test for getting service info."""
        app = Flask(__name__)
        app.config['FOCA'] = Config(
            db=MongoConfig(**MONGO_CONFIG),
            endpoints=ENDPOINT_CONFIG,
        )
        mock_resp = deepcopy(SERVICE_INFO_CONFIG)
        app.config['FOCA'].db.dbs[DB].collections[coll] \
            .client = mongomock.MongoClient().db.collection
        app.config['FOCA'].db.dbs[DB].collections[coll] \
            .client.insert_one(mock_resp)

        with app.app_context():
            service_info = RegisterServiceInfo()
            res = service_info.get_service_info()
            assert res == SERVICE_INFO_CONFIG
Exemple #4
0
    def test__upsert_service_info_insert(self):
        """Test for creating service info document in database."""
        app = Flask(__name__)
        app.config['FOCA'] = Config(
            db=MongoConfig(**MONGO_CONFIG),
            endpoints=ENDPOINT_CONFIG,
        )
        app.config['FOCA'].db.dbs[DB].collections[coll] \
            .client = mongomock.MongoClient().db.collection

        data = deepcopy(SERVICE_INFO_CONFIG)
        del data['contactUrl']
        with app.app_context():
            service_info = RegisterServiceInfo()
            service_info._upsert_service_info(data=data)
            assert service_info.get_service_info() == data
            assert service_info.get_service_info() != SERVICE_INFO_CONFIG
Exemple #5
0
    def test_set_service_info_from_config_skip(self):
        """Test for skipping setting service info because identical service
        info is already available.
        """
        app = Flask(__name__)
        app.config['FOCA'] = Config(
            db=MongoConfig(**MONGO_CONFIG),
            endpoints=ENDPOINT_CONFIG,
        )
        mock_resp = deepcopy(SERVICE_INFO_CONFIG)
        app.config['FOCA'].db.dbs[DB].collections[coll] \
            .client = mongomock.MongoClient().db.collection
        app.config['FOCA'].db.dbs[DB].collections[coll] \
            .client.insert_one(mock_resp)

        with app.app_context():
            service_info = RegisterServiceInfo()
            service_info.set_service_info_from_config()
            assert service_info.get_service_info() == SERVICE_INFO_CONFIG