Commit 07629dce authored by Tomáš Peterka's avatar Tomáš Peterka Committed by Rafael Monnerat

[test] Pass Logger instead of Handler as a logger

parent 9da1f41e
...@@ -239,6 +239,9 @@ class SlapformatMixin(unittest.TestCase): ...@@ -239,6 +239,9 @@ class SlapformatMixin(unittest.TestCase):
self.test_result = TestLoggerHandler() self.test_result = TestLoggerHandler()
logger.addHandler(self.test_result) logger.addHandler(self.test_result)
config.logger = logger config.logger = logger
if hasattr(self, "logger"):
raise ValueError("{} already has logger attached".format(self.__class__.__name__))
self.logger = logger
self.partition = slapos.format.Partition('partition', '/part_path', self.partition = slapos.format.Partition('partition', '/part_path',
slapos.format.User('testuser'), [], None) slapos.format.User('testuser'), [], None)
global USER_LIST global USER_LIST
...@@ -281,7 +284,7 @@ class TestComputer(SlapformatMixin): ...@@ -281,7 +284,7 @@ class TestComputer(SlapformatMixin):
@unittest.skip("Not implemented") @unittest.skip("Not implemented")
def test_construct_empty_prepared(self): def test_construct_empty_prepared(self):
computer = slapos.format.Computer('computer', computer = slapos.format.Computer('computer',
interface=slapos.format.Interface(logger=self.test_result, interface=slapos.format.Interface(logger=self.logger,
name='bridge', name='bridge',
ipv4_local_network='127.0.0.1/16')) ipv4_local_network='127.0.0.1/16'))
computer.instance_root = '/instance_root' computer.instance_root = '/instance_root'
...@@ -302,7 +305,7 @@ class TestComputer(SlapformatMixin): ...@@ -302,7 +305,7 @@ class TestComputer(SlapformatMixin):
def test_construct_empty_prepared_no_alter_user(self): def test_construct_empty_prepared_no_alter_user(self):
computer = slapos.format.Computer('computer', computer = slapos.format.Computer('computer',
interface=slapos.format.Interface(logger=self.test_result, interface=slapos.format.Interface(logger=self.logger,
name='bridge', name='bridge',
ipv4_local_network='127.0.0.1/16')) ipv4_local_network='127.0.0.1/16'))
computer.instance_root = '/instance_root' computer.instance_root = '/instance_root'
...@@ -319,7 +322,7 @@ class TestComputer(SlapformatMixin): ...@@ -319,7 +322,7 @@ class TestComputer(SlapformatMixin):
@unittest.skip("Not implemented") @unittest.skip("Not implemented")
def test_construct_empty_prepared_no_alter_network(self): def test_construct_empty_prepared_no_alter_network(self):
computer = slapos.format.Computer('computer', computer = slapos.format.Computer('computer',
interface=slapos.format.Interface(logger=self.test_result, interface=slapos.format.Interface(logger=self.logger,
name='bridge', name='bridge',
ipv4_local_network='127.0.0.1/16')) ipv4_local_network='127.0.0.1/16'))
computer.instance_root = '/instance_root' computer.instance_root = '/instance_root'
...@@ -340,7 +343,7 @@ class TestComputer(SlapformatMixin): ...@@ -340,7 +343,7 @@ class TestComputer(SlapformatMixin):
def test_construct_empty_prepared_no_alter_network_user(self): def test_construct_empty_prepared_no_alter_network_user(self):
computer = slapos.format.Computer('computer', computer = slapos.format.Computer('computer',
interface=slapos.format.Interface(logger=self.test_result, interface=slapos.format.Interface(logger=self.logger,
name='bridge', name='bridge',
ipv4_local_network='127.0.0.1/16')) ipv4_local_network='127.0.0.1/16'))
computer.instance_root = '/instance_root' computer.instance_root = '/instance_root'
...@@ -359,7 +362,7 @@ class TestComputer(SlapformatMixin): ...@@ -359,7 +362,7 @@ class TestComputer(SlapformatMixin):
@unittest.skip("Not implemented") @unittest.skip("Not implemented")
def test_construct_prepared(self): def test_construct_prepared(self):
computer = slapos.format.Computer('computer', computer = slapos.format.Computer('computer',
interface=slapos.format.Interface(logger=self.test_result, interface=slapos.format.Interface(logger=self.logger,
name='bridge', name='bridge',
ipv4_local_network='127.0.0.1/16')) ipv4_local_network='127.0.0.1/16'))
computer.instance_root = '/instance_root' computer.instance_root = '/instance_root'
...@@ -405,7 +408,7 @@ class TestComputer(SlapformatMixin): ...@@ -405,7 +408,7 @@ class TestComputer(SlapformatMixin):
def test_construct_prepared_no_alter_user(self): def test_construct_prepared_no_alter_user(self):
computer = slapos.format.Computer('computer', computer = slapos.format.Computer('computer',
interface=slapos.format.Interface(logger=self.test_result, interface=slapos.format.Interface(logger=self.logger,
name='bridge', name='bridge',
ipv4_local_network='127.0.0.1/16')) ipv4_local_network='127.0.0.1/16'))
computer.instance_root = '/instance_root' computer.instance_root = '/instance_root'
...@@ -498,7 +501,7 @@ class TestComputer(SlapformatMixin): ...@@ -498,7 +501,7 @@ class TestComputer(SlapformatMixin):
@unittest.skip("Not implemented") @unittest.skip("Not implemented")
def test_construct_prepared_no_alter_network(self): def test_construct_prepared_no_alter_network(self):
computer = slapos.format.Computer('computer', computer = slapos.format.Computer('computer',
interface=slapos.format.Interface(logger=self.test_result, interface=slapos.format.Interface(logger=self.logger,
name='bridge', name='bridge',
ipv4_local_network='127.0.0.1/16')) ipv4_local_network='127.0.0.1/16'))
computer.instance_root = '/instance_root' computer.instance_root = '/instance_root'
...@@ -540,7 +543,7 @@ class TestComputer(SlapformatMixin): ...@@ -540,7 +543,7 @@ class TestComputer(SlapformatMixin):
def test_construct_prepared_no_alter_network_user(self): def test_construct_prepared_no_alter_network_user(self):
computer = slapos.format.Computer('computer', computer = slapos.format.Computer('computer',
interface=slapos.format.Interface(logger=self.test_result, interface=slapos.format.Interface(logger=self.logger,
name='bridge', name='bridge',
ipv4_local_network='127.0.0.1/16')) ipv4_local_network='127.0.0.1/16'))
computer.instance_root = '/instance_root' computer.instance_root = '/instance_root'
...@@ -581,7 +584,7 @@ class TestComputer(SlapformatMixin): ...@@ -581,7 +584,7 @@ class TestComputer(SlapformatMixin):
global USER_LIST global USER_LIST
USER_LIST = ['root'] USER_LIST = ['root']
computer = slapos.format.Computer('computer', computer = slapos.format.Computer('computer',
interface=slapos.format.Interface(logger=self.test_result, interface=slapos.format.Interface(logger=self.logger,
name='myinterface', name='myinterface',
ipv4_local_network='127.0.0.1/16')) ipv4_local_network='127.0.0.1/16'))
computer.instance_root = '/instance_root' computer.instance_root = '/instance_root'
......
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