Commit 3b6cead7 authored by Łukasz Nowak's avatar Łukasz Nowak

Rename variable.

parent 196b6d83
......@@ -8,7 +8,7 @@ import os
import pwd
USER_LIST = []
CALL_AND_READ_LIST = []
EXTERNAL_COMMAND_LIST = []
class FakeConfig:
pass
......@@ -25,8 +25,8 @@ def fakeCallAndRead(argument_list, raise_on_error=True):
if 'useradd' in argument_list:
global USER_LIST
USER_LIST.append(argument_list[-1])
global CALL_AND_READ_LIST
CALL_AND_READ_LIST.append(argument_list)
global EXTERNAL_COMMAND_LIST
EXTERNAL_COMMAND_LIST.append(argument_list)
return 0, 'UP'
class LoggableWrapper:
......@@ -108,9 +108,9 @@ class SlapformatMixin(unittest.TestCase):
config.logger = logger
self.partition = slapos.format.Partition('partition', '/part_path',
slapos.format.User('testuser'), [], None)
global CALL_AND_READ_LIST
global EXTERNAL_COMMAND_LIST
global USER_LIST
CALL_AND_READ_LIST = []
EXTERNAL_COMMAND_LIST = []
USER_LIST = ['testuser']
self.real_callAndRead = slapos.format.callAndRead
......@@ -123,9 +123,9 @@ class SlapformatMixin(unittest.TestCase):
self.restoreOs()
self.restoreGrp()
self.restorePwd()
global CALL_AND_READ_LIST
global EXTERNAL_COMMAND_LIST
global USER_LIST
CALL_AND_READ_LIST = []
EXTERNAL_COMMAND_LIST = []
USER_LIST = ['testuser']
slapos.format.callAndRead = self.real_callAndRead
......@@ -151,13 +151,13 @@ class TestComputer(SlapformatMixin):
"chown('/software_root', 0, 0)",
"chmod('/software_root', 493)"],
self.test_result.bucket)
global CALL_AND_READ_LIST
global EXTERNAL_COMMAND_LIST
self.assertEqual([
['ip', 'addr', 'list', 'bridge'],
['groupadd', 'slapsoft'],
['useradd', '-d', '/software_root', '-g', 'slapsoft', '-s',
'/bin/false', 'slapsoft']],
CALL_AND_READ_LIST)
EXTERNAL_COMMAND_LIST)
def test_construct_empty_prepared_no_alter_user(self):
computer = slapos.format.Computer('computer',
......@@ -170,10 +170,10 @@ class TestComputer(SlapformatMixin):
"makedirs('/software_root', 493)",
"chmod('/software_root', 493)"],
self.test_result.bucket)
global CALL_AND_READ_LIST
global EXTERNAL_COMMAND_LIST
self.assertEqual([
['ip', 'addr', 'list', 'bridge'],],
CALL_AND_READ_LIST)
EXTERNAL_COMMAND_LIST)
def test_construct_empty_prepared_no_alter_network(self):
computer = slapos.format.Computer('computer',
......@@ -187,13 +187,13 @@ class TestComputer(SlapformatMixin):
"chown('/software_root', 0, 0)",
"chmod('/software_root', 493)"],
self.test_result.bucket)
global CALL_AND_READ_LIST
global EXTERNAL_COMMAND_LIST
self.assertEqual([
['ip', 'addr', 'list', 'bridge'],
['groupadd', 'slapsoft'],
['useradd', '-d', '/software_root', '-g', 'slapsoft', '-s',
'/bin/false', 'slapsoft']],
CALL_AND_READ_LIST)
EXTERNAL_COMMAND_LIST)
def test_construct_empty_prepared_no_alter_network_user(self):
computer = slapos.format.Computer('computer',
......@@ -206,11 +206,11 @@ class TestComputer(SlapformatMixin):
"makedirs('/software_root', 493)",
"chmod('/software_root', 493)"],
self.test_result.bucket)
global CALL_AND_READ_LIST
global EXTERNAL_COMMAND_LIST
self.assertEqual([
['ip', 'addr', 'list', 'bridge'],
],
CALL_AND_READ_LIST)
EXTERNAL_COMMAND_LIST)
class TestPartition(SlapformatMixin):
......@@ -237,7 +237,7 @@ class TestPartition(SlapformatMixin):
class TestUser(SlapformatMixin):
def test_create(self):
global CALL_AND_READ_LIST
global EXTERNAL_COMMAND_LIST
user = slapos.format.User('doesnotexistsyet')
user.setPath('/doesnotexistsyet')
user.create()
......@@ -248,10 +248,10 @@ class TestUser(SlapformatMixin):
['useradd', '-d', '/doesnotexistsyet', '-g', 'doesnotexistsyet', '-s',
'/bin/false', 'doesnotexistsyet']
],
CALL_AND_READ_LIST)
EXTERNAL_COMMAND_LIST)
def test_create_additional_groups(self):
global CALL_AND_READ_LIST
global EXTERNAL_COMMAND_LIST
user = slapos.format.User('doesnotexistsyet', ['additionalgroup1',
'additionalgroup2'])
user.setPath('/doesnotexistsyet')
......@@ -264,11 +264,11 @@ class TestUser(SlapformatMixin):
'/bin/false', '-G', 'additionalgroup1,additionalgroup2',
'doesnotexistsyet']
],
CALL_AND_READ_LIST)
EXTERNAL_COMMAND_LIST)
def test_create_group_exists(self):
pwd.getpwnam = self.raisingKeyError
global CALL_AND_READ_LIST
global EXTERNAL_COMMAND_LIST
user = slapos.format.User('testuser')
user.setPath('/testuser')
......@@ -279,11 +279,11 @@ class TestUser(SlapformatMixin):
['useradd', '-d', '/testuser', '-g', 'testuser', '-s', '/bin/false',
'testuser']
],
CALL_AND_READ_LIST)
EXTERNAL_COMMAND_LIST)
def test_create_user_exists_additional_groups(self):
grp.getgrnam = self.raisingKeyError
global CALL_AND_READ_LIST
global EXTERNAL_COMMAND_LIST
user = slapos.format.User('testuser', ['additionalgroup1',
'additionalgroup2'])
user.setPath('/testuser')
......@@ -295,11 +295,11 @@ class TestUser(SlapformatMixin):
['usermod', '-d', '/testuser', '-g', 'testuser', '-s', '/bin/false',
'-G', 'additionalgroup1,additionalgroup2', 'testuser']
],
CALL_AND_READ_LIST)
EXTERNAL_COMMAND_LIST)
def test_create_user_exists(self):
grp.getgrnam = self.raisingKeyError
global CALL_AND_READ_LIST
global EXTERNAL_COMMAND_LIST
user = slapos.format.User('testuser')
user.setPath('/testuser')
user.create()
......@@ -310,10 +310,10 @@ class TestUser(SlapformatMixin):
['usermod', '-d', '/testuser', '-g', 'testuser', '-s', '/bin/false',
'testuser']
],
CALL_AND_READ_LIST)
EXTERNAL_COMMAND_LIST)
def test_create_user_group_exists(self):
global CALL_AND_READ_LIST
global EXTERNAL_COMMAND_LIST
user = slapos.format.User('testuser')
user.setPath('/testuser')
user.create()
......@@ -323,7 +323,7 @@ class TestUser(SlapformatMixin):
['usermod', '-d', '/testuser', '-g', 'testuser', '-s', '/bin/false',
'testuser']
],
CALL_AND_READ_LIST)
EXTERNAL_COMMAND_LIST)
def test_isAvailable(self):
user = slapos.format.User('testuser')
......
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