From b9126c70e09deafa04d591c2af5e785438647339 Mon Sep 17 00:00:00 2001 From: Brian Stinson Date: Jul 20 2015 02:03:29 +0000 Subject: refactored tests to classes for each type of input string --- diff --git a/tests/test_distgit.py b/tests/test_distgit.py index a597016..eab397e 100644 --- a/tests/test_distgit.py +++ b/tests/test_distgit.py @@ -7,35 +7,58 @@ print sys.path from centpkg import DistGitDirectory -class TestDistGitDirectory(unittest.TestCase): +class TestDistGitNothing(unittest.TestCase): def test_distgit_emptystring(self): with self.assertRaises(TypeError): d = DistGitDirectory() - def test_distgit_only_sig(self): - branchstring = 'sig-cloud7' - d = DistGitDirectory(branchstring) +class TestDistgitOnlySig(unittest.TestCase): + def setUp(self): + self.branchstring = 'sig-cloud7' + self.d = DistGitDirectory(self.branchstring) - self.assertEqual(d.signame, 'cloud') - self.assertEqual(d.centosversion, '7') - self.assertEqual(d.projectname, None) - self.assertEqual(d.releasename, None) + def test_signame_gets_set(self): + self.assertEqual(self.d.signame, 'cloud') - def test_distgit_sig_and_project(self): - branchstring = 'sig-cloud7-openstack' - d = DistGitDirectory(branchstring) + def test_centosversion_gets_set(self): + self.assertEqual(self.d.centosversion, '7') - self.assertEqual(d.signame, 'cloud') - self.assertEqual(d.centosversion, '7') - self.assertEqual(d.projectname, 'openstack') - self.assertEqual(d.releasename, None) + def test_projectname_gets_set(self): + self.assertEqual(self.d.projectname, None) - def test_distgit_sig_project_and_release(self): - branchstring = 'sig-cloud7-openstack-kilo' - d = DistGitDirectory(branchstring) + def test_releasename_gets_set(self): + self.assertEqual(self.d.releasename, None) - self.assertEqual(d.signame, 'cloud') - self.assertEqual(d.centosversion, '7') - self.assertEqual(d.projectname, 'openstack') - self.assertEqual(d.releasename, 'kilo') +class TestDistgitSigAndProject(unittest.TestCase): + def setUp(self): + self.branchstring = 'sig-cloud7-openstack' + self.d = DistGitDirectory(self.branchstring) + def test_signame_gets_set(self): + self.assertEqual(self.d.signame, 'cloud') + + def test_centosversion_gets_set(self): + self.assertEqual(self.d.centosversion, '7') + + def test_projectname_gets_set(self): + self.assertEqual(self.d.projectname, 'openstack') + + def test_releasename_gets_set(self): + self.assertEqual(self.d.releasename, None) + +class TestDistgitSigProjectAndRelease(unittest.TestCase): + def setUp(self): + self.branchstring = 'sig-cloud7-openstack-kilo' + self.d = DistGitDirectory(self.branchstring) + + def test_signame_gets_set(self): + self.assertEqual(self.d.signame, 'cloud') + + def test_centosversion_gets_set(self): + self.assertEqual(self.d.centosversion, '7') + + def test_projectname_gets_set(self): + self.assertEqual(self.d.projectname, 'openstack') + + def test_releasename_gets_set(self): + self.assertEqual(self.d.releasename, 'kilo')