Skip to content

Commit

Permalink
fix issues with imports over more levels
Browse files Browse the repository at this point in the history
  • Loading branch information
jscotka authored and root committed Mar 8, 2018
1 parent 9f84792 commit 2078677
Show file tree
Hide file tree
Showing 38 changed files with 374 additions and 472 deletions.
5 changes: 2 additions & 3 deletions examples/openshift/template/memcached.py
Expand Up @@ -24,8 +24,7 @@
import pexpect
from avocado import main
from avocado.core import exceptions
from moduleframework import module_framework
from moduleframework import common
from moduleframework import core, module_framework
import time


Expand All @@ -40,7 +39,7 @@ def test_smoke(self):
session = pexpect.spawn("telnet %s %s" % (self.ip_address, self.getConfig()['service']['port']))
session.sendline('set Test 0 100 4\r\n\n')
session.sendline('JournalDev\r\n\n')
common.print_info('Expecting STORED')
core.print_info('Expecting STORED')
session.expect('STORED')
session.close()

Expand Down
4 changes: 2 additions & 2 deletions examples/testing-module/Makefile
Expand Up @@ -42,8 +42,8 @@ check-run-them-fedmsg-testmodule: prepare-nspawn
../../tools/run-them.sh testmodule ../../tools/example_message_module.yaml fedmsg

check-exceptions: prepare-docker
URL=NOT_VALID_URL MODULE=docker $(CMD) --show-job-log simpleTest.py 2>&1 | grep 'raise CmdError'
CONFIG=NOT_VALID_CONFIG MODULE=docker $(CMD) --show-job-log simpleTest.py 2>&1 | grep 'raise ConfigExc'
URL=NOT_VALID_URL MODULE=docker $(CMD) --show-job-log simpleTest.py 2>&1 | grep 'raise.*CmdError'
CONFIG=NOT_VALID_CONFIG MODULE=docker $(CMD) --show-job-log simpleTest.py 2>&1 | grep 'raise.*ConfigExc'

check-pure-rpm: prepare-nspawn
CONFIG=config-pure-rpm.yaml MODULE=nspawn $(CMD) $(SIMPLE)
Expand Down
18 changes: 9 additions & 9 deletions moduleframework/avocado_testers/avocado_test.py
Expand Up @@ -30,7 +30,7 @@
from avocado.core import exceptions
import warnings

from moduleframework.common import *
from moduleframework import core, common
from moduleframework.helpers.container_helper import ContainerHelper
from moduleframework.helpers.nspawn_helper import NspawnHelper
from moduleframework.helpers.rpm_helper import RpmHelper
Expand All @@ -56,10 +56,10 @@ def __init__(self, *args, **kwargs):
super(AvocadoTest, self).__init__(*args, **kwargs)

