Ejemplo n.º 1
0
def test_dependency_with_missing_register():
    class TestA:
        def __init__(self, message='foo'):
            self._message = message

        def do_something(self):
            return self._message

    class TestB:
        def __init__(self, message='bar', ctx: DepContext = get_context()):
            self._message = message
            self._test_a = ctx.get(TestA)

        def do_something(self):
            return self._test_a.do_something() + self._message

    global_ctx = get_context()
    global_ctx.start()
    with raises(InitializationError):
        global_ctx.register(TestB('xyz'))
Ejemplo n.º 2
0
def test_dependency():
    class TestA:
        def __init__(self, message='foo'):
            self._message = message

        def do_something(self):
            return self._message

    class TestB:
        def __init__(self, message='bar', ctx: DepContext = get_context()):
            self._message = message
            self._test_a = ctx.get(TestA)

        def do_something(self):
            return self._test_a.do_something() + self._message

    global_ctx = get_context()
    global_ctx.start()
    global_ctx.register(TestA('abc'))
    global_ctx.register(TestB('xyz'))
    test_b = global_ctx.get(TestB)
    assert test_b.do_something() == 'abcxyz'
Ejemplo n.º 3
0
 def __init__(self, ctx: DepContext = get_context()):
     self._map_set_path: MapSetPaths = ctx.get(MapSetPaths)
 def __init__(self, ctx: DepContext = get_context()):
     self._cache: Optional[Dict[UUID, str]] = None
     self._map_set_io: MapSetIO = ctx.get(MapSetIO)
Ejemplo n.º 5
0
def get_config() -> Config:
    return get_context().get(Config)
Ejemplo n.º 6
0
def get_backup_io() -> BackupIo:
    return get_context().get(BackupIo)
Ejemplo n.º 7
0
def get_magic_color_svg() -> MagicColorSvg:
    return get_context().get(MagicColorSvg)
Ejemplo n.º 8
0
def get_map_set_directory() -> MapSetDirectory:
    return get_context().get(MapSetDirectory)
Ejemplo n.º 9
0
def get_map_set_manager() -> MapSetManager:
    return get_context().get(MapSetManager)
Ejemplo n.º 10
0
 def __init__(self, message='bar', ctx: DepContext = get_context()):
     self._message = message
     self._test_a = ctx.get(TestA)
 def __init__(self, ctx: DepContext = get_context()):
     self._map_set_io: MapSetIO = ctx.get(MapSetIO)
     self._token_set_io: TokenSetIO = ctx.get(TokenSetIO)
     self._map_set_cache: MapSetCache = ctx.get(MapSetCache)
     self._map_set_directory: MapSetDirectory = ctx.get(MapSetDirectory)
Ejemplo n.º 12
0
 def __init__(self, ctx: DepContext = get_context()):
     self._map_set_io: MapSetIO = ctx.get(MapSetIO)
     self._data: Dict[UUID, ManagedMapSet] = {}
Ejemplo n.º 13
0
 def __init__(self, ctx: DepContext = get_context()):
     self._config: Config = ctx.get(Config)
Ejemplo n.º 14
0
        + 'are also reported by this service.'
    },
    {
        'name':
        'Backup',
        'description':
        'These operations allow to download and upload the complete data of ' +
        'a Background Set. The format of the data (.obm file) is a gzipped TAR file '
        +
        'with mostly JSON and a few binary images inside. Basically the files '
        + 'look like the result of a "tar cfz <file name> ." command in the ' +
        'directory of the Background Set on the server.'
    },
]

ctx = get_context()
ctx.start()
ctx.register(get_config_for_production())

ctx.register(MapSetPaths())
ctx.register(TokenSetIO())
ctx.register(MapSetIO())
ctx.register(BackupIo())

ctx.register(MapSetCache())
ctx.register(MapSetDirectory())
ctx.register(MapSetManager())
ctx.register(MagicColorSvg())

app = FastAPI(openapi_tags=TAGS_META_DATA)