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
 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}")
 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