Skip to content

Commit

Permalink
More test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
chinyeungli committed Apr 10, 2014
1 parent a5f94c8 commit c5e1f19
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions about_code_tool/tests/test_genabout.py
Expand Up @@ -240,6 +240,19 @@ def test_get_dje_license_list_gen_license_with_empty_dje_license_key_empty_licen
self.assertTrue(len(gen.warnings) == 1, "Should return 1 warning.")
self.assertFalse(gen.errors, "No errors should be returned.")

def test_get_dje_license_list_gen_license_with_dje_license_key_no_license_text_file(self):
gen = genabout.GenAbout()
gen_location = join(TESTDATA_PATH, "test_files_for_genabout/")
input_list = [{'about_file': '/about.py.ABOUT', 'version': '0.8.1',
'about_resource': '.', 'name': 'ABOUT tool',
'dje_license_key': 'apache-2.0'}]
expected_output_list = [('/', 'apache-2.0')]
gen_license = True
lic_output_list = gen.get_dje_license_list(gen_location, input_list, gen_license)
self.assertTrue(expected_output_list == lic_output_list)
self.assertFalse(gen.warnings, "No warnings should be returned.")
self.assertFalse(gen.errors, "No errors should be returned.")

def test_pre_generation_about_is_dir_exists_action_0(self):
gen = genabout.GenAbout()
gen_location = join(TESTDATA_PATH, "test_files_for_genabout/")
Expand Down Expand Up @@ -352,7 +365,7 @@ def test_format_output_with_continuation(self):

def test_verify_license_files_exist(self):
gen = genabout.GenAbout()
input_list = [{'version': '0.8.1', 'about_file': 'about.py.ABOUT',
input_list = [{'version': '0.8.1', 'about_file': '/TESTCASE/',
'license_text_file': 'apache2.LICENSE.txt',
'name': 'ABOUT tool', 'about_resource': '.'}]
path = '.'
Expand All @@ -362,9 +375,33 @@ def test_verify_license_files_exist(self):
self.assertFalse(gen.warnings, "No warnings should be returned.")
self.assertFalse(gen.errors, "No errors should be returned.")

def test_verify_license_files_exist_license_in_project(self):
gen = genabout.GenAbout()
input_list = [{'version': '0.8.1', 'about_file': '/TESTCASE/',
'license_text_file': 'apache2.LICENSE.txt',
'name': 'ABOUT tool', 'about_resource': '.'}]
path = '.'
expected_list = [('./apache2.LICENSE.txt', '')]
output = gen.verify_license_files(input_list, path, True)
self.assertEqual(expected_list, output)
self.assertFalse(gen.warnings, "No warnings should be returned.")
self.assertFalse(gen.errors, "No errors should be returned.")

def test_verify_license_files_not_exist(self):
gen = genabout.GenAbout()
input_list = [{'version': '0.8.1', 'about_file': 'about.py.ABOUT',
input_list = [{'version': '0.8.1', 'about_file': '/about.py.ABOUT',
'license_text_file': 'not_exist.LICENSE.txt',
'name': 'ABOUT tool', 'about_resource': '.'}]
path = '.'
expected_list = []
output = gen.verify_license_files(input_list, path, False)
self.assertTrue(expected_list == output)
self.assertTrue(len(gen.warnings) == 1, "Should return 1 warning.")
self.assertFalse(gen.errors, "No errors should be returned.")

def test_verify_license_files_not_exist_license_in_project(self):
gen = genabout.GenAbout()
input_list = [{'version': '0.8.1', 'about_file': '/TESTCASE/',
'license_text_file': 'not_exist.LICENSE.txt',
'name': 'ABOUT tool', 'about_resource': '.'}]
path = '.'
Expand All @@ -376,7 +413,7 @@ def test_verify_license_files_not_exist(self):

def test_verify_license_files_no_key(self):
gen = genabout.GenAbout()
input_list = [{'version': '0.8.1', 'about_file': 'about.py.ABOUT',
input_list = [{'version': '0.8.1', 'about_file': '/about.py.ABOUT',
'name': 'ABOUT tool', 'about_resource': '.'}]
path = '.'
self.assertRaises(Exception, gen.verify_license_files, input_list, path)
Expand Down

0 comments on commit c5e1f19

Please sign in to comment.