Commit 1f273c26 authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Łukasz Nowak

test: Import once

It will make further testing much easier
parent d48b47a4
......@@ -45,10 +45,8 @@ from cryptography.x509.oid import NameOID
import caucase.cli
import caucase.http
from cli import getter
from cli import http
from cli import updater
from updater import Updater
import cli
import updater
@contextlib.contextmanager
......@@ -216,7 +214,7 @@ class KedifaMixinCaucase(KedifaMixin):
self.pidfile = os.path.join(self.testdir, 'kedifa.pid')
port = '16080'
self.kedifa_runtime = multiprocessing.Process(
target=http,
target=cli.http,
args=(
'--ip', ip,
'--port', port,
......@@ -288,7 +286,7 @@ class KedifaMixinCaucase(KedifaMixin):
class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
def _getter_get(self, url, certificate, destination):
getter(
cli.getter(
url,
'--out', destination,
'--server-ca-certificate', self.ca_crt_pem,
......@@ -311,7 +309,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
mapping.close()
state = tempfile.NamedTemporaryFile(dir=self.testdir, delete=False)
state.close()
updater(
cli.updater(
'--once',
'--server-ca-certificate', self.ca_crt_pem,
'--identity', certificate,
......@@ -1111,44 +1109,51 @@ class KedifaUpdaterMixin(KedifaMixin):
class KedifaUpdaterMappingTest(KedifaUpdaterMixin, unittest.TestCase):
def test_updateMapping_empty(self):
self.setupMapping()
u = Updater(1, self.mapping, self.state, None, None, None, None, True)
u = updater.Updater(1, self.mapping, self.state, None, None, None, None,
True)
u.updateMapping()
self.assertEqual(u.mapping, {})
def test_updateMapping_normal(self):
self.setupMapping('url file')
u = Updater(1, self.mapping, self.state, None, None, None, None, True)
u = updater.Updater(1, self.mapping, self.state, None, None, None, None,
True)
u.updateMapping()
self.assertEqual(u.mapping, {'file': ('url', None)})
def test_updateMapping_morewhite(self):
self.setupMapping('url \t file')
u = Updater(1, self.mapping, self.state, None, None, None, None, True)
u = updater.Updater(1, self.mapping, self.state, None, None, None, None,
True)
u.updateMapping()
self.assertEqual(u.mapping, {'file': ('url', None)})
def test_updateMapping_one_empty(self):
self.setupMapping('url file\n \n')
u = Updater(1, self.mapping, self.state, None, None, None, None, True)
u = updater.Updater(1, self.mapping, self.state, None, None, None, None,
True)
u.updateMapping()
self.assertEqual(u.mapping, {'file': ('url', None)})
def test_updateMapping_one_not_enough(self):
self.setupMapping('url file\nbuzz\n')
u = Updater(1, self.mapping, self.state, None, None, None, None, True)
u = updater.Updater(1, self.mapping, self.state, None, None, None, None,
True)
u.updateMapping()
self.assertEqual(u.mapping, {'file': ('url', None)})
def test_updateMapping_with_fallback(self):
self.setupMapping('url file\nbuzz oink fallback\n')
u = Updater(1, self.mapping, self.state, None, None, None, None, True)
u = updater.Updater(1, self.mapping, self.state, None, None, None, None,
True)
u.updateMapping()
self.assertEqual(
u.mapping, {'file': ('url', None), 'oink': ('buzz', 'fallback')})
def test_updateMapping_one_comment(self):
self.setupMapping('url file\n#buzz uff\n')
u = Updater(1, self.mapping, self.state, None, None, None, None, True)
u = updater.Updater(1, self.mapping, self.state, None, None, None, None,
True)
u.updateMapping()
self.assertEqual(u.mapping, {'file': ('url', None)})
......@@ -1175,13 +1180,13 @@ class KedifaUpdaterUpdateCertificateTest(
if fallback_file:
mapping = '%s %s' % (mapping, fallback_file.name)
self.setupMapping(mapping)
u = Updater(
u = updater.Updater(
1, self.mapping, self.state, '/master/certificate/file', None, None,
None, True)
u.updateMapping()
u.readState()
with mock.patch.object(
Updater, 'fetchCertificate', return_value=fetch):
updater.Updater, 'fetchCertificate', return_value=fetch):
result = u.updateCertificate(self.certificate_file_name, master_content)
u.writeState()
return open(self.certificate_file_name, 'r').read(), result
......
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