def teardown_class(cls): """ Writes header with this class' `teardown` header to the test log and `DEBUG_LOG`. Finally runs inherited `base_suite.Suite.teardown_class` """ common.write_to([cls.log.info, DEBUG_LOG.info], common.MAKE_CAP("%s teardown" % cls.__name__, '_')) super().teardown_class()
def teardown_class(cls): """ Writes header with this class' `teardown` header to the test log and `DEBUG_LOG`, removes user, created in setup. Finally runs inherited `base_suite.Suite.setup_class` """ common.write_to([LOG.info, DEBUG_LOG.info], common.MAKE_CAP("%s teardown" % cls.__name__, '_')) cls.user_action('userdel', 'Removed') super().teardown_class()
def sudo(command): """ Executes given `command` with superuser's privilegues. Also writes this command to the `CMD_LOG`, and the result to `DEBUG_LOG`. Returns retrieved result """ result = sudo(command) common.write_to([DEBUG_LOG.debug, DEBUG_LOG.error], [result.stdout, result.stderr]) CMD_LOG.debug(result.command) return result
def prepare(cls, logger, exports, header): """ Assosiates given `logger` and `exports` options with appropriate class attributes, writes major `header` with this class `setup` header to the given logger and `DEBUG_LOG` """ cls.log = logger cls.ex_opts = exports common.write_to([cls.log.info, DEBUG_LOG.info], common.MAKE_CAP(header)) common.write_to([cls.log.info, DEBUG_LOG.info], common.MAKE_CAP("%s setup" % cls.__name__, '_'))
def setup_method(self, method): """ Test setup for a method level (will run for every method in class). Writes header with this method's name to the test log and `DEBUG_LOG`. Setup nfs server: creates test file. Setup nfs client: executes `set_up.Case.client` (read description). Writes setup results to the current test log """ cls = self.__class__ common.write_to([cls.log.info, DEBUG_LOG.info], common.MAKE_CAP(method.__name__, '-')) # set up server server_test_file = os.path.join(cls.server_dir, cls.test_file) create = cls.bridge.sudo("touch %s" % server_test_file) cls.log.info("Server setup %s" % cls.result(create.succeeded)) # set up client mount = set_up.Case.client(cls.server_dir, cls.client_dir) cls.log.info("Client setup %s" % cls.result(mount))