class ListMissingTestCase(unittest.TestCase):
    def setUp(self):
        self.directory = "/home/devel/wregglej/downloads/srcrpms"
        self.myserver = TestServer()
        self.myserver.upload_packages(self.directory, source=1)
        self.packageobj = xp.packages.Packages()

    def tearDown(self):
        rhnSQL.rollback()

    def testPresence(self):
        if self.packageobj.listMissingSourcePackages:
            assert 1
        else:
            assert 0

    def testlistMissingSourcePackages(self):
        channel = self.myserver.getChannel()
        package_list = self.packageobj.listMissingSourcePackages(
            [channel.get_label()], self.myserver.getUsername(), self.myserver.getPassword()
        )
        if type(package_list) == type([]):
            assert 1
        else:
            assert 0
Ejemplo n.º 2
0
class ListMissingTestCase( unittest.TestCase ):
    def setUp( self ):
        self.directory = '/home/devel/wregglej/downloads/srcrpms'
        self.myserver = TestServer()
        self.myserver.upload_packages( self.directory, source = 1 )
        self.packageobj = xp.packages.Packages()

    def tearDown( self ):
        rhnSQL.rollback()

    def testPresence( self ):
        if self.packageobj.listMissingSourcePackages:
            assert 1
        else:
            assert 0

    def testlistMissingSourcePackages( self ):
        channel = self.myserver.getChannel()
        package_list = self.packageobj.listMissingSourcePackages( [ channel.get_label() ],\
                                                                  self.myserver.getUsername(),\
                                                                  self.myserver.getPassword() )
        if type( package_list ) == type( [] ):
            assert 1
        else:
            assert 0
Ejemplo n.º 3
0
class SolveDependenciesTestCase(unittest.TestCase):
    #this class assumes that:
    # mozilla-1.3.1-0.dag.rhel3.i386.rpm
    # mozilla-1.5-2.rhfc1.dag.i386.rpm
    # mozilla-1.6-0.rhfc1.dag.i386.rpm
    # mozilla-1.7.1-1.1.el3.test.i386.rpm
    # are all available in self.directory.


    def setUp(self):
        self.directory = '/home/devel/wregglej/testrpms'
        self.filename = 'libcaps.so'
        self.arch = 'i386'
        self.myserver = TestServer()
        self.serv_id = self.myserver.getServerId()
        self.myserver.upload_packages(self.directory)
        self.up2date = self.myserver.getUp2date()
        self.sysid = self.myserver.getSystemId()
        self.sd2 = self.up2date.solveDependencies_v2    #returns arch info
        self.sd4 = self.up2date.solveDependencies_v4    #returns arch info, has better filtering

    def tearDown(self):
        rhnSQL.rollback()

    def testGetArchSd2( self ):
        ret = self.sd2( self.sysid, [self.filename] )
        assert len( ret[self.filename][0] ) == 5

    def testGetArchSd4( self ):
        ret = self.sd4( self.sysid, [self.filename] )
        assert len( ret[self.filename][0] ) == 5

    def testArchTypeSd2( self ):
        ret = self.sd2( self.sysid, [self.filename] )
        assert type( ret[self.filename][0][4] ) == type('a')

    def testArchTypeSd4( self ):
        ret = self.sd4( self.sysid, [self.filename] )
        assert type( ret[self.filename][0][4] ) == type('a')

    def testArchValueSd2( self ):
        ret = self.sd2( self.sysid, [self.filename] )
        assert ret[self.filename][0][4] == 'i386'

    def testArchValueSd4( self ):
        ret = self.sd4( self.sysid, [self.filename] )
        assert ret[self.filename][0][4] == 'i386'

    def testAllTrueSd4( self ):
        ret = self.sd4( self.sysid, [self.filename], all = 1 )
        assert len( ret[self.filename]) > 1

    def testAllFalseSd4( self ):
        ret = self.sd4( self.sysid, [self.filename], all = 0 )
        assert len( ret[self.filename] ) == 1
Ejemplo n.º 4
0
class SolveDependenciesTestCase(unittest.TestCase):
    #this class assumes that:
    # mozilla-1.3.1-0.dag.rhel3.i386.rpm
    # mozilla-1.5-2.rhfc1.dag.i386.rpm
    # mozilla-1.6-0.rhfc1.dag.i386.rpm
    # mozilla-1.7.1-1.1.el3.test.i386.rpm
    # are all available in self.directory.


    def setUp(self):
        self.directory = '/home/devel/wregglej/testrpms'
        self.filename = 'libcaps.so'
        self.arch = 'i386'
        self.myserver = TestServer()
        self.serv_id = self.myserver.getServerId()
        self.myserver.upload_packages(self.directory)
        self.up2date = self.myserver.getUp2date()
        self.sysid = self.myserver.getSystemId()
        self.sd2 = self.up2date.solveDependencies_v2    #returns arch info
        self.sd4 = self.up2date.solveDependencies_v4    #returns arch info, has better filtering

    def tearDown(self):
        rhnSQL.rollback()

    def testGetArchSd2( self ):
        ret = self.sd2( self.sysid, [self.filename] )
        assert len( ret[self.filename][0] ) == 5

    def testGetArchSd4( self ):
        ret = self.sd4( self.sysid, [self.filename] )
        assert len( ret[self.filename][0] ) == 5

    def testArchTypeSd2( self ):
        ret = self.sd2( self.sysid, [self.filename] )
        assert type( ret[self.filename][0][4] ) == type('a')

    def testArchTypeSd4( self ):
        ret = self.sd4( self.sysid, [self.filename] )
        assert type( ret[self.filename][0][4] ) == type('a')

    def testArchValueSd2( self ):
        ret = self.sd2( self.sysid, [self.filename] )
        assert ret[self.filename][0][4] == 'i386'

    def testArchValueSd4( self ):
        ret = self.sd4( self.sysid, [self.filename] )
        assert ret[self.filename][0][4] == 'i386'

    def testAllTrueSd4( self ):
        ret = self.sd4( self.sysid, [self.filename], all = 1 )
        assert len( ret[self.filename]) > 1

    def testAllFalseSd4( self ):
        ret = self.sd4( self.sysid, [self.filename], all = 0 )
        assert len( ret[self.filename] ) == 1
