当前位置: 首页>>代码示例>>Python>>正文


Python locals.Store类代码示例

本文整理汇总了Python中storm.locals.Store的典型用法代码示例。如果您正苦于以下问题:Python Store类的具体用法?Python Store怎么用?Python Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Store类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_generateEmail_with_null_fields

 def test_generateEmail_with_null_fields(self):
     """GenerateEmail works when many fields are NULL."""
     person = self.factory.makePerson(name='person')
     cake = self.factory.makeSourcePackageRecipe(
         name=u'recipe', owner=person)
     pantry_owner = self.factory.makePerson(name='archiveowner')
     pantry = self.factory.makeArchive(name='ppa', owner=pantry_owner)
     secret = self.factory.makeDistroSeries(name=u'distroseries')
     build = self.factory.makeSourcePackageRecipeBuild(
         recipe=cake, distroseries=secret, archive=pantry,
         status=BuildStatus.SUPERSEDED)
     Store.of(build).flush()
     ctrl = self.makeStatusEmail(build)
     self.assertEqual(
         u'[recipe build #%d] of ~person recipe in distroseries: '
         'Build for superseded Source' % (build.id), ctrl.subject)
     body, footer = ctrl.body.split('\n-- \n')
     self.assertEqual(superseded_body, body)
     build_url = canonical_url(build)
     self.assertEqual(
         '%s\nYou are the requester of the build.\n' % build_url, footer)
     self.assertEqual(
         config.canonical.noreply_from_address, ctrl.from_addr)
     self.assertEqual(
         'Requester', ctrl.headers['X-Launchpad-Message-Rationale'])
     self.assertEqual(
         'recipe-build-status',
         ctrl.headers['X-Launchpad-Notification-Type'])
     self.assertEqual(
         'SUPERSEDED', ctrl.headers['X-Launchpad-Build-State'])
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:30,代码来源:test_sourcepackagerecipebuild.py

示例2: bequeathe_flags

def bequeathe_flags(source_message, target_message, incumbents=None):
    """Destroy `source_message`, leaving flags to `target_message`.

    If `source_message` holds the is_current_ubuntu flag, and there are no
    `incumbents` that hold the same flag, then `target_message` inherits
    it.  Similar for the is_current_upstream flag.
    """
    sacrifice_flags(source_message, incumbents)

    if (source_message.is_current_ubuntu and
        not target_message.is_current_ubuntu):
        # Transfer is_current_ubuntu flag.
        source_message.is_current_ubuntu = False
        target_message.is_current_ubuntu = True
        Store.of(source_message).add_flush_order(
            source_message, target_message)

    if (source_message.is_current_upstream and
        not target_message.is_current_upstream):
        # Transfer is_current_upstream flag.
        source_message.is_current_upstream = False
        target_message.is_current_upstream = True
        Store.of(source_message).add_flush_order(
            source_message, target_message)

    source_message.destroySelf()
开发者ID:vitaminmoo,项目名称:unnaturalcode,代码行数:26,代码来源:translationmerger.py

示例3: test_check_unmodifiable_strings

    def test_check_unmodifiable_strings(self):
        # This test case asserts that data migration updates unmodifiable l10n strings
        self._initStartDB(34)

        notification_l10n = NotificationL10NFactory(self.store)

        t0 = notification_l10n.get_val("export_template", "it")

        notification_l10n.set_val("export_template", "it", "")

        t1 = notification_l10n.get_val("export_template", "it")

        self.assertEqual(t1, "")

        self.store.commit()

        # place a dummy version in the current db
        store = Store(create_database(GLSettings.db_uri))
        prv = config.PrivateFactory(store)
        self.dummy_ver = "2.XX.XX"
        prv.set_val("version", self.dummy_ver)
        self.assertEqual(prv.get_val("version"), self.dummy_ver)
        store.commit()
        store.close()

        migration.perform_data_update(self.db_file)

        store = Store(create_database(GLSettings.db_uri))
        notification_l10n = NotificationL10NFactory(store)
        t2 = notification_l10n.get_val("export_template", "it")
        self.assertEqual(t2, t0)
        store.commit()
        store.close()

        shutil.rmtree(GLSettings.db_path)
开发者ID:globaleaks,项目名称:GlobaLeaks,代码行数:35,代码来源:test_migration.py

示例4: delete

 def delete(self):
     """Deletes the exercise, providing it has no associated worksheets."""
     if (self.worksheet_exercises.count() > 0):
         raise IntegrityError()
     for suite in self.test_suites:
         suite.delete()
     Store.of(self).remove(self)
开发者ID:dcoles,项目名称:ivle,代码行数:7,代码来源:database.py

