Commit a8b6de0e authored by Łukasz Nowak's avatar Łukasz Nowak

Do online tests against real shacache server.

parent ab75ae2f
import unittest
import tempfile
import hashlib
import os
import random
import tempfile
import unittest
from slapos.libnetworkcache import NetworkcacheClient
from slapos.signature import parseArgument, \
createPrivateKeyAndCertificateFile
......@@ -29,8 +31,24 @@ class OnlineTest(unittest.TestCase):
nc.upload(content)
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)
nc.download('sha512sum')
# upload them
nc.upload(test_data)
# now try to download them
result = nc.download(shasum)
# is it correctly downloaded
self.assertEqual(result.read(), 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