Exemplo n.º 1
0
#!/usr/bin/python
import unittest
import tempfile
import os
import unittest_base
import sys
import shutil
import xenapi_mock

from autocertkit import utils
from datetime import datetime

utils.configure_logging('ack_tests')

K = 1024
M = K * 1024
G = M * 1024


class ExpressionMatchingTests(unittest_base.DevTestCase):
    """Tests for checking that the expr_eval function
    works appropriately with XenServer version numbers"""

    def _exp_true(self, expr, val):
        res = utils.eval_expr(expr, val)
        self.assertEqual(res, True, "Expected %s %s to be True!" % (val, expr))

    def _exp_false(self, expr, val):
        res = utils.eval_expr(expr, val)
        self.assertEqual(
            res, False, "Expected %s %s to be False!" % (val, expr))
Exemplo n.º 2
0
#!/usr/bin/python
import unittest

import unittest_base
from autocertkit import utils, test_generators, testbase
import sys

utils.configure_logging('ack_tests')

class TagsTests(unittest_base.DevTestCase):
    """Test that tags are enumerated correctly for a specified testclass"""

    def testCPUTestClassTags(self):
        cpuclass = testbase.CPUTestClass(self.session, self.config)
        tags = cpuclass.get_tags()
        assert 'CPU' in tags, "CPU tag not in the tags for CPUClass (%s)" % tags

    def testForTagMutilation(self):
        tg = test_generators.TestGenerator('fake_session', {}, 'nonexistent')
        for test_name, test_class in tg.get_test_classes():
            orig_tags = list(test_class('fake_session',{}).tags)
            new_tags = test_class('fake_session',{}).tags
            assert orig_tags == new_tags, "%s != %s - Tags are being mutilated. (%s)" % (orig_tags, new_tags, test_name)

if __name__ == '__main__':
    unittest.main()
Exemplo n.º 3
0
#!/usr/bin/python

import unittest
import sys
import os
import os.path
import random
import exceptions
import tempfile
import shutil

from autocertkit import utils, ack_cli

utils.configure_logging("ack_tests")


class NetworkConfRobustTests(unittest.TestCase):
    """ Checking functionality and robust of netconf parser. """

    TMP_DIR = None
    PREFIX = "sameple_netconf_"
    CLEANUP_LIST = []

    def _create_netconf_file(self, content):
        fullpath = self.TMP_DIR + os.sep + self.PREFIX + str(random.random())

        fh = file(fullpath, "w")
        fh.write(content)
        fh.close()

        self.CLEANUP_LIST.append(fullpath)