示例5: setUp

    def setUp(self):
        helpers.init_glsettings_for_unit_tests()

        GLSettings.db_path = os.path.join(GLSettings.ramdisk_path, 'db_test')
        os.mkdir(GLSettings.db_path)
        db_name = 'glbackend-%d.db' % DATABASE_VERSION
        db_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'db', 'populated', db_name)
        shutil.copyfile(db_path, os.path.join(GLSettings.db_path, db_name))

        self.db_file = os.path.join(GLSettings.db_path, db_name)
        GLSettings.db_uri = GLSettings.make_db_uri(self.db_file)

        # place a dummy version in the current db
        store = Store(create_database(GLSettings.db_uri))
        prv = config.PrivateFactory(store)
        self.dummy_ver = '2.XX.XX'
        prv.set_val('version', self.dummy_ver)
        self.assertEqual(prv.get_val('version'), self.dummy_ver)
        store.commit()
        store.close()

        # backup various mocks that we will use
        self._bck_f = config.is_cfg_valid
        GLConfig['private']['xx_smtp_password'] = GLConfig['private'].pop('smtp_password')
        self.dp = u'yes_you_really_should_change_me'
开发者ID:Taipo,项目名称:GlobaLeaks,代码行数:25,代码来源:test_migration.py

示例6: initialize

 def initialize(self, debug=None):
     """See `IDatabase`."""
     # Calculate the engine url.
     url = expand(config.database.url, config.paths)
     log.debug('Database url: %s', url)
     # XXX By design of SQLite, database file creation does not honor
     # umask.  See their ticket #1193:
     # http://www.sqlite.org/cvstrac/tktview?tn=1193,31
     #
     # This sucks for us because the mailman.db file /must/ be group
     # writable, however even though we guarantee our umask is 002 here, it
     # still gets created without the necessary g+w permission, due to
     # SQLite's policy.  This should only affect SQLite engines because its
     # the only one that creates a little file on the local file system.
     # This kludges around their bug by "touch"ing the database file before
     # SQLite has any chance to create it, thus honoring the umask and
     # ensuring the right permissions.  We only try to do this for SQLite
     # engines, and yes, we could have chmod'd the file after the fact, but
     # half dozen and all...
     self.url = url
     self._prepare(url)
     database = create_database(url)
     store = Store(database, GenerationalCache())
     database.DEBUG = (as_boolean(config.database.debug)
                       if debug is None else debug)
     self.store = store
     store.commit()
开发者ID:trevor,项目名称:mailman3,代码行数:27,代码来源:base.py

示例7: NCBITaxonomySelector

class NCBITaxonomySelector(object):


    def __init__(self):
        self.__init_database()


    def __init_database(self):    
        """
        creates the sqlite database instance and checks if the database exists in biodb.
        """
        database= create_database("sqlite:%s" % biodb_sql_db_path)
        print "Created storm database from %s." % biodb_sql_db_path
        self.store= Store(database)
        

    def getTaxaByDivisionID(self, div_id):
        return self.store.find(BioDB, \
                (NCBITaxonomyDivision.taxonID == BioDB.id) & \
                (NCBITaxonomyDivision.divisionID == div_id))



    def getDivisionIDByTaxonID(self, tax_id):
        return self.store.find(NCBITaxonomyDivision, NCBITaxonomyDivision.taxonID == tax_id).one().divisionID

    def getDivisionNameByID(self, div_id):
        return self.store.find(NCBIDivision, NCBIDivision.id == div_id).one().name
开发者ID:ecotox,项目名称:biodb,代码行数:28,代码来源:ncbi_taxonomy_selector.py

示例8: take

    def take(self, count):
        """Take some amount of parts from this pile and return the object
        representing this amount. Everything gets copied over."""

        assert count > 0
        assert count <= self.count

        if count == self.count:
            return self

        take = Part()
        take.count = count
        self.count -= count

        take.source = self.source
        take.date = self.date
        take.price = self.price
        take.vat = self.vat
        take.part_type = self.part_type
        take.assignment = self.assignment
        take.history = self.history
        take.soldered = self.soldered
        take.usable = self.usable
        Store.of(self).add(take)

        return take
开发者ID:MarSik,项目名称:elshelves,代码行数:26,代码来源:model.py

示例9: test_version_change_success

    def test_version_change_success(self):
        migration.perform_data_update(self.db_file)

        store = Store(create_database(GLSettings.db_uri))
        prv = config.PrivateFactory(store)
        self.assertEqual(prv.get_val('version'), __version__)
        store.close()
开发者ID:Taipo,项目名称:GlobaLeaks,代码行数:7,代码来源:test_migration.py

示例10: test_getByBuildFarmJobs

 def test_getByBuildFarmJobs(self):
     sprbs = [self.makeSourcePackageRecipeBuild() for i in range(10)]
     Store.of(sprbs[0]).flush()
     self.assertContentEqual(
         sprbs,
         SourcePackageRecipeBuild.getByBuildFarmJobs(
             [sprb.build_farm_job for sprb in sprbs]))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:7,代码来源:test_sourcepackagerecipebuild.py

