Commit 9ed94c78 authored by Łukasz Nowak's avatar Łukasz Nowak

Avoid changing code in order to do the testing.

parent 65fb2a39
...@@ -400,7 +400,6 @@ class Partition: ...@@ -400,7 +400,6 @@ class Partition:
self.user = user self.user = user
self.address_list = address_list or [] self.address_list = address_list or []
self.tap = tap self.tap = tap
self._os = os
def __getinitargs__(self): def __getinitargs__(self):
return (self.reference, self.path, self.user, self.address_list, self.tap) return (self.reference, self.path, self.user, self.address_list, self.tap)
...@@ -411,14 +410,14 @@ class Partition: ...@@ -411,14 +410,14 @@ class Partition:
it the 750 permission. In case if path exists just modifies it. it the 750 permission. In case if path exists just modifies it.
""" """
self.path = self._os.path.abspath(self.path) self.path = os.path.abspath(self.path)
owner = self.user if self.user else User('root') owner = self.user if self.user else User('root')
if not self._os.path.exists(self.path): if not os.path.exists(self.path):
self._os.mkdir(self.path, 0750) os.mkdir(self.path, 0750)
if alter_user: if alter_user:
owner_pw = getpwnam(owner.name) owner_pw = getpwnam(owner.name)
self._os.chown(self.path, owner_pw.pw_uid, owner_pw.pw_gid) os.chown(self.path, owner_pw.pw_uid, owner_pw.pw_gid)
self._os.chmod(self.path, 0750) os.chmod(self.path, 0750)
class User: class User:
"User: represent and manipulate a user on the system." "User: represent and manipulate a user on the system."
...@@ -430,8 +429,6 @@ class User: ...@@ -430,8 +429,6 @@ class User:
""" """
self.name = str(user_name) self.name = str(user_name)
self.additional_group_list = additional_group_list self.additional_group_list = additional_group_list
self._getpwnam = getpwnam
self._grp = grp
def __getinitargs__(self): def __getinitargs__(self):
return (self.name,) return (self.name,)
...@@ -451,7 +448,7 @@ class User: ...@@ -451,7 +448,7 @@ class User:
# This method shall check if all is correctly done # This method shall check if all is correctly done
# This method shall not reset groups, just add them # This method shall not reset groups, just add them
try: try:
self._grp.getgrnam(self.name) grp.getgrnam(self.name)
except KeyError: except KeyError:
callAndRead(['groupadd', self.name]) callAndRead(['groupadd', self.name])
...@@ -460,7 +457,7 @@ class User: ...@@ -460,7 +457,7 @@ class User:
user_parameter_list.extend(['-G', ','.join(self.additional_group_list)]) user_parameter_list.extend(['-G', ','.join(self.additional_group_list)])
user_parameter_list.append(self.name) user_parameter_list.append(self.name)
try: try:
self._getpwnam(self.name) getpwnam(self.name)
except KeyError: except KeyError:
callAndRead(['useradd'] + user_parameter_list) callAndRead(['useradd'] + user_parameter_list)
else: else:
...@@ -478,7 +475,7 @@ class User: ...@@ -478,7 +475,7 @@ class User:
""" """
try: try:
self._getpwnam(self.name) getpwnam(self.name)
return True return True
except KeyError: except KeyError:
......
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