예제 #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'))
예제 #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'
예제 #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)
def get_config() -> Config:
    return get_context().get(Config)
def get_backup_io() -> BackupIo:
    return get_context().get(BackupIo)
def get_magic_color_svg() -> MagicColorSvg:
    return get_context().get(MagicColorSvg)
def get_map_set_directory() -> MapSetDirectory:
    return get_context().get(MapSetDirectory)
def get_map_set_manager() -> MapSetManager:
    return get_context().get(MapSetManager)
예제 #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)
 def __init__(self, ctx: DepContext = get_context()):
     self._map_set_io: MapSetIO = ctx.get(MapSetIO)
     self._data: Dict[UUID, ManagedMapSet] = {}
예제 #13
0
 def __init__(self, ctx: DepContext = get_context()):
     self._config: Config = ctx.get(Config)
예제 #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)