Esempio n. 1
0
    def test_it_fails_on_unexpected_inheretance( self, Internal: MagicMock ):
        Spy = { "preprocessor": "abc" }
        Internal.return_value = Spy
        Locator = ServiceLocator()

        with self.assertRaises( RuntimeError, msg = "Broken dependency at preprocessor" ):
            Locator.get( "preprocessor", int )
Esempio n. 2
0
    def  test_it_fails_if_a_dependency_is_not_statisfied( self, Internal: MagicMock ):
        Spy = { "dep1": "abc" }
        Internal.return_value = Spy
        Locator = ServiceLocator()

        with self.assertRaises( RuntimeError, msg = "Missing dependency preprocessor" ):
            Locator.set( "miner", "abc", [ "dep1", "preprocessor" ] )
Esempio n. 3
0
    def test_it_returns_a_given_value( self, Internal: MagicMock ):
        Spy = { "preprocessor": "abc" }
        Internal.return_value = Spy
        Locator = ServiceLocator()

        self.assertEqual(
            Spy[ "preprocessor" ],
            Locator.get( "preprocessor", str )
        )
Esempio n. 4
0
    def test_it_sets_services( self, Internal: MagicMock ):
        Spy = {}
        Internal.return_value = Spy
        Locator = ServiceLocator()
        Locator.set( "preprocessor", "abc" )

        self.assertDictEqual(
            Spy,
            { "preprocessor": "abc" }
        )
Esempio n. 5
0
 def test_it_fails_on_unknown_service( self, Internal: MagicMock ):
      Spy = {}
      Internal.return_value = Spy
      Locator = ServiceLocator()
      with self.assertRaises( RuntimeError, msg = "Unknown service preprocessor" ):
          Locator.get( 'preprocessor', int )
Esempio n. 6
0
    def test_it_fails_if_a_single_dependency_is_not_statisfied( self ):
        Locator = ServiceLocator()

        with self.assertRaises( RuntimeError, msg = "Missing dependency preprocessor" ):
            Locator.set( "miner", "abc", "preprocessor" )
Esempio n. 7
0
from biomed.preprocessor.cache.sharedMemoryCache import SharedMemoryCache
import biomed.preprocessor.cache.numpyArrayFileCache as NPC
import biomed.preprocessor.polymorph_preprocessor as PP
import biomed.vectorizer.selector.selector_manager as SM
import biomed.vectorizer.std_vectorizer as Vect
import biomed.mlp.mlp_manager as MLP
from biomed.utils.simple_file_writer import SimpleFileWriter
from biomed.utils.json_file_writer import JSONFileWriter
from biomed.utils.csv_file_writer import CSVFileWriter
import biomed.evaluator.std_evaluator as Eval
import biomed.splitter.std_splitter as Split
import biomed.measurer.std_measurer as Measure
from biomed.encoder.std_categorie_encoder import StdCategoriesEncoder
import biomed.text_mining.text_mining_controller as TMC

__Services = ServiceLocator()


def startServices() -> None:
    #independent services
    __Services.set("preprocessor.normalizer.simple",
                   SimpleNormalizer.Factory())

    __Services.set("preprocessor.normalizer.complex",
                   ComplexNormalizer.Factory())

    __Services.set("properties", PropertiesManager())

    __Services.set("preprocessor.cache.shared",
                   SharedMemoryCache.Factory.getInstance())