示例11: _checkValidDatabase

    def _checkValidDatabase(self, storage):
        '''Checks the Store to make sure it has a valid database'''

        store = Store(storage)
        for table in SCHEMA.iterkeys():
            result = store.execute('SELECT * FROM `%s`' % table.lower())
            self.assertEqual(result.get_all(), [])
        return True
开发者ID:tiwilliam,项目名称:entertainer,代码行数:8,代码来源:test_database.py

示例12: __init__

    def __init__(self, table_history, old_db_file, new_db_file, start_ver):
        self.table_history = table_history
        self.old_db_file = old_db_file
        self.new_db_file = new_db_file
        self.start_ver = start_ver

        self.std_fancy = " ł "
        self.debug_info = "   [%d => %d] " % (start_ver, start_ver + 1)

        for k, v in table_history.iteritems():
            # +1 because count start from 0,
            # -8 because the relase befor the 8th are not supported anymore
            length = DATABASE_VERSION + 1 - 8
            if len(v) != length:
                msg = 'Expecting a table with {} statuses ({})'.format(length, k)
                raise TypeError(msg)

        log.msg('{} Opening old DB: {}'.format(self.debug_info, old_db_file))
        old_database = create_database('sqlite:' + self.old_db_file)
        self.store_old = Store(old_database)

        GLSetting.db_file = new_db_file

        new_database = create_database('sqlite:' + new_db_file)
        self.store_new = Store(new_database)

        if self.start_ver + 1 == DATABASE_VERSION:
            log.msg('{} Acquire SQL schema {}'.format(self.debug_info, GLSetting.db_schema_file))

            if not os.access(GLSetting.db_schema_file, os.R_OK):
                log.msg('Unable to access', GLSetting.db_schema_file)
                raise IOError('Unable to access db schema file')

            with open(GLSetting.db_schema_file) as f:
                create_queries = ''.join(f).split(';')
                for create_query in create_queries:
                    try:
                        self.store_new.execute(create_query + ';')
                    except OperationalError:
                        log.msg('OperationalError in "{}"'.format(create_query))
            self.store_new.commit()
            return
            # return here and manage the migrant versions here:

        for k, v in self.table_history.iteritems():

            create_query = self.get_right_sql_version(k, self.start_ver + 1)
            if not create_query:
                # table not present in the version
                continue

            try:
                self.store_new.execute(create_query + ';')
            except OperationalError as excep:
                log.msg('{} OperationalError in [{}]'.format(self.debug_info, create_query))
                raise excep

        self.store_new.commit()
开发者ID:tonegas,项目名称:GlobaLeaks,代码行数:58,代码来源:base_updater.py

示例13: test_ver_change_exception

    def test_ver_change_exception(self):
        # Explicity throw an exception in managed_ver_update via is_cfg_valid
        config.is_cfg_valid = apply_gen(throw_excep)

        self.assertRaises(IOError, migration.perform_data_update, self.db_file)

        store = Store(create_database(GLSettings.db_uri))
        prv = config.PrivateFactory(store)
        self.assertEqual(prv.get_val('version'), self.dummy_ver)
        store.close()
开发者ID:Taipo,项目名称:GlobaLeaks,代码行数:10,代码来源:test_migration.py

示例14: test_binary_builds

 def test_binary_builds(self):
     """The binary_builds property should be populated automatically."""
     spb = self.factory.makeSourcePackageRecipeBuild()
     multiverse = self.factory.makeComponent(name='multiverse')
     spr = self.factory.makeSourcePackageRelease(
         source_package_recipe_build=spb, component=multiverse)
     self.assertEqual([], list(spb.binary_builds))
     binary = self.factory.makeBinaryPackageBuild(spr)
     self.factory.makeBinaryPackageBuild()
     Store.of(binary).flush()
     self.assertEqual([binary], list(spb.binary_builds))
开发者ID:pombreda,项目名称:UnnaturalCodeFork,代码行数:11,代码来源:test_sourcepackagerecipebuild.py

示例15: test_version_change_not_ok

    def test_version_change_not_ok(self):
        # Set is_config_valid to false  during managed ver update
        config.is_cfg_valid = apply_gen(mod_bool)

        self.assertRaises(Exception, migration.perform_data_update, self.db_file)

        # Ensure the rollback has succeeded
        store = Store(create_database(GLSettings.db_uri))
        prv = config.PrivateFactory(store)
        self.assertEqual(prv.get_val('version'), self.dummy_ver)
        store.close()
开发者ID:Taipo,项目名称:GlobaLeaks,代码行数:11,代码来源:test_migration.py


注:本文中的storm.locals.Store类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。