def config(binder: inject.Binder) -> None:
        if c.use_memory_cache:
            instance = MemoryGameCacheAdapter()
            players = [Player('1', '1', None), Player('2', '2', None)]
            instance.add_new_game(Game(123, players, True, 0))

            binder.bind(GameCacheInterface, instance)
        else:
            binder.bind(GameCacheInterface,
                        DynamoGameCacheAdapter(c.game_dynamo_table))
예제 #2
0
 def configuration(binder: inject.Binder):
     env = os.environ.get('ENV') or "dev"
     if env == "dev":
         binder.bind(TicketRepository, InMemoryTicketRepository())
         binder.bind(AccountRepository, InMemoryAccountRepository())
     elif env == "prod":
         pass
     elif env == "test":
         pass
     else:
         raise ValueError("Invalid env")
예제 #3
0
 def dependencies(binder: inject.Binder) -> None:
     binder.bind(SuiteSplitService, None)
     binder.bind(GenTaskOptions, evg_expansions.gen_task_options())
     binder.bind(EvergreenApi,
                 RetryingEvergreenApi.get_api(config_file=evergreen_config))
     binder.bind(
         GenerationConfiguration,
         GenerationConfiguration.from_yaml_file(GENERATE_CONFIG_FILE))
     binder.bind(
         ResmokeProxyConfig,
         ResmokeProxyConfig(resmoke_suite_dir=DEFAULT_TEST_SUITE_DIR))
예제 #4
0
파일: inject.py 프로젝트: fizmat/ef_python
 def conf(binder: Binder) -> None:
     binder.bind(
         FieldSolver,
         FieldSolverPyamgx if solver == 'amgx' else FieldSolverPyamg)
     if backend == 'cupy':
         import cupy
         binder.bind(ArrayOnGrid, ArrayOnGridCupy)
         binder.bind(numpy, cupy)
     else:
         binder.bind(ArrayOnGrid, ArrayOnGrid)
         binder.bind(numpy, numpy)
예제 #5
0
파일: apps.py 프로젝트: Jumpi96/helpo
def inject_config(binder: inject.Binder) -> None:
    from users.application.repositories import UsersRepository, VolunteerProfilesRepository, \
        SkillsRepository, OrganizationAreasRepository, OrganizationProfilesRepository
    from users.infrastructure.repositories import DjangoORMUsersRepository, \
        DjangoORMVolunteerProfilesRepository, DjangoORMSkillsRepository, \
        DjangoORMOrganizationAreasRepository, DjangoORMOrganizationProfilesRepository

    binder.bind(UsersRepository, DjangoORMUsersRepository())
    binder.bind(VolunteerProfilesRepository, DjangoORMVolunteerProfilesRepository())
    binder.bind(OrganizationProfilesRepository, DjangoORMOrganizationProfilesRepository())
    binder.bind(SkillsRepository, DjangoORMSkillsRepository())
    binder.bind(OrganizationAreasRepository, DjangoORMOrganizationAreasRepository())
예제 #6
0
        def injection_config(binder: inject.Binder):
            binder.bind(plugins.PluginProxy, plugin_proxy)
            binder.bind(thread.ThreadManager, thread_manager)
            binder.bind(journal.JournalReader, journal_reader)

            for cls, obj in plugin_manager._plugins_cls_map.items():
                binder.bind(cls, obj)
예제 #7
0
def configure(binder: inject.Binder) -> None:
    binder.bind(DbConfigProvider, DbConfigProvider(s.VAULT_DB_NAME))
    binder.bind_to_constructor(Db, lambda: SqliteDb())
    binder.bind_to_constructor(SqliteDb, lambda: SqliteDb())
    print(s.DATA_PATH)
    binder.bind(
        DataRepo,
        S3DataRepo() if s.DATA_PATH.startswith("s3") else LocalDataRepo())
예제 #8
0
def check_and_bind(binder: Binder, cls: Type[T], ins: Union[Type[T], T]):
    exp = None
    try:
        is_sub = issubclass(ins, cls)
    except TypeError as e:
        is_sub = False
        exp = e
    try:
        is_ins = isinstance(ins, cls)
    except TypeError as e:
        is_ins = False
        exp = e
    if is_ins or is_sub:
        binder.bind(cls, ins)
    else:
        raise exp or TypeError(
            f"{ins} is neither subclass or instance of {cls}")