Ejemplo n.º 5
0
 def setUp(self):
     self.directory = '/home/devel/wregglej/testrpms'
     self.filename = 'libcaps.so'
     self.arch = 'i386'
     self.myserver = TestServer()
     self.serv_id = self.myserver.getServerId()
     self.myserver.upload_packages(self.directory)
     self.up2date = self.myserver.getUp2date()
     self.sysid = self.myserver.getSystemId()
     self.sd2 = self.up2date.solveDependencies_v2  # returns arch info
     self.sd4 = self.up2date.solveDependencies_v4  # returns arch info, has better filtering
 def setUp(self):
     self.directory = '/home/devel/wregglej/testrpms'
     self.filename = 'libcaps.so'
     self.arch = 'i386'
     self.myserver = TestServer()
     self.serv_id = self.myserver.getServerId()
     self.myserver.upload_packages(self.directory)
     self.up2date = self.myserver.getUp2date()
     self.solve_deps_arch = rhnDependency.solve_dependencies_arch
     self.solve_deps_with_limits = rhnDependency.solve_dependencies_with_limits
     self.up2date = self.myserver.getUp2date()
Ejemplo n.º 7
0
	def __init__(self, suite_name=DEFAULT_TEST_SUITE, build_num=0):
		'''
		@param string suite
		@param string buildnum
		'''
		self.initOK=False
		## do input validation
		self.buildnum=build_num
		self.suiteName=suite_name

		self.Pass=0
		self.Fail=0
		self.Total=0
		self.ALTList=[]
		self.start_time=None
		self.end_time=None
		self.exception_string=''
		## do environment validation
		if not path.isfile(self.__class__.__name__+'.py'):
			print('Please run %s from the directory where is resides.' % (self.__class__.__name__+'.py'))
			return
#		if not path.isdir(SETUP_SUBDIR):
#			print 'Required directory %s does not exist. please check and run again.' % SETUP_SUBDIR
#			return
		if not path.isfile(CONFIG_FILE):
			print("File '%s' is not found in test4u root directory. please make sure you get the full package and start over." % CONFIG_FILE)
			return
		if not path.isdir(TC_SUBDIR):
			print("Directory '%s' is not found in test4u root directory. It is used to store testcase files(*.t4u). Please check and start over." % TC_SUBDIR)
			return
		if not path.isdir(TS_SUBDIR):
			print("Directory '%s' is not found in test4u root directory. It is used to store test suite files(*.ts). Please check and start over." % TC_SUBDIR)
			return
		if not path.isdir(SNAPSHOT_SUBDIR):
			mkdir(SNAPSHOT_SUBDIR)
		## remove old log file
		if path.isfile(TESTER_DEBUG_LOG_FILE):
			print('Removing old log file...')
			remove(TESTER_DEBUG_LOG_FILE)
#			truncate_file(TESTER_DEBUG_LOG_FILE)

		## create new log file
		self.logHandler=createLogger(self.buildnum)

		## build device pool
		self.testServer=TestServer()
		self.devicePool=self.testServer.getDeviceIdList()
		if len(self.devicePool)==0:
			printLog('NO DEVICE FOUND. QUIT.', logging.ERROR)
			return

		## build testcase suite
		try:
			self.testPool=TestSuite(self.suiteName)
			if self.testPool.getTotalCount()==0:
				printLog('NO TESTCASE IN THE TEST SUITE. QUIT.', logging.ERROR)
				return
		except Exception, e:
			printLog('Failed to create test pool: %s' % e.message, logging.ERROR)
			return
Ejemplo n.º 8
0
 def start_client(self):
     transport = TSocket.TSocket("127.0.0.1", 30030)
     trans = TTransport.TFramedTransport(transport)
     protocol = TBinaryProtocol.TBinaryProtocol(trans)
     client = TestServer.Client(protocol)
     trans.open()
     self.msg = client.add_and_get_msg("hello thrift")
