Commit 250554ff authored by Łukasz Nowak's avatar Łukasz Nowak

Setup test date in setUp

parent 68111d76
......@@ -22,6 +22,12 @@ class OnlineTest(unittest.TestCase):
def setUp(self):
self.shacache = 'http://127.0.0.1:8080'
self.shadir = 'http://127.0.0.1:8080'
self.test_data = tempfile.TemporaryFile()
self.test_string = str(random.random())
self.test_data.write(self.test_string)
self.test_data.seek(0)
self.test_shasum = hashlib.sha512(self.test_data.read()).hexdigest()
self.test_data.seek(0)
def test_upload(self):
content = tempfile.TemporaryFile()
......@@ -32,23 +38,17 @@ class OnlineTest(unittest.TestCase):
def test_download(self):
# prepare some test data
test_data = tempfile.TemporaryFile()
test_string = str(random.random())
test_data.write(test_string)
test_data.seek(0)
shasum = hashlib.sha512(test_data.read()).hexdigest()
test_data.seek(0)
nc = NetworkcacheClient(self.shacache, self.shadir)
# upload them
nc.upload(test_data)
nc.upload(self.test_data)
# now try to download them
result = nc.download(shasum)
result = nc.download(self.test_shasum)
# is it correctly downloaded
self.assertEqual(result.read(), test_string)
self.assertEqual(result.read(), self.test_string)
class LibNetworkCacheMixin(unittest.TestCase):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment