示例#1
0
    def setUp(self):
        super(TestSQLBackend, self).setUp()

        # get the options from the config
        self.config = testing.setUp()
        self.ini = os.path.join(os.path.dirname(__file__), 'test_sql.ini')
        settings = {}
        load_into_settings(self.ini, settings)
        self.config.add_settings(settings)

        # instantiate the backend to test
        self.config.include("tokenserver")
        load_and_register("tokenserver", self.config)
        self.backend = self.config.registry.getUtility(INodeAssignment)

        # adding a service and a node with 100 slots
        try:
            self.backend.add_service("sync-1.1", "{node}/1.1/{uid}")
        except IntegrityError:
            # ignore if the service was already added by another test.
            pass
        self.backend.add_node("sync-1.1", "https://phx12", 100)

        self._sqlite = self.backend._engine.driver == 'pysqlite'
        endpoints = {}
        load_endpoints(endpoints, self.config)
        get_current_registry()['endpoints_patterns'] = endpoints
示例#2
0
    def setUp(self):
        super(TestCase, self).setUp()

        # get the options from the config
        self.config = testing.setUp()
        self.ini = os.path.join(os.path.dirname(__file__),
                                'test_sql.ini')
        settings = {}
        load_into_settings(self.ini, settings)
        self.config.add_settings(settings)

        # instantiate the backend to test
        self.config.include("tokenserver")
        load_and_register("tokenserver", self.config)
        self.backend = self.config.registry.getUtility(INodeAssignment)

        # adding a node with 100 slots
        self.backend._safe_execute(
              """insert into nodes (`node`, `service`, `available`,
                    `capacity`, `current_load`, `downed`, `backoff`)
                  values ("https://phx12", "sync-1.0", 100, 100, 0, 0, 0)""")
        self.backend._safe_execute(
                """insert into service_pattern
                (`service`, `pattern`)
                values
                ("sync-1.0", "{node}/{version}/{uid}")""")
        self._sqlite = self.backend._engine.driver == 'pysqlite'

        endpoints = {}
        load_endpoints(endpoints, self.config)
        get_current_registry()['endpoints_patterns'] = endpoints
    def setUp(self):
        super(TestSQLBackend, self).setUp()

        # get the options from the config
        self.config = testing.setUp()
        self.ini = os.path.join(os.path.dirname(__file__),
                                'test_sql.ini')
        settings = {}
        load_into_settings(self.ini, settings)
        self.config.add_settings(settings)

        # instantiate the backend to test
        self.config.include("tokenserver")
        load_and_register("tokenserver", self.config)
        self.backend = self.config.registry.getUtility(INodeAssignment)

        # adding a service and a node with 100 slots
        self.backend.add_service("sync-1.0", "{node}/{version}/{uid}")
        self.backend.add_node("sync-1.0", "https://phx12", 100)

        self._sqlite = self.backend._engine.driver == 'pysqlite'
        endpoints = {}
        load_endpoints(endpoints, self.config)
        get_current_registry()['endpoints_patterns'] = endpoints