Ejemplo n.º 9
0
 def setUp(self):
     self.directory = '/home/devel/wregglej/testrpms'
     self.filename = 'libcaps.so'
     self.arch = 'i386'
     self.myserver = TestServer()
     self.serv_id = self.myserver.getServerId()
     self.myserver.upload_packages(self.directory)
     self.up2date = self.myserver.getUp2date()
     self.solve_deps_arch = rhnDependency.solve_dependencies_arch
     self.solve_deps_with_limits = rhnDependency.solve_dependencies_with_limits
     self.up2date = self.myserver.getUp2date()
Ejemplo n.º 10
0
 def setUp(self):
     self.directory = '/home/devel/wregglej/testrpms'
     self.filename = 'libcaps.so'
     self.arch = 'i386'
     self.myserver = TestServer()
     self.serv_id = self.myserver.getServerId()
     self.myserver.upload_packages(self.directory)
     self.up2date = self.myserver.getUp2date()
     self.sysid = self.myserver.getSystemId()
     self.sd2 = self.up2date.solveDependencies_v2  # returns arch info
     self.sd4 = self.up2date.solveDependencies_v4  # returns arch info, has better filtering
Ejemplo n.º 11
0
    def __init__(self, build_num, test_suite, device_id):
        # get idle device
        self.buildnum = build_num
        self.testSuite = copy.deepcopy(test_suite)
        self.testServer = TestServer()
        AndroidDevice.__init__(self, device_id)
#        self.device = AndroidDevice(device_id)
        self.crash = False
        self.threadName='<'+self.model+'_'+self.deviceId+'>  '
        threading.Thread.__init__(self)#, name=self.device.model+'_'+self.device.deviceId)
        if not self.resultFlag:
#            self.devicePool.releaseDevice(self.device.deviceId)
            assert False
Ejemplo n.º 12
0
    def __init__(self, suite_name=DEFAULT_TEST_SUITE, build_num=0):
        '''
		@param string suite
		@param string buildnum
		'''
        self.initOK = False
        ## do input validation
        self.buildnum = build_num
        self.suiteName = suite_name

        self.Pass = 0
        self.Fail = 0
        self.Total = 0
        self.ALTList = []
        self.start_time = None
        self.end_time = None
        self.exception_string = ''
        ## do environment validation
        if not path.isfile(self.__class__.__name__ + '.py'):
            print('Please run %s from the directory where is resides.' %
                  (self.__class__.__name__ + '.py'))
            return
#		if not path.isdir(SETUP_SUBDIR):
#			print 'Required directory %s does not exist. please check and run again.' % SETUP_SUBDIR
#			return
        if not path.isfile(CONFIG_FILE):
            print(
                "File '%s' is not found in test4u root directory. please make sure you get the full package and start over."
                % CONFIG_FILE)
            return
        if not path.isdir(TC_SUBDIR):
            print(
                "Directory '%s' is not found in test4u root directory. It is used to store testcase files(*.t4u). Please check and start over."
                % TC_SUBDIR)
            return
        if not path.isdir(TS_SUBDIR):
            print(
                "Directory '%s' is not found in test4u root directory. It is used to store test suite files(*.ts). Please check and start over."
                % TC_SUBDIR)
            return
        if not path.isdir(SNAPSHOT_SUBDIR):
            mkdir(SNAPSHOT_SUBDIR)
        ## remove old log file
        if path.isfile(TESTER_DEBUG_LOG_FILE):
            print('Removing old log file...')
            remove(TESTER_DEBUG_LOG_FILE)
#			truncate_file(TESTER_DEBUG_LOG_FILE)

## create new log file
        self.logHandler = createLogger(self.buildnum)

        ## build device pool
        self.testServer = TestServer()
        self.devicePool = self.testServer.getDeviceIdList()
        if len(self.devicePool) == 0:
            printLog('NO DEVICE FOUND. QUIT.', logging.ERROR)
            return

        ## build testcase suite
        try:
            self.testPool = TestSuite(self.suiteName)
            if self.testPool.getTotalCount() == 0:
                printLog('NO TESTCASE IN THE TEST SUITE. QUIT.', logging.ERROR)
                return
        except Exception, e:
            printLog('Failed to create test pool: %s' % e.message,
                     logging.ERROR)
            return
Ejemplo n.º 13
0
        wordlist.send_keys(Keys.ARROW_LEFT)
        WebDriverWait(self.driver, 10).until(
            EC.text_to_be_present_in_element((By.ID, 'wordlist__page'),
                                             "(Page 1)"))
        options = [
            x.get_attribute('value')
            for x in wordlist.find_elements_by_tag_name('option')
        ]
        self.assertEqual(options, [
            "HAA", "HBB", "HCC", "HDD", "HEE", "HFF", "HGG", "HHH", "HII",
            "HJJ"
        ])

        wordlist.send_keys(Keys.ARROW_RIGHT)
        WebDriverWait(self.driver, 10).until(
            EC.text_to_be_present_in_element((By.ID, 'wordlist__page'),
                                             "(Page 2)"))
        options = [
            x.get_attribute('value')
            for x in wordlist.find_elements_by_tag_name('option')
        ]
        self.assertEqual(options, ["HKK", "HLL", "HMM", "HNN"])


if __name__ == '__main__':
    test_server = TestServer()
    test_server.run()
    unittest.main()
    test_server.terminate()
