Commit 77c0ffac authored by Jacek Lebioda's avatar Jacek Lebioda
Browse files

Added mocked connection

parent 0b581e42
Pipeline #10726 passed with stage
in 1 minute and 8 seconds
from .abstract import AbstractConnector
from .elasticSearch import ElasticSearchConnector
from .mock import MockConnector
from .variantDB import VariantDBConnector
__all__ = [
'AbstractConnector',
'ElasticSearchConnector',
'MockConnector',
'VariantDBConnector'
]
\ No newline at end of file
# -*- coding: utf-8 -*-
from abc import ABC, abstractmethod
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
......
# -*- coding: utf-8 -*-
from .abstract import AbstractConnector
class MockConnector(AbstractConnector):
"""
Mock connector.
"""
def __init__(self, params: dict):
self._params = params
@staticmethod
def get_id() -> str:
"""
Identifier of this connector
:return:
"""
return "mock"
def connect(self):
"""No need to connect"""
pass
def disconnect(self):
"""No need to disconnect"""
pass
def build_query(self, _: dict) -> dict:
"""No need to do anything"""
return {}
def query(self, query_parameters: dict) -> dict:
"""No need to query, just return an empty dict"""
query_dict = self.build_query(query_parameters)
return query_dict
def translate_response(self, response: str) -> bool:
"""Will always return True"""
return True
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
......@@ -132,3 +131,6 @@ class VariantDBConnector(AbstractConnector):
raise Exception("VariantDB returns invalid response")
responses = response_dict.get("values", [0])
return int(responses[0]) > 0
def test_connection(self):
self._params.get('endpoint')
......@@ -32,5 +32,5 @@ class ConnectorsManagerSuite(TestCase):
def test_discover_and_load_adapters(self):
adapters = self.manager.discover_and_load_adapters()
self.assertEqual(len(adapters), 2, "it should load VariantDB and ES adapters")
self.assertEqual(len(adapters), 3, "it should load VariantDB, ES and mock adapters")
assert 'variant_db' in adapters
......@@ -10,8 +10,8 @@ class End2endSuite(TestCase):
super(End2endSuite, cls).setUpClass()
configuration_file = get_path_to_configuration()
cls.app = create_app(configuration_file,
'../../configuration/beacon_information.yaml',
'../../configuration/connections.yaml')
'../../configuration/templates/beacon_information.yaml',
'../../configuration/connections_ci.yaml')
cls.client = cls.app.test_client()
def test_index(self):
......
---
connectors:
- variant_db
- elastic_search
- mock
data_sources:
- type: mock
id: mock__1
params: []
datasets:
- id: '1'
data_source: mock__1
active: True
- id: '2'
data_source: mock__1
active: True
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment