Example #1
0
    def testParsing(self):
        withoutClass = ('<entitlement><server>localhost</server>'
                        '<key>ABCD01234</key></entitlement>\n')
        assert(conarycfg.loadEntitlementFromString(withoutClass)
                == ('localhost', None, 'ABCD01234'))

        withoutClass = conarycfg.emitEntitlement('localhost', key = 'ABCD01234')
        assert(conarycfg.loadEntitlementFromString(withoutClass)
                == ('localhost', None, 'ABCD01234'))

        rc, s = self.captureOutput(conarycfg.loadEntitlementFromString,
                                   withoutClass, 'localhost', '<foo>')
        self.assertTrue('The serverName argument to loadEntitlementFromString has been deprecated' in s)
Example #2
0
    def testTimeoutParsing(self):
        xml = conarycfg.emitEntitlement('server', key = 'ABCD01234',
                                        retryOnTimeout = True, timeout = 60)
        ent = conarycfg.loadEntitlementFromString(xml, returnTimeout = True)
        assert(ent[3] == 60 and ent[4] is True)

        xml = conarycfg.emitEntitlement('server', key = 'ABCD01234')
        ent = conarycfg.loadEntitlementFromString(xml, returnTimeout = True)
        assert(ent[3] is None and ent[4] is True)

        xml = conarycfg.emitEntitlement('server', key = 'ABCD01234',
                                        timeout = 30)
        ent = conarycfg.loadEntitlementFromString(xml, returnTimeout = True)
        assert(ent[3] == 30 and ent[4] is True)
Example #3
0
    def testParsing(self):
        withoutClass = ('<entitlement><server>localhost</server>'
                        '<key>ABCD01234</key></entitlement>\n')
        assert (conarycfg.loadEntitlementFromString(withoutClass) == (
            'localhost', None, 'ABCD01234'))

        withoutClass = conarycfg.emitEntitlement('localhost', key='ABCD01234')
        assert (conarycfg.loadEntitlementFromString(withoutClass) == (
            'localhost', None, 'ABCD01234'))

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            conarycfg.loadEntitlementFromString(withoutClass, 'localhost',
                                                '<foo>')
            self.assertIn(
                'The serverName argument to loadEntitlementFromString has been deprecated',
                w[-1].message)