mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-30 09:48:56 +00:00
Add a test for the success case
This commit is contained in:
parent
a07426b2e9
commit
b604d08463
@ -8,7 +8,6 @@ from twisted.internet import reactor, defer
|
||||
from twisted.application import service
|
||||
from twisted.application.internet import TimerService
|
||||
from twisted.python.filepath import FilePath
|
||||
from twisted.python.failure import Failure
|
||||
from pycryptopp.publickey import rsa
|
||||
|
||||
import allmydata
|
||||
@ -207,7 +206,7 @@ def create_client(basedir=u".", _client_factory=None):
|
||||
_client_factory=_client_factory,
|
||||
)
|
||||
except Exception:
|
||||
return Failure()
|
||||
return defer.fail()
|
||||
|
||||
|
||||
def create_client_from_config(config, _client_factory=None):
|
||||
@ -261,7 +260,7 @@ def create_client_from_config(config, _client_factory=None):
|
||||
storage_broker.setServiceParent(client)
|
||||
return defer.succeed(client)
|
||||
except Exception:
|
||||
return Failure()
|
||||
return defer.fail()
|
||||
|
||||
|
||||
def _sequencer(config):
|
||||
|
@ -1,9 +1,22 @@
|
||||
import os, sys
|
||||
import mock
|
||||
import twisted
|
||||
from yaml import (
|
||||
safe_dump,
|
||||
)
|
||||
from twisted.trial import unittest
|
||||
from twisted.application import service
|
||||
from twisted.internet import defer
|
||||
from twisted.python.filepath import (
|
||||
FilePath,
|
||||
)
|
||||
from testtools.matchers import (
|
||||
Equals,
|
||||
AfterPreprocessing,
|
||||
)
|
||||
from testtools.twistedsupport import (
|
||||
succeeded,
|
||||
)
|
||||
|
||||
import allmydata
|
||||
import allmydata.frontends.magic_folder
|
||||
@ -20,6 +33,9 @@ from allmydata.interfaces import IFilesystemNode, IFileNode, \
|
||||
IImmutableFileNode, IMutableFileNode, IDirectoryNode
|
||||
from foolscap.api import flushEventualQueue
|
||||
import allmydata.test.common_util as testutil
|
||||
from allmydata.test.common import (
|
||||
SyncTestCase,
|
||||
)
|
||||
|
||||
|
||||
BASECONFIG = ("[client]\n"
|
||||
@ -666,6 +682,49 @@ class IntroducerClients(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
class StorageClients(SyncTestCase):
|
||||
"""
|
||||
Tests for storage-related behavior of ``_Client``.
|
||||
"""
|
||||
def test_static_servers(self):
|
||||
"""
|
||||
Storage servers defined in ``private/servers.yaml`` are loaded into the
|
||||
storage broker.
|
||||
"""
|
||||
serverid = u"v0-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
announcement = {
|
||||
u"nickname": 'some-storage-server',
|
||||
u"anonymous-storage-FURL": u"pb://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@tcp:storage.example:100/swissnum",
|
||||
}
|
||||
basedir = FilePath(self.mktemp())
|
||||
private = basedir.child(u"private")
|
||||
private.makedirs()
|
||||
servers = private.child(u"servers.yaml")
|
||||
servers.setContent(safe_dump({
|
||||
u"storage": {
|
||||
serverid: {
|
||||
u"ann": announcement,
|
||||
},
|
||||
},
|
||||
}))
|
||||
def get_known_server_details(a_client):
|
||||
return list(
|
||||
(s.get_serverid(), s.get_announcement())
|
||||
for s
|
||||
in a_client.storage_broker.get_known_servers()
|
||||
)
|
||||
self.assertThat(
|
||||
client.create_client(basedir.asTextMode().path),
|
||||
succeeded(
|
||||
AfterPreprocessing(
|
||||
get_known_server_details,
|
||||
Equals([(serverid, announcement)]),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
class Run(unittest.TestCase, testutil.StallMixin):
|
||||
|
||||
def setUp(self):
|
||||
|
Loading…
Reference in New Issue
Block a user