self.backend = get_backend()
self.moduleType = get_module_type()
self.moduleType_base = get_module_type_base()
self.moduleProfile = get_profile()
print_info(
self.moduleType = common.get_module_type()
self.moduleType_base = common.get_module_type_base()
self.moduleProfile = common.get_profile()
core.print_info(
"Module Type: %s - Backend: %s - Profile: %s" %
(self.moduleType, self.moduleType_base, self.moduleProfile))

Expand Down Expand Up @@ -142,7 +142,7 @@ def run(self, *args, **kwargs):
:param kwargs: shell, ignore_status, verbose
:return: object avocado.process.run
"""
if is_debug():
if core.is_debug():
self.__print_breaks("COMMAND IN MODULE <->")
return self.backend.run(*args, **kwargs)

Expand Down Expand Up @@ -194,7 +194,7 @@ def runHost(self, *args, **kwargs):
:param kwargs: pass thru
:return: object of avocado.process.run
"""
if is_debug():
if core.is_debug():
self.__print_breaks("COMMAND ON HOST <!>")
return self.backend.runHost(*args, **kwargs)

Expand All @@ -216,7 +216,7 @@ def getActualProfile(self):
:return: str
"""
self.start()
allpackages = self.run(r'rpm -qa --qf="%{{name}}\n"', verbose=is_not_silent()).stdout.split('\n')
allpackages = self.run(r'rpm -qa --qf="%{{name}}\n"', verbose=core.is_not_silent()).stdout.split('\n')
return allpackages

def copyTo(self, *args, **kwargs):
Expand Down Expand Up @@ -323,7 +323,7 @@ def get_backend():
:return: module object
"""
parent = get_module_type_base()
parent = common.get_module_type_base()

if parent == 'docker':
return ContainerHelper()
Expand Down
8 changes: 4 additions & 4 deletions moduleframework/avocado_testers/container_avocado_test.py
Expand Up @@ -20,12 +20,12 @@
# Authors: Petr Hracek <phracek@redhat.com>
#

from moduleframework.module_framework import AvocadoTest
from moduleframework.common import get_module_type_base
from moduleframework import common
import avocado_test


# INTERFACE CLASSES FOR SPECIFIC MODULE TESTS
class ContainerAvocadoTest(AvocadoTest):
class ContainerAvocadoTest(avocado_test.AvocadoTest):
"""
Class for writing tests specific just for DOCKER
derived from AvocadoTest class.
Expand All @@ -34,7 +34,7 @@ class ContainerAvocadoTest(AvocadoTest):
"""

def setUp(self):
if get_module_type_base() != "docker":
if common.get_module_type_base() != "docker":
self.cancel("Docker specific test")
super(ContainerAvocadoTest, self).setUp()

Expand Down
9 changes: 5 additions & 4 deletions moduleframework/avocado_testers/nspawn_avocado_test.py
Expand Up @@ -19,11 +19,12 @@
#
# Authors: Petr Hracek <phracek@redhat.com>
#
from moduleframework.module_framework import AvocadoTest
from moduleframework.common import get_module_type_base

from moduleframework import common
import avocado_test

class NspawnAvocadoTest(AvocadoTest):

class NspawnAvocadoTest(avocado_test.AvocadoTest):
"""
Class for writing tests specific just for RPM module testing inside NSPAWN env
derived from AvocadoTest class.
Expand All @@ -32,7 +33,7 @@ class NspawnAvocadoTest(AvocadoTest):
"""

def setUp(self):
if get_module_type_base() != "nspawn":
if common.get_module_type_base() != "nspawn":
self.cancel("Nspawn specific test")
super(NspawnAvocadoTest, self).setUp()

Expand Down
8 changes: 4 additions & 4 deletions moduleframework/avocado_testers/openshift_avocado_test.py
Expand Up @@ -20,12 +20,12 @@
# Authors: Petr Hracek <phracek@redhat.com>
#

from moduleframework.module_framework import AvocadoTest
from moduleframework.common import get_module_type_base
from moduleframework import common
import avocado_test


# INTERFACE CLASSES FOR SPECIFIC MODULE TESTS
class OpenShiftAvocadoTest(AvocadoTest):
class OpenShiftAvocadoTest(avocado_test.AvocadoTest):
"""
Class for writing tests specific just for OpenShift
derived from AvocadoTest class.
Expand All @@ -34,6 +34,6 @@ class OpenShiftAvocadoTest(AvocadoTest):
"""

def setUp(self):
if get_module_type_base() != "openshift":
if common.get_module_type_base() != "openshift":
self.cancel("OpenShift specific test")
super(OpenShiftAvocadoTest, self).setUp()
8 changes: 4 additions & 4 deletions moduleframework/avocado_testers/rpm_avocado_test.py
Expand Up @@ -20,11 +20,11 @@
# Authors: Petr Hracek <phracek@redhat.com>
#

from moduleframework.module_framework import AvocadoTest
from moduleframework.common import get_module_type_base
from moduleframework import common
import avocado_test


class RpmAvocadoTest(AvocadoTest):
class RpmAvocadoTest(avocado_test.AvocadoTest):
"""
Class for writing tests specific just for LOCAL (system) RPM testing
derived from AvocadoTest class.
Expand All @@ -33,7 +33,7 @@ class RpmAvocadoTest(AvocadoTest):
"""

def setUp(self):
if get_module_type_base() != "rpm":
if common.get_module_type_base() != "rpm":
self.cancel("Rpm specific test")
super(RpmAvocadoTest, self).setUp()

Expand Down
32 changes: 7 additions & 25 deletions moduleframework/bashhelper.py
@@ -1,24 +1,3 @@
# -*- coding: utf-8 -*-
#
# Meta test family (MTF) is a tool to test components of a modular Fedora:
# https://docs.pagure.org/modularity/
# Copyright (C) 2017 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# he Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Authors: Jan Scotka <jscotka@redhat.com>
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
Expand All @@ -43,13 +22,16 @@
# Authors: Jan Scotka <jscotka@redhat.com>
#

from __future__ import print_function
import os
import pickle
import inspect
from moduleframework import module_framework
import core
import module_framework
from optparse import OptionParser



def main():
picklefile = '/var/tmp/module-data.pkl'
parser = OptionParser()
Expand Down Expand Up @@ -78,7 +60,7 @@ def main():

def printIfVerbose(*sargs):
if options.verbose:
print sargs
core.print_info(sargs)

if os.path.isfile(picklefile) and os.stat(picklefile).st_size > 100:
printIfVerbose("reading from pickfile", picklefile)
Expand All @@ -95,9 +77,9 @@ def printIfVerbose(*sargs):
if "tearDown" != method:
if options.printt:
if len(args) == 1:
print getattr(helper, method)()
print(getattr(helper, method)())
else:
print getattr(helper, method)(" ".join(args[1:]))
print(getattr(helper, method)(" ".join(args[1:])))
else:
if len(args) == 1:
getattr(helper, method)()
Expand Down

0 comments on commit 2078677

Please sign in to comment.