class SolveDependenciesTestCase(unittest.TestCase):
    # this class assumes that:
    # mozilla-1.3.1-0.dag.rhel3.i386.rpm
    # mozilla-1.5-2.rhfc1.dag.i386.rpm
    # mozilla-1.6-0.rhfc1.dag.i386.rpm
    # mozilla-1.7.1-1.1.el3.test.i386.rpm
    # are all available in self.directory.

    def setUp(self):
        self.directory = '/home/devel/wregglej/testrpms'
        self.filename = 'libcaps.so'
        self.arch = 'i386'
        self.myserver = TestServer()
        self.serv_id = self.myserver.getServerId()
        self.myserver.upload_packages(self.directory)
        self.up2date = self.myserver.getUp2date()
        self.solve_deps_arch = rhnDependency.solve_dependencies_arch
        self.solve_deps_with_limits = rhnDependency.solve_dependencies_with_limits
        self.up2date = self.myserver.getUp2date()

    def tearDown(self):
        rhnSQL.rollback()

    def testReturnType(self):
        assert type(self.solve_deps_arch(self.serv_id, [], 2)) == type({})

    def testKeyType(self):
        assert type(
            self.solve_deps_arch(self.serv_id, [self.filename],
                                 2).keys()[0]) == type('a')

    def testValueType(self):
        assert type(
            self.solve_deps_arch(self.serv_id, [self.filename],
                                 2)[self.filename]) == type([])

    def testNestedValueType(self):
        assert type(
            self.solve_deps_arch(self.serv_id, [self.filename],
                                 2)[self.filename][0]) == type([])

    def testNestedValueLength(self):
        assert len(
            self.solve_deps_arch(self.serv_id, [self.filename],
                                 2)[self.filename][0]) > 0

    def testNestedValueLength2(self):
        assert len(
            self.solve_deps_arch(self.serv_id, [self.filename],
                                 2)[self.filename][0]) == 5

    def testNestedValueType0(self):
        assert type(
            self.solve_deps_arch(self.serv_id, [self.filename],
                                 2)[self.filename][0][0]) == type('a')

    def testNestedValueType1(self):
        assert type(
            self.solve_deps_arch(self.serv_id, [self.filename],
                                 2)[self.filename][0][1]) == type('a')

    def testNestedValueType2(self):
        assert type(
            self.solve_deps_arch(self.serv_id, [self.filename],
                                 2)[self.filename][0][2]) == type('a')

    def testNestedValueType3(self):
        assert type(
            self.solve_deps_arch(self.serv_id, [self.filename],
                                 2)[self.filename][0][3]) == type('a')

    def testNestedValueType4(self):
        assert type(
            self.solve_deps_arch(self.serv_id, [self.filename],
                                 2)[self.filename][0][4]) == type('a')

    def testVerifyArch(self):
        assert self.solve_deps_arch(self.serv_id, [self.filename],
                                    2)[self.filename][0][4] == self.arch

    def testReturnTypeLimit(self):
        assert type(self.solve_deps_with_limits(self.serv_id, [],
                                                2)) == type({})

    def testKeyTypeLimit(self):
        assert type(
            self.solve_deps_with_limits(self.serv_id, [self.filename],
                                        2).keys()[0]) == type('a')

    def testValueTypeLimit(self):
        assert type(
            self.solve_deps_with_limits(self.serv_id, [self.filename],
                                        2)[self.filename]) == type([])

    def testNestedValueTypeLimit(self):
        assert type(
            self.solve_deps_with_limits(self.serv_id, [self.filename],
                                        2)[self.filename][0]) == type([])

    def testNestedValueLengthLimit(self):
        assert len(
            self.solve_deps_with_limits(self.serv_id, [self.filename],
                                        2)[self.filename][0]) > 0

    def testNestedValueLengthLimit2(self):
        assert len(
            self.solve_deps_with_limits(self.serv_id, [self.filename],
                                        2)[self.filename][0]) == 5

    def testNestedValueTypeLimit0(self):
        assert type(
            self.solve_deps_with_limits(self.serv_id, [self.filename],
                                        2)[self.filename][0][0]) == type('a')

    def testNestedValueTypeLimit1(self):
        assert type(
            self.solve_deps_with_limits(self.serv_id, [self.filename],
                                        2)[self.filename][0][1]) == type('a')

    def testNestedValueTypeLimit2(self):
        assert type(
            self.solve_deps_with_limits(self.serv_id, [self.filename],
                                        2)[self.filename][0][2]) == type('a')

    def testNestedValueTypeLimit3(self):
        assert type(
            self.solve_deps_with_limits(self.serv_id, [self.filename],
                                        2)[self.filename][0][3]) == type('a')

    def testNestedValueTypeLimit4(self):
        assert type(
            self.solve_deps_with_limits(self.serv_id, [self.filename],
                                        2)[self.filename][0][4]) == type('a')

    def testVerifyArchLimit(self):
        assert self.solve_deps_with_limits(self.serv_id, [self.filename],
                                           2)[self.filename][0][4] == self.arch

    def testAllReturn(self):
        pack = self.solve_deps_with_limits(self.serv_id, [self.filename],
                                           2,
                                           all=1)
        if pack is not None:
            assert 1
        else:
            assert 0

    def testAllReturn1(self):
        pack = self.solve_deps_with_limits(self.serv_id, [self.filename],
                                           2,
                                           all=1)
        exp_ret = ['mozilla', '1.3.1', '0.dag.rhel3', '34', 'i386']
        if exp_ret in pack[self.filename]:
            assert 1
        else:
            assert 0

    def testAllReturn2(self):
        pack = self.solve_deps_with_limits(self.serv_id, [self.filename],
                                           2,
                                           all=1)
        exp_ret = ['mozilla', '1.7.1', '1.1.el3.dag', '37', 'i386']
        if exp_ret in pack[self.filename]:
            assert 1
        else:
            assert 0

    def testAllReturn3(self):
        pack = self.solve_deps_with_limits(self.serv_id, [self.filename],
                                           2,
                                           all=1)
        exp_ret = ['mozilla', '1.5', '2.rhfc1.dag', '38', 'i386']
        if exp_ret in pack[self.filename]:
            assert 1
        else:
            assert 0

    def testAllReturn4(self):
        pack = self.solve_deps_with_limits(self.serv_id, [self.filename],
                                           2,
                                           all=1)
        exp_ret = ['mozilla', '1.6', '0.rhfc1.dag', '38', 'i386']
        if exp_ret in pack[self.filename]:
            assert 1
        else:
            assert 0

    def testNotAllReturn(self):
        pack = self.solve_deps_with_limits(self.serv_id, [self.filename], 2)

        exp_ret = ['mozilla', '1.6', '0.rhfc1.dag', '38', 'i386']
        if exp_ret in pack[self.filename]:
            assert 1
        else:
            assert 0

    def testMakeEvr(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        assert nlimit['epoch'] == '38' and\
            nlimit['name'] == 'mozilla' and\
            nlimit['version'] == '1.5' and\
            nlimit['release'] == '2.rhfc1.dag'

    def testMakeEvr1(self):
        nlimitstr = 'mozilla-1.5-2.rhfc1.dag:38'
        nlimit = rhnDependency.make_evr(nlimitstr)
        assert nlimit['epoch'] == '38' and\
            nlimit['name'] == 'mozilla' and\
            nlimit['version'] == '1.5' and\
            nlimit['release'] == '2.rhfc1.dag'

    def testMakeEvr2(self):
        nlimitstr = 'mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        assert nlimit['epoch'] is None and\
            nlimit['name'] == 'mozilla' and\
            nlimit['version'] == '1.5' and\
            nlimit['release'] == '2.rhfc1.dag'

    def testEvrFilterE(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.solve_deps_with_limits(self.serv_id, [self.filename],
                                           2,
                                           limit_operator='==',
                                           limit=nlimitstr)
        assert pack[self.filename][0][1] == nlimit['version'] and\
            pack[self.filename][0][2] == nlimit['release'] and\
            pack[self.filename][0][3] == nlimit['epoch']

    def testEvrFilterGT(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.solve_deps_with_limits(self.serv_id, [self.filename],
                                           2,
                                           limit_operator='>',
                                           limit=nlimitstr)
        assert rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release'])) == 1

    def testEvrFilterGTE(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.solve_deps_with_limits(self.serv_id, [self.filename],
                                           2,
                                           limit_operator='>=',
                                           limit=nlimitstr)
        ret = rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == 1 or ret == 0

    def testEvrFilterLT(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.solve_deps_with_limits(self.serv_id, [self.filename],
                                           2,
                                           limit_operator='<',
                                           limit=nlimitstr)
        ret = rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == -1

    def testEvrFilterLTE(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.solve_deps_with_limits(self.serv_id, [self.filename],
                                           2,
                                           limit_operator='<=',
                                           limit=nlimitstr)
        ret = rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == -1 or ret == 0

    def testUp2dateObj(self):
        pack = self.up2date.solveDependencies(self.myserver.getSystemId(),
                                              [self.filename])
        if pack is not None:
            assert 1
        else:
            assert 0

    def testUp2dateObjReturnLength(self):
        pack = self.up2date.solveDependencies_arch(self.myserver.getSystemId(),
                                                   [self.filename])
        assert len(pack[self.filename][0]) == 5

    def testUp2dateObjArchReturnType(self):
        pack = self.up2date.solveDependencies_arch(self.myserver.getSystemId(),
                                                   [self.filename])
        assert pack[self.filename][0][4] == 'i386'

    def testUp2dateFilterEq(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(
            self.myserver.getSystemId(), [self.filename],
            2,
            limit_operator='==',
            limit=nlimitstr)
        ret = rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release']))

        assert ret == 0

    def testUp2dateFilterGT(self):
        nlimitstr = '35:mozilla-0-0'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(
            self.myserver.getSystemId(), [self.filename],
            2,
            limit_operator='>',
            limit=nlimitstr)
        ret = rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == 1

    def testUp2dateFilterGTE(self):
        nlimitstr = '35:mozilla-1-1'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(
            self.myserver.getSystemId(), [self.filename],
            2,
            limit_operator='>',
            limit=nlimitstr)
        ret = rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == 1 or ret == 0

    def testUp2dateFilterLT(self):
        nlimitstr = '35:mozilla-1-1'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(
            self.myserver.getSystemId(), [self.filename],
            2,
            limit_operator='<',
            limit=nlimitstr)
        ret = rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == -1

    def testUp2dateFilterLTE(self):
        nlimitstr = '35:mozilla-1-1'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(
            self.myserver.getSystemId(), [self.filename],
            2,
            limit_operator='<=',
            limit=nlimitstr)
        ret = rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == -1 or ret == 0

    def testUp2dateFilterEq1(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(
            self.myserver.getSystemId(), [self.filename],
            2,
            limit_operator='==',
            limit=nlimitstr)
        ret = rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release']))

        assert ret == 0

    def testUp2dateFilterGT1(self):
        nlimitstr = 'mozilla-0-0:35'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(
            self.myserver.getSystemId(), [self.filename],
            2,
            limit_operator='>',
            limit=nlimitstr)
        ret = rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == 1

    def testUp2dateFilterGTE1(self):
        nlimitstr = 'mozilla-1-1:35'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(
            self.myserver.getSystemId(), [self.filename],
            2,
            limit_operator='>',
            limit=nlimitstr)
        ret = rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == 1 or ret == 0

    def testUp2dateFilterLT1(self):
        nlimitstr = 'mozilla-1-1:35'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(
            self.myserver.getSystemId(), [self.filename],
            2,
            limit_operator='<',
            limit=nlimitstr)
        ret = rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == -1

    def testUp2dateFilterLTE1(self):
        nlimitstr = 'mozilla-1-1:35'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(
            self.myserver.getSystemId(), [self.filename],
            2,
            limit_operator='<=',
            limit=nlimitstr)
        ret = rpm.labelCompare(
            (pack[self.filename][0][3], pack[self.filename][0][1],
             pack[self.filename][0][2]),
            (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == -1 or ret == 0
Ejemplo n.º 15
0
 def setUp( self ):
     self.directory = '/home/devel/wregglej/downloads/srcrpms'
     self.myserver = TestServer()
     self.myserver.upload_packages( self.directory, source = 1 )
     self.packageobj = xp.packages.Packages()
Ejemplo n.º 16
0
class SolveDependenciesTestCase(unittest.TestCase):
    # this class assumes that:
    # mozilla-1.3.1-0.dag.rhel3.i386.rpm
    # mozilla-1.5-2.rhfc1.dag.i386.rpm
    # mozilla-1.6-0.rhfc1.dag.i386.rpm
    # mozilla-1.7.1-1.1.el3.test.i386.rpm
    # are all available in self.directory.

    def setUp(self):
        self.directory = '/home/devel/wregglej/testrpms'
        self.filename = 'libcaps.so'
        self.arch = 'i386'
        self.myserver = TestServer()
        self.serv_id = self.myserver.getServerId()
        self.myserver.upload_packages(self.directory)
        self.up2date = self.myserver.getUp2date()
        self.solve_deps_arch = rhnDependency.solve_dependencies_arch
        self.solve_deps_with_limits = rhnDependency.solve_dependencies_with_limits
        self.up2date = self.myserver.getUp2date()

    def tearDown(self):
        rhnSQL.rollback()

    def testReturnType(self):
        assert type(self.solve_deps_arch(self.serv_id, [], 2)) == type({})

    def testKeyType(self):
        assert type(self.solve_deps_arch(self.serv_id, [self.filename], 2).keys()[0]) == type('a')

    def testValueType(self):
        assert type(self.solve_deps_arch(self.serv_id, [self.filename], 2)[self.filename]) == type([])

    def testNestedValueType(self):
        assert type(self.solve_deps_arch(self.serv_id, [self.filename], 2)[self.filename][0]) == type([])

    def testNestedValueLength(self):
        assert len(self.solve_deps_arch(self.serv_id, [self.filename], 2)[self.filename][0]) > 0

    def testNestedValueLength2(self):
        assert len(self.solve_deps_arch(self.serv_id, [self.filename], 2)[self.filename][0]) == 5

    def testNestedValueType0(self):
        assert type(self.solve_deps_arch(self.serv_id, [self.filename], 2)[self.filename][0][0]) == type('a')

    def testNestedValueType1(self):
        assert type(self.solve_deps_arch(self.serv_id, [self.filename], 2)[self.filename][0][1]) == type('a')

    def testNestedValueType2(self):
        assert type(self.solve_deps_arch(self.serv_id, [self.filename], 2)[self.filename][0][2]) == type('a')

    def testNestedValueType3(self):
        assert type(self.solve_deps_arch(self.serv_id, [self.filename], 2)[self.filename][0][3]) == type('a')

    def testNestedValueType4(self):
        assert type(self.solve_deps_arch(self.serv_id, [self.filename], 2)[self.filename][0][4]) == type('a')

    def testVerifyArch(self):
        assert self.solve_deps_arch(self.serv_id, [self.filename], 2)[self.filename][0][4] == self.arch

    def testReturnTypeLimit(self):
        assert type(self.solve_deps_with_limits(self.serv_id, [], 2)) == type({})

    def testKeyTypeLimit(self):
        assert type(self.solve_deps_with_limits(self.serv_id, [self.filename], 2).keys()[0]) == type('a')

    def testValueTypeLimit(self):
        assert type(self.solve_deps_with_limits(self.serv_id, [self.filename], 2)[self.filename]) == type([])

    def testNestedValueTypeLimit(self):
        assert type(self.solve_deps_with_limits(self.serv_id, [self.filename], 2)[self.filename][0]) == type([])

    def testNestedValueLengthLimit(self):
        assert len(self.solve_deps_with_limits(self.serv_id, [self.filename], 2)[self.filename][0]) > 0

    def testNestedValueLengthLimit2(self):
        assert len(self.solve_deps_with_limits(self.serv_id, [self.filename], 2)[self.filename][0]) == 5

    def testNestedValueTypeLimit0(self):
        assert type(self.solve_deps_with_limits(self.serv_id, [self.filename], 2)[self.filename][0][0]) == type('a')

    def testNestedValueTypeLimit1(self):
        assert type(self.solve_deps_with_limits(self.serv_id, [self.filename], 2)[self.filename][0][1]) == type('a')

    def testNestedValueTypeLimit2(self):
        assert type(self.solve_deps_with_limits(self.serv_id, [self.filename], 2)[self.filename][0][2]) == type('a')

    def testNestedValueTypeLimit3(self):
        assert type(self.solve_deps_with_limits(self.serv_id, [self.filename], 2)[self.filename][0][3]) == type('a')

    def testNestedValueTypeLimit4(self):
        assert type(self.solve_deps_with_limits(self.serv_id, [self.filename], 2)[self.filename][0][4]) == type('a')

    def testVerifyArchLimit(self):
        assert self.solve_deps_with_limits(self.serv_id, [self.filename], 2)[self.filename][0][4] == self.arch

    def testAllReturn(self):
        pack = self.solve_deps_with_limits(self.serv_id,
                                           [self.filename],
                                           2,
                                           all=1)
        if pack is not None:
            assert 1
        else:
            assert 0

    def testAllReturn1(self):
        pack = self.solve_deps_with_limits(self.serv_id,
                                           [self.filename],
                                           2,
                                           all=1)
        exp_ret = ['mozilla', '1.3.1', '0.dag.rhel3', '34', 'i386']
        if exp_ret in pack[self.filename]:
            assert 1
        else:
            assert 0

    def testAllReturn2(self):
        pack = self.solve_deps_with_limits(self.serv_id,
                                           [self.filename],
                                           2,
                                           all=1)
        exp_ret = ['mozilla', '1.7.1', '1.1.el3.dag', '37', 'i386']
        if exp_ret in pack[self.filename]:
            assert 1
        else:
            assert 0

    def testAllReturn3(self):
        pack = self.solve_deps_with_limits(self.serv_id,
                                           [self.filename],
                                           2,
                                           all=1)
        exp_ret = ['mozilla', '1.5', '2.rhfc1.dag', '38', 'i386']
        if exp_ret in pack[self.filename]:
            assert 1
        else:
            assert 0

    def testAllReturn4(self):
        pack = self.solve_deps_with_limits(self.serv_id,
                                           [self.filename],
                                           2,
                                           all=1)
        exp_ret = ['mozilla', '1.6', '0.rhfc1.dag', '38', 'i386']
        if exp_ret in pack[self.filename]:
            assert 1
        else:
            assert 0

    def testNotAllReturn(self):
        pack = self.solve_deps_with_limits(self.serv_id,
                                           [self.filename],
                                           2)

        exp_ret = ['mozilla', '1.6', '0.rhfc1.dag', '38', 'i386']
        if exp_ret in pack[self.filename]:
            assert 1
        else:
            assert 0

    def testMakeEvr(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        assert nlimit['epoch'] == '38' and\
            nlimit['name'] == 'mozilla' and\
            nlimit['version'] == '1.5' and\
            nlimit['release'] == '2.rhfc1.dag'

    def testMakeEvr1(self):
        nlimitstr = 'mozilla-1.5-2.rhfc1.dag:38'
        nlimit = rhnDependency.make_evr(nlimitstr)
        assert nlimit['epoch'] == '38' and\
            nlimit['name'] == 'mozilla' and\
            nlimit['version'] == '1.5' and\
            nlimit['release'] == '2.rhfc1.dag'

    def testMakeEvr2(self):
        nlimitstr = 'mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        assert nlimit['epoch'] is None and\
            nlimit['name'] == 'mozilla' and\
            nlimit['version'] == '1.5' and\
            nlimit['release'] == '2.rhfc1.dag'

    def testEvrFilterE(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.solve_deps_with_limits(self.serv_id,
                                           [self.filename],
                                           2,
                                           limit_operator='==',
                                           limit=nlimitstr)
        assert pack[self.filename][0][1] == nlimit['version'] and\
            pack[self.filename][0][2] == nlimit['release'] and\
            pack[self.filename][0][3] == nlimit['epoch']

    def testEvrFilterGT(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.solve_deps_with_limits(self.serv_id,
                                           [self.filename],
                                           2,
                                           limit_operator='>',
                                           limit=nlimitstr)
        assert rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                                (nlimit['epoch'], nlimit['version'], nlimit['release'])) == 1

    def testEvrFilterGTE(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.solve_deps_with_limits(self.serv_id,
                                           [self.filename],
                                           2,
                                           limit_operator='>=',
                                           limit=nlimitstr)
        ret = rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                               (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == 1 or ret == 0

    def testEvrFilterLT(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.solve_deps_with_limits(self.serv_id,
                                           [self.filename],
                                           2,
                                           limit_operator='<',
                                           limit=nlimitstr)
        ret = rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                               (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == -1

    def testEvrFilterLTE(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.solve_deps_with_limits(self.serv_id,
                                           [self.filename],
                                           2,
                                           limit_operator='<=',
                                           limit=nlimitstr)
        ret = rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                               (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == -1 or ret == 0

    def testUp2dateObj(self):
        pack = self.up2date.solveDependencies(self.myserver.getSystemId(), [self.filename])
        if pack is not None:
            assert 1
        else:
            assert 0

    def testUp2dateObjReturnLength(self):
        pack = self.up2date.solveDependencies_arch(self.myserver.getSystemId(), [self.filename])
        assert len(pack[self.filename][0]) == 5

    def testUp2dateObjArchReturnType(self):
        pack = self.up2date.solveDependencies_arch(self.myserver.getSystemId(), [self.filename])
        assert pack[self.filename][0][4] == 'i386'

    def testUp2dateFilterEq(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(self.myserver.getSystemId(),
                                                          [self.filename],
                                                          2,
                                                          limit_operator='==',
                                                          limit=nlimitstr)
        ret = rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                               (nlimit['epoch'], nlimit['version'], nlimit['release']))

        assert ret == 0

    def testUp2dateFilterGT(self):
        nlimitstr = '35:mozilla-0-0'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(self.myserver.getSystemId(),
                                                          [self.filename],
                                                          2,
                                                          limit_operator='>',
                                                          limit=nlimitstr)
        ret = rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                               (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == 1

    def testUp2dateFilterGTE(self):
        nlimitstr = '35:mozilla-1-1'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(self.myserver.getSystemId(),
                                                          [self.filename],
                                                          2,
                                                          limit_operator='>',
                                                          limit=nlimitstr)
        ret = rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                               (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == 1 or ret == 0

    def testUp2dateFilterLT(self):
        nlimitstr = '35:mozilla-1-1'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(self.myserver.getSystemId(),
                                                          [self.filename],
                                                          2,
                                                          limit_operator='<',
                                                          limit=nlimitstr)
        ret = rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                               (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == -1

    def testUp2dateFilterLTE(self):
        nlimitstr = '35:mozilla-1-1'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(self.myserver.getSystemId(),
                                                          [self.filename],
                                                          2,
                                                          limit_operator='<=',
                                                          limit=nlimitstr)
        ret = rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                               (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == -1 or ret == 0

    def testUp2dateFilterEq1(self):
        nlimitstr = '38:mozilla-1.5-2.rhfc1.dag'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(self.myserver.getSystemId(),
                                                          [self.filename],
                                                          2,
                                                          limit_operator='==',
                                                          limit=nlimitstr)
        ret = rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                               (nlimit['epoch'], nlimit['version'], nlimit['release']))

        assert ret == 0

    def testUp2dateFilterGT1(self):
        nlimitstr = 'mozilla-0-0:35'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(self.myserver.getSystemId(),
                                                          [self.filename],
                                                          2,
                                                          limit_operator='>',
                                                          limit=nlimitstr)
        ret = rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                               (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == 1

    def testUp2dateFilterGTE1(self):
        nlimitstr = 'mozilla-1-1:35'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(self.myserver.getSystemId(),
                                                          [self.filename],
                                                          2,
                                                          limit_operator='>',
                                                          limit=nlimitstr)
        ret = rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                               (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == 1 or ret == 0

    def testUp2dateFilterLT1(self):
        nlimitstr = 'mozilla-1-1:35'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(self.myserver.getSystemId(),
                                                          [self.filename],
                                                          2,
                                                          limit_operator='<',
                                                          limit=nlimitstr)
        ret = rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                               (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == -1

    def testUp2dateFilterLTE1(self):
        nlimitstr = 'mozilla-1-1:35'
        nlimit = rhnDependency.make_evr(nlimitstr)
        pack = self.up2date.solveDependencies_with_limits(self.myserver.getSystemId(),
                                                          [self.filename],
                                                          2,
                                                          limit_operator='<=',
                                                          limit=nlimitstr)
        ret = rpm.labelCompare((pack[self.filename][0][3], pack[self.filename][0][1], pack[self.filename][0][2]),
                               (nlimit['epoch'], nlimit['version'], nlimit['release']))
        assert ret == -1 or ret == 0
 def setUp(self):
     self.directory = "/home/devel/wregglej/downloads/srcrpms"
     self.myserver = TestServer()
     self.myserver.upload_packages(self.directory, source=1)
     self.packageobj = xp.packages.Packages()
Ejemplo n.º 18
0
 def __init__(self):
     handler = Handler()
     processor = TestServer.Processor(handler)
     transport = TSocket.TServerSocket("127.0.0.1", 30030)
     self.server = TNonblockingServer.TNonblockingServer(
         processor, transport)