diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2006-10-16 11:28:33 -0400 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2006-10-16 11:28:33 -0400 |
commit | 371b17f08988754ea2bb30d45074207171864e84 (patch) | |
tree | 9e934ea535f37ad0dba17b44a709e699a46764e9 /tests | |
parent | eaf9eeec697485ae4e946dfab25458e374decd77 (diff) | |
download | third_party-cobbler-371b17f08988754ea2bb30d45074207171864e84.tar.gz third_party-cobbler-371b17f08988754ea2bb30d45074207171864e84.tar.xz third_party-cobbler-371b17f08988754ea2bb30d45074207171864e84.zip |
Unit tests for directory import
Diffstat (limited to 'tests')
7 files changed, 40 insertions, 3 deletions
diff --git a/tests/import_testdata/RHEL-4/U4/AS/i386/tree/images/pxeboot/initrd.img b/tests/import_testdata/RHEL-4/U4/AS/i386/tree/images/pxeboot/initrd.img new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/import_testdata/RHEL-4/U4/AS/i386/tree/images/pxeboot/initrd.img diff --git a/tests/import_testdata/RHEL-4/U4/AS/i386/tree/images/pxeboot/vmlinuz b/tests/import_testdata/RHEL-4/U4/AS/i386/tree/images/pxeboot/vmlinuz new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/import_testdata/RHEL-4/U4/AS/i386/tree/images/pxeboot/vmlinuz diff --git a/tests/import_testdata/RHEL-4/U4/AS/ia64/tree/images/pxeboot/initrd.img b/tests/import_testdata/RHEL-4/U4/AS/ia64/tree/images/pxeboot/initrd.img new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/import_testdata/RHEL-4/U4/AS/ia64/tree/images/pxeboot/initrd.img diff --git a/tests/import_testdata/RHEL-4/U4/AS/ia64/tree/images/pxeboot/vmlinuz b/tests/import_testdata/RHEL-4/U4/AS/ia64/tree/images/pxeboot/vmlinuz new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/import_testdata/RHEL-4/U4/AS/ia64/tree/images/pxeboot/vmlinuz diff --git a/tests/import_testdata/RHEL-4/U4/AS/x86_64/tree/images/pxeboot/initrd.img b/tests/import_testdata/RHEL-4/U4/AS/x86_64/tree/images/pxeboot/initrd.img new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/import_testdata/RHEL-4/U4/AS/x86_64/tree/images/pxeboot/initrd.img diff --git a/tests/import_testdata/RHEL-4/U4/AS/x86_64/tree/images/pxeboot/vmlinuz b/tests/import_testdata/RHEL-4/U4/AS/x86_64/tree/images/pxeboot/vmlinuz new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/import_testdata/RHEL-4/U4/AS/x86_64/tree/images/pxeboot/vmlinuz diff --git a/tests/tests.py b/tests/tests.py index cc2ca73..8acc1a7 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -28,9 +28,6 @@ import config import utils from cexceptions import CobblerException - - - FAKE_INITRD="initrd-2.6.15-1.2054_FAKE.img" FAKE_INITRD2="initrd-2.5.16-2.2055_FAKE.img" FAKE_INITRD3="initrd-1.8.18-3.9999_FAKE.img" @@ -297,6 +294,46 @@ class TestCLIBasic(BootTest): app = "/usr/bin/python" self.assertTrue(subprocess.call([app,"cobbler/cobbler.py","list"]) == 0) +class TestImport(BootTest): + + def test_import(self): + # testing the import code. + self.api.clear() + cwd = os.getcwd() + tests = os.path.join(cwd,"tests","import_testdata") + self.api.import_tree(tests, None, None) + self.api.serialize() + + # below: + # partial name of distro: current count, passing count, required arch + haystacks = { + "import_testdata_RHEL-4_U4_AS_ia64_tree_images_pxeboot" : [0, 1, "ia64" ], + "import_testdata_RHEL-4_U4_AS_i386_tree_images_pxeboot" : [0, 1, "x86" ], + "import_testdata_RHEL-4_U4_AS_x86_64_tree_images_pxeboot" : [0, 1, "x86_64" ], + "import_testdata_core_5_i386_os_images_pxeboot" : [ 0, 1, "x86" ], + "import_testdata_core_5_i386_os_images_xen" : [0, 1, "x86" ], + } + + # first go through all found distros and count the matches + for distro in self.api.distros(): + got_it = False + for match in haystacks.keys(): + if distro.name.find(match) != -1: + found = haystacks[match] + found[0] = found[0] + 1 + # check for architecture mismatches + self.failUnlessEqual(distro.arch, found[2], "architecture detection: %s vs %s on %s" % (distro.arch, found[2], distro.name)) + got_it = True + if not got_it: # hasn't :) + self.fail("imported foreign distro: %s" % distro.name) + + # now check the required number of matches vs actual. + # this checks to ensure unsupported arches aren't imported and there + # are no duplicate imports + for match in haystacks.keys(): + found = haystacks[match] + self.failUnlessEqual(found[0], found[1], "mismatched counts: %d vs %d for %s" % (found[0], found[1], match)) + if __name__ == "__main__": if not os.path.exists("setup.py"): print "tests: must invoke from top level directory" |