From 9006c93961426383477a10058971b7ce19142e97 Mon Sep 17 00:00:00 2001 From: Brian Stinson Date: Nov 15 2018 04:17:30 +0000 Subject: add some tests Signed-off-by: Brian Stinson --- diff --git a/tests/test_layout.py b/tests/test_layout.py new file mode 100644 index 0000000..1841b74 --- /dev/null +++ b/tests/test_layout.py @@ -0,0 +1,80 @@ +import os +import shutil +import tempfile +import unittest + +from pyrpkg.layout import Layout + +class EmptyLayoutTestCase(unittest.TestCase): + def setUp(self): + self.workdir = tempfile.mkdtemp(prefix='rpkg-tests.') + self.layout = Layout.load(self.workdir) + + def tearDown(self): + shutil.rmtree(self.workdir) + + + def test_empty_layout_sets_sourcedir_to_cwd(self): + self.assertEqual(self.layout.sourcedir, self.workdir) + + def test_empty_layout_sets_specdir_to_cwd(self): + self.assertEqual(self.layout.specdir, self.workdir) + + def test_empty_layout_sets_builddir_to_cwd(self): + self.assertEqual(self.layout.builddir, self.workdir) + + def test_empty_layout_sets_rpmdir_to_cwd(self): + self.assertEqual(self.layout.rpmdir, self.workdir) + + def test_distgit_layout_sets_srcpmdir_to_cwd(self): + self.assertEqual(self.layout.srcrpmdir, self.workdir) + +class DistGitLayoutTestCase(unittest.TestCase): + def setUp(self): + self.workdir = tempfile.mkdtemp(prefix='rpkg-tests.') + self.file = os.path.join(self.workdir,'sources') + open(self.file, 'a').close() + self.layout = Layout.load(self.workdir) + + def tearDown(self): + shutil.rmtree(self.workdir) + + def test_distgit_layout_sets_sourcedir_to_cwd(self): + self.assertEqual(self.layout.sourcedir, self.workdir) + + def test_distgit_layout_sets_specdir_to_cwd(self): + self.assertEqual(self.layout.specdir, self.workdir) + + def test_distgit_layout_sets_builddir_to_cwd(self): + self.assertEqual(self.layout.builddir, self.workdir) + + def test_distgit_layout_sets_rpmdir_to_cwd(self): + self.assertEqual(self.layout.rpmdir, self.workdir) + + def test_distgit_layout_sets_srcpmdir_to_cwd(self): + self.assertEqual(self.layout.srcrpmdir, self.workdir) + +class ExplodedSRPMLayoutTestCase(unittest.TestCase): + def setUp(self): + self.workdir = tempfile.mkdtemp(prefix='rpkg-tests.') + self.file = os.path.join(self.workdir,'.test.metadata') + open(self.file, 'a').close() + self.layout = Layout.load(self.workdir) + + def tearDown(self): + shutil.rmtree(self.workdir) + + def test_distgit_layout_sets_sourcedir_to_SOURCES(self): + self.assertEqual(self.layout.sourcedir, os.path.join(self.workdir, 'SOURCES')) + + def test_distgit_layout_sets_specdir_to_SPECS(self): + self.assertEqual(self.layout.specdir, os.path.join(self.workdir, 'SPECS')) + + def test_distgit_layout_sets_builddir_to_BUILD(self): + self.assertEqual(self.layout.builddir, os.path.join(self.workdir, 'BUILD')) + + def test_distgit_layout_sets_rpmdir_to_RPMS(self): + self.assertEqual(self.layout.rpmdir, os.path.join(self.workdir, 'RPMS')) + + def test_distgit_layout_sets_srpmdir_to_SRPMS(self): + self.assertEqual(self.layout.srcrpmdir, os.path.join(self.workdir, 'SRPMS'))