本文整理汇总了Python中axiom.substore.SubStore类的典型用法代码示例。如果您正苦于以下问题:Python SubStore类的具体用法?Python SubStore怎么用?Python SubStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SubStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_upgradeStoreRecursing
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
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
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
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
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: test_requiresFromSiteNoDefault
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)
示例7: setUp
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()
示例8: setUp
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
示例9: test_requiresFromSiteDefault
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
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
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
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_requiresFromSiteUnspecifiedException
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)
示例14: test_memorySubstoreFile
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")
示例15: insertUserStore
def insertUserStore(siteStore, userStorePath):
"""
Move the SubStore at the indicated location into the given site store's
directory and then hook it up to the site store's authentication database.
@type siteStore: C{Store}
@type userStorePath: C{FilePath}
"""
# The following may, but does not need to be in a transaction, because it
# is merely an attempt to guess a reasonable filesystem name to use for
# this avatar. The user store being operated on is expected to be used
# exclusively by this process.
ls = siteStore.findUnique(LoginSystem)
unattachedSubStore = Store(userStorePath)
for lm in unattachedSubStore.query(LoginMethod,
LoginMethod.account == unattachedSubStore.findUnique(LoginAccount),
sort=LoginMethod.internal.descending):
if ls.accountByAddress(lm.localpart, lm.domain) is None:
localpart, domain = lm.localpart, lm.domain
break
else:
raise AllNamesConflict()
unattachedSubStore.close()
insertLocation = siteStore.newFilePath('account', domain, localpart + '.axiom')
insertParentLoc = insertLocation.parent()
if not insertParentLoc.exists():
insertParentLoc.makedirs()
if insertLocation.exists():
raise DatabaseDirectoryConflict()
userStorePath.moveTo(insertLocation)
ss = SubStore(store=siteStore, storepath=insertLocation)
attachedStore = ss.open()
# migrateUp() manages its own transactions because it interacts with two
# different stores.
attachedStore.findUnique(LoginAccount).migrateUp()