本文整理汇总了Python中axiom.substore.SubStore.createNew方法的典型用法代码示例。如果您正苦于以下问题:Python SubStore.createNew方法的具体用法?Python SubStore.createNew怎么用?Python SubStore.createNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类axiom.substore.SubStore
的用法示例。
在下文中一共展示了SubStore.createNew方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_upgradeStoreRecursing
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def test_upgradeStoreRecursing(self):
"""
L{Upgrade} upgrades L{Item}s in substores.
"""
choose(oldapp)
ss1 = SubStore.createNew(self.store, ['a'])
ss2 = SubStore.createNew(self.store, ['b'])
swordIDs = [
(ss1.storeID, oldapp.Sword(store=ss1.open(), name='foo').storeID),
(ss2.storeID, oldapp.Sword(store=ss2.open(), name='bar').storeID)]
del ss1, ss2
self.store.close()
choose(deleteswordapp)
self.store = store.Store(self.dbdir)
cmd = Upgrade()
cmd.parent = CommandStub(self.store, 'upgrade')
callWithStdoutRedirect(cmd.parseOptions, [])
for (ssid, swordID) in swordIDs:
self.assertRaises(
KeyError,
self.store.getItemByID(ssid).open().getItemByID, swordID)
示例2: setUp
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def setUp(self):
"""
Set up stores and an offering.
"""
store = Store(dbdir=self.mktemp())
appStore1 = SubStore.createNew(store, ("app", "test1.axiom"))
appStore2 = SubStore.createNew(store, ("app", "test2.axiom"))
self.firstOffering = Offering(u'first offering', None, None, None, None,
None, [])
firstInstalledOffering = InstalledOffering(
store=store, application=appStore1,
offeringName=self.firstOffering.name)
ss1 = appStore1.open()
self.installApp(ss1)
# (bypass Item.__setattr__)
object.__setattr__(
firstInstalledOffering, 'getOffering',
lambda: self.firstOffering)
secondOffering = Offering(u'second offering', None, None, None, None,
None, [])
secondInstalledOffering = InstalledOffering(
store=store, application=appStore2,
offeringName=secondOffering.name)
# (bypass Item.__setattr__)
object.__setattr__(secondInstalledOffering, 'getOffering',
lambda: secondOffering)
self.fragment = _OfferingsFragment(FrontPage(store=store))
示例3: testAvatarStoreState
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def testAvatarStoreState(self):
"""
You can only pass an 'avatars' argument if it doesn't already have an
account in it. Some accounts want to have their stores in slightly odd
places (like offering.py) but you can't have two accounts added which
both point to the same store.
"""
dbdir = FilePath(self.mktemp())
s = Store(dbdir)
ls = userbase.LoginSystem(store=s)
dependency.installOn(ls, s)
acc = ls.addAccount('alice', 'dom.ain', 'password')
# this is allowed, if weird
unrelatedAccount = ls.addAccount(
'elseice', 'dom.ain', 'password',
avatars=SubStore.createNew(s, ('crazy', 'what')))
# this is not allowed.
self.assertRaises(errors.DuplicateUniqueItem,
ls.addAccount,
'bob', 'ain.dom', 'xpassword',
avatars=acc.avatars)
# Make sure that our stupid call to addAccount did not corrupt
# anything, because we are stupid
self.assertEqual(acc.avatars.open().query(userbase.LoginAccount).count(), 1)
示例4: test_subSchedule
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def test_subSchedule(self):
"""
The same as test_schedule, except using a subscheduler.
"""
subst = SubStore.createNew(self.store, ['scheduler_test'])
substore = subst.open()
subscheduler = IScheduler(substore)
return self._testSchedule(subscheduler)
示例5: test_requiresFromSite
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def test_requiresFromSite(self):
"""
The value of a L{axiom.dependency.requiresFromSite} descriptor ought to
be the powerup on the site for the instance it describes.
"""
dependency.installOn(RealGrid(store=self.store), self.store)
substore = SubStore.createNew(self.store, ['sub']).open()
self.assertEquals(PowerStrip(store=substore).draw(1), REAL_POWER)
示例6: setUp
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def setUp(self):
self.spath = filepath.FilePath(self.mktemp() + ".axiom")
self.store = Store(self.spath)
self.substoreitem = SubStore.createNew(self.store,
["sub.axiom"])
self.substore = self.substoreitem.open()
# Not available yet.
self.substore.attachToParent()
示例7: setUp
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def setUp(self):
"""
Set up the tests by creating a store and a substore and opening them both.
"""
self.topdb = topdb = Store(filepath.FilePath(self.mktemp()))
self.ssitem = ssitem = SubStore.createNew(
topdb, ["dontstartme", "really"])
self.ss = ssitem.open()
self.serviceStarted = False
示例8: test_requiresFromSiteNoDefault
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def test_requiresFromSiteNoDefault(self):
"""
The default function shouldn't be needed or invoked if its value isn't
going to be used.
"""
dependency.installOn(RealGrid(store=self.store), self.store)
substore = SubStore.createNew(self.store, ['sub']).open()
self.assertEquals(SpecifiedBadDefaults(store=substore).pump(),
REAL_POWER)
示例9: test_requiresFromSiteDefault
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def test_requiresFromSiteDefault(self):
"""
The value of a L{axiom.dependency.requiresFromSite} descriptor on an
item in a user store ought to be the result of invoking its default
factory parameter.
"""
substore = SubStore.createNew(self.store, ['sub']).open()
ps = PowerStrip(store=substore)
self.assertEquals(ps.draw(1), FAKE_POWER)
self.assertEquals(ps.grid.siteStore, self.store)
示例10: openStore
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def openStore(self):
self.currentTopStore = store.Store(self.topdbdir)
if self.subStoreID is not None:
self.currentSubStore = self.currentTopStore.getItemByID(self.subStoreID).open()
else:
ss = SubStore.createNew(self.currentTopStore,
['sub'])
self.subStoreID = ss.storeID
self.currentSubStore = ss.open()
return self.currentSubStore
示例11: createDatabase
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def createDatabase(s):
"""
Create a store which contains a substore-service-starter item powered up
for IService, and a substore, which contains a service that should not be
started after the upgrader runs.
"""
ssi = SubStore.createNew(s, ["sub", "test"])
ss = ssi.open()
ds = DummyService(store=ss)
ss.powerUp(ds, IService)
ssss = SubStoreStartupService(store=s).installOn(s)
示例12: test_listOffering
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def test_listOffering(self):
"""
Mantissa offerings are added as users with a 'username' but no domain.
Check that the 'list' command prints these correctly.
"""
name = 'offering-name'
self.userbase('install')
realm = IRealm(self.store)
substoreItem = SubStore.createNew(self.store, ('app', name))
realm.addAccount(name, None, None, internal=True,
avatars=substoreItem)
output = self.userbase('list')
self.assertEqual(output, [name])
示例13: test_memorySubstoreFile
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def test_memorySubstoreFile(self):
"""
In-memory substores whose stores have file directories should be able
to create files.
"""
filesdir = filepath.FilePath(self.mktemp())
s = Store(filesdir=filesdir)
ss = SubStore.createNew(s, ['account', '[email protected]'])
s2 = ss.open()
f = s2.newFile("test.txt")
f.write("yay")
f.close()
self.assertEqual(open(f.finalpath.path).read(), "yay")
示例14: test_requiresFromSiteUnspecifiedException
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def test_requiresFromSiteUnspecifiedException(self):
"""
If a default factory function isn't supplied, an
L{UnsatisfiedRequirement}, which should be a subtype of
L{AttributeError}, should be raised when the descriptor is retrieved.
"""
lung = IronLung(store=self.store)
siteLung = IronLung(
store=SubStore.createNew(self.store, ['sub']).open())
self.assertRaises(UnsatisfiedRequirement, lambda : lung.grid)
self.assertRaises(UnsatisfiedRequirement, lambda : siteLung.grid)
default = object()
self.assertIdentical(getattr(lung, 'grid', default), default)
示例15: setUp
# 需要导入模块: from axiom.substore import SubStore [as 别名]
# 或者: from axiom.substore.SubStore import createNew [as 别名]
def setUp(self):
"""
Create a site store for the substore which will contain the IScheduler
being tested. Start its IService so any scheduled events will run.
"""
self.storePath = filepath.FilePath(self.mktemp())
self.siteStore = Store(self.storePath)
super(SubSchedulerTests, self).setUp()
substoreItem = SubStore.createNew(self.siteStore, ['scheduler_test'])
self.substore = substoreItem.open()
self.scheduler = scheduler = IScheduler(self.substore)
self.stubTime(scheduler)
self.store = self.substore