2009-02-16 21:58:44 +00:00
|
|
|
|
|
|
|
# Test the NoNetworkGrid test harness
|
|
|
|
|
|
|
|
from twisted.trial import unittest
|
|
|
|
from twisted.application import service
|
|
|
|
from allmydata.test.no_network import NoNetworkGrid
|
|
|
|
from allmydata.immutable.upload import Data
|
2009-12-01 22:44:35 +00:00
|
|
|
from allmydata.util.consumer import download_to_data
|
2009-02-16 21:58:44 +00:00
|
|
|
|
|
|
|
class Harness(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.s = service.MultiService()
|
|
|
|
self.s.startService()
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
return self.s.stopService()
|
|
|
|
|
|
|
|
def test_create(self):
|
|
|
|
basedir = "no_network/Harness/create"
|
|
|
|
g = NoNetworkGrid(basedir)
|
|
|
|
g.startService()
|
|
|
|
return g.stopService()
|
|
|
|
|
|
|
|
def test_upload(self):
|
|
|
|
basedir = "no_network/Harness/upload"
|
|
|
|
g = NoNetworkGrid(basedir)
|
|
|
|
g.setServiceParent(self.s)
|
|
|
|
|
|
|
|
c0 = g.clients[0]
|
|
|
|
DATA = "Data to upload" * 100
|
|
|
|
data = Data(DATA, "")
|
|
|
|
d = c0.upload(data)
|
|
|
|
def _uploaded(res):
|
|
|
|
n = c0.create_node_from_uri(res.uri)
|
2009-12-01 22:44:35 +00:00
|
|
|
return download_to_data(n)
|
2009-02-16 21:58:44 +00:00
|
|
|
d.addCallback(_uploaded)
|
|
|
|
def _check(res):
|
|
|
|
self.failUnlessEqual(res, DATA)
|
|
|
|
d.addCallback(_check)
|
|
|
|
|
|
|
|
return d
|
|
|
|
|