예제 #9
0
 def dependencies(binder: inject.Binder) -> None:
     binder.bind(
         EvergreenApi,
         RetryingEvergreenApi.get_api(
             config_file=os.path.expanduser(options.evg_api_config)))
     binder.bind(TimeoutSettings,
                 TimeoutSettings(start_date=start_date, end_date=end_date))
     binder.bind(TimeoutOverrides, timeout_overrides)
     binder.bind(
         EvergreenProjectConfig,
         parse_evergreen_file(os.path.expanduser(
             options.evg_project_config)))
     binder.bind(
         ResmokeProxyService,
         ResmokeProxyService(
             run_options=f"--installDir={shlex.quote(options.install_dir)}")
     )
예제 #10
0
 def config(binder: inject.Binder) -> None:
     binder.bind(RaidRepository, MySQLRaidRepository(
         application.config['DATABASE_URI'],
         application.config['METADATA'],
         application.config['RAID_TABLE']))
     binder.bind(GangRepository, MySQLGangRepository(
         application.config['DATABASE_URI'],
         application.config['METADATA'],
         application.config['GANG_TABLE']))
     binder.bind(OutlawRepository, MySQLOutlawRepository(
         application.config['DATABASE_URI'],
         application.config['METADATA'],
         application.config['OUTLAW_TABLE']))
     binder.bind(MailNotifier, SMTPMailNotifier())
예제 #11
0
    def config(binder: inject.Binder) -> None:
        binder.bind(PlayerCacheInterface,
                    DynamoPlayerCacheAdapter(c.player_table))

        binder.bind(GameCacheInterface,
                    DynamoGameCacheAdapter(c.game_table))

        binder.bind(GameQueueInterface,
                    SQSGameQueueAdapter(c.match_queue_name))
예제 #12
0
    def inject_config(binder: inject.Binder) -> None:
        # Queries
        binder.bind(queries.GettingRssPageQuery,
                    orm_queries.ORMGettingRssPageQuery(session))
        binder.bind(queries.GettingRssPagesQuery,
                    orm_queries.ORMGettingRssPagesQuery(session))

        # Repositories
        binder.bind(repositories.RssPageRepo,
                    orm_repositories.RssPageRepo(session))
예제 #13
0
    def test_bind_provider(self):
        provider = lambda: 123
        binder = Binder()
        binder.bind_to_provider(int, provider)

        assert binder._bindings[int] is provider
예제 #14
0
    def test_bind__duplicate_binding(self):
        binder = Binder()
        binder.bind(int, 123)

        self.assertRaisesRegexp(InjectorException, 'Duplicate binding', binder.bind, int, 456)
예제 #15
0
def configure(binder: inject.Binder) -> None:
    binder.bind(list, [1, 2, 3])
예제 #16
0
 def test_bind_constructor__constructor_required(self):
     binder = Binder()
     self.assertRaisesRegex(InjectorException, "Constructor cannot be None",
                            binder.bind_to_constructor, int, None)
 def dependencies(binder: inject.Binder) -> None:
     binder.bind(EvgExpansions, evg_expansions)
     binder.bind(
         SuiteSplitConfig,
         evg_expansions.build_suite_split_config(start_date, end_date))
     binder.bind(SplitStrategy, greedy_division)
     binder.bind(FallbackStrategy, round_robin_fallback)
     binder.bind(GenTaskOptions,
                 evg_expansions.build_evg_config_gen_options())
     binder.bind(EvergreenApi,
                 RetryingEvergreenApi.get_api(config_file=evg_api_config))
     binder.bind(EvergreenProjectConfig,
                 parse_evergreen_file(evg_project_config))
     binder.bind(GenerationConfiguration,
                 GenerationConfiguration.from_yaml_file())
     binder.bind(ResmokeProxyService,
                 ResmokeProxyService(" ".join(resmoke_run_args)))
예제 #18
0
def inject_config(binder: inject.Binder) -> None:
    binder.bind(EmailGateway, DummyEmailGateway())
    binder.bind(AuctionsRepository, DjangoORMAuctionsRepository())
예제 #19
0
def bind(binder: Binder) -> None:
    binder.bind_to_provider(TaskRepository, TaskRepository)
    binder.bind_to_provider(AuthenticationRepository, AuthenticationRepository)
예제 #20
0
 def config(binder: inject.Binder) -> None:
     from .pdf2text import inject_configuration
     binder.install(inject_configuration)
예제 #21
0
 def config(binder: inject.Binder) -> None:
     binder.bind(GameQueueInterface,
                 SQSGameQueueAdapter(sqs_match_making_queue_name))
예제 #22
0
def configure(binder: inject.Binder) -> None:
    binder.bind(list, [1, 2, 3])
예제 #23
0
 def configure(binder: inject.Binder) -> None:
     binder.bind(UsersRepository, users_repo_mock)
     binder.bind(VolunteerProfilesRepository, volunteer_profiles_repo_mock)
     binder.bind(RemoveUserOutputBoundary, remove_user_output_boundary_mock)
예제 #24
0
    def test_bind_constructor(self):
        constructor = lambda: 123
        binder = Binder()
        binder.bind_to_constructor(int, constructor)

        assert binder._bindings[int]._constructor is constructor
예제 #25
0
 def dependencies(binder: inject.Binder) -> None:
     binder.bind(
         SuiteSplitConfig,
         evg_expansions.get_suite_split_config(start_date, end_date))
     binder.bind(SplitStrategy, greedy_division)
     binder.bind(FallbackStrategy, round_robin_fallback)
     binder.bind(GenTaskOptions,
                 evg_expansions.get_evg_config_gen_options(config_dir))
     binder.bind(EvergreenApi, evg_api)
     binder.bind(
         GenerationConfiguration,
         GenerationConfiguration.from_yaml_file(
             under_test.GENERATE_CONFIG_FILE))
     binder.bind(ResmokeProxyConfig,
                 ResmokeProxyConfig(resmoke_suite_dir=test_suites_dir))
예제 #26
0
    def test_bind(self):
        binder = Binder()
        binder.bind(int, 123)

        assert int in binder._bindings
예제 #27
0
    def test_bind(self):
        binder = Binder()
        binder.bind(int, 123)

        assert int in binder._bindings
예제 #28
0
 def dependencies(binder: inject.Binder) -> None:
     evg_api = RetryingEvergreenApi.get_api(config_file=evg_api_config)
     binder.bind(SuiteSplitConfig, split_task_options)
     binder.bind(SplitStrategy, greedy_division)
     binder.bind(FallbackStrategy, round_robin_fallback)
     binder.bind(EvergreenProjectConfig, evg_conf)
     binder.bind(GenTaskOptions, gen_task_options)
     binder.bind(EvergreenApi, evg_api)
     binder.bind(GenerationConfiguration,
                 GenerationConfiguration.from_yaml_file())
     binder.bind(
         ResmokeProxyConfig,
         ResmokeProxyConfig(resmoke_suite_dir=DEFAULT_TEST_SUITE_DIR))
     binder.bind(EvergreenFileChangeDetector,
                 EvergreenFileChangeDetector(task_id, evg_api))
     binder.bind(BurnInConfig, burn_in_config)
예제 #29
0
def storage_provider_config(binder: inject.Binder):
    binder.bind(Storage, Storage())
예제 #30
0
 def dependencies(binder: inject.Binder) -> None:
     binder.bind(ResmokeProxyService, ResmokeProxyService())
예제 #31
0
 def configure(binder: inject.Binder):
     binder.bind(HaxGlobalState, hax_state)
예제 #32
0
 def dependencies(binder: inject.Binder) -> None:
     binder.bind(EvgExpansions, evg_expansions)
     binder.bind(EvergreenApi, RetryingEvergreenApi.get_api(config_file=evg_api_config))
     binder.bind(EvergreenProjectConfig, parse_evergreen_file(EVERGREEN_FILE))
     binder.bind(SelectedTestsClient, SelectedTestsClient.from_file(selected_tests_config))
     binder.bind(SuiteSplitConfig, evg_expansions.build_suite_split_config(start_date, end_date))
     binder.bind(SplitStrategy, greedy_division)
     binder.bind(FallbackStrategy, round_robin_fallback)
     binder.bind(GenTaskOptions, evg_expansions.build_gen_task_options())
     binder.bind(GenerationConfiguration, GenerationConfiguration.from_yaml_file())
예제 #33
0
 def config(binder: inject.Binder) -> None:
     binder.bind(PlayerCacheInterface,
                 DynamoPlayerCacheAdapter(player_table_name))
예제 #34
0
 def config(binder: inject.Binder):
     binder.bind(PostsRepository, post_repo_mock)
예제 #35
0
    def test_bind_constructor(self):
        constructor = lambda: 123
        binder = Binder()
        binder.bind_to_constructor(int, constructor)

        assert binder._bindings[int]._constructor is constructor