@@ -63,7 +63,6 @@ def test_get_mapping_list(self):
6363 gen = genabout .GenAbout ()
6464 expected_list = {'about_file' : 'directory/filename' ,
6565 'version' : 'confirmed version' ,
66- 'about_resource' : 'file_name' ,
6766 'name' : 'component' ,
6867 'copyright' : 'confirmed copyright' }
6968 output = gen .get_mapping_list ()
@@ -93,7 +92,9 @@ def test_validate_value_in_essential_missing_about_resource(self):
9392 gen = genabout .GenAbout ()
9493 input = [{'about_file' : '/about.ABOUT' , 'about_resource' : '' ,
9594 'name' : 'ABOUT tool' , 'version' : '0.8.1' }]
96- self .assertFalse (gen .validate_value_in_essential_fields (input ))
95+ #self.assertFalse(gen.validate_value_in_essential_fields(input))
96+ # This is now true as it doesn't depends on about_resource now
97+ self .assertTrue (gen .validate_value_in_essential_fields (input ))
9798
9899 def test_validate_value_in_essential_missing_all (self ):
99100 gen = genabout .GenAbout ()
@@ -151,7 +152,9 @@ def test_validate_mandatory_fields_missing_about_resource(self):
151152 gen = genabout .GenAbout ()
152153 input_list = [{'about_file' : '/about.ABOUT' , 'name' : 'ABOUT tool' ,
153154 'version' : '0.8.1' }]
154- self .assertFalse (gen .validate_mandatory_fields (input_list ))
155+ #self.assertFalse(gen.validate_mandatory_fields(input_list))
156+ # This is now True as it doesn't need about_resource
157+ self .assertTrue (gen .validate_mandatory_fields (input_list ))
155158
156159 def test_get_non_supported_fields (self ):
157160 gen = genabout .GenAbout ()
@@ -299,7 +302,7 @@ def test_pre_generation_about_is_dir_exists_action_0(self):
299302 'about_resource' : '.' , 'name' : 'ABOUT tool' }]
300303 expected_output_list = [[join (TESTDATA_PATH , 'test_files_for_genabout/TESTCASE' , 'TESTCASE.ABOUT' ),
301304 {'about_file' : '/TESTCASE/' , 'version' : '0.8.1' ,
302- 'about_resource_path' : '/TESTCASE/TESTCASE.ABOUT ' ,
305+ 'about_resource_path' : '/TESTCASE/' ,
303306 'about_resource' : '.' , 'name' : 'ABOUT tool' }]]
304307 output_list = gen .pre_generation (gen_location , input_list , action_num , False )
305308 self .assertTrue (expected_output_list == output_list )
@@ -525,3 +528,97 @@ def test_process_dje_licenses(self):
525528 expected_output = [[join (u'/test' , 'test_key.LICENSE' ), 'This is a test license.' ]]
526529 output = gen .process_dje_licenses (test_license_list , test_license_dict , test_path )
527530 self .assertTrue (output == expected_output )
531+
532+ def test_update_about_resource_about_file_and_field_exist (self ):
533+ gen = genabout .GenAbout ()
534+ input_dict = {'about_resource' : 'test.c' , 'about_file' : '/tmp/test.c' }
535+ about_file_exist = True
536+ gen .update_about_resource (input_dict , about_file_exist )
537+ self .assertTrue (input_dict == input_dict , "The dict should not be changed." )
538+
539+ def test_update_about_resource_about_file_and_field_not_exist_isFile (self ):
540+ gen = genabout .GenAbout ()
541+ input_dict = {'about_file' : '/tmp/test.c' }
542+ expected_output = {'about_file' : '/tmp/test.c' , 'about_resource' : 'test.c' }
543+ about_file_exist = True
544+ gen .update_about_resource (input_dict , about_file_exist )
545+ self .assertTrue (input_dict == expected_output )
546+
547+ def test_update_about_resource_about_file_and_field_not_exist_isdir (self ):
548+ gen = genabout .GenAbout ()
549+ input_dict = {'about_file' : '/tmp/test/' }
550+ expected_output = {'about_file' : '/tmp/test/' , 'about_resource' : '.' }
551+ about_file_exist = True
552+ gen .update_about_resource (input_dict , about_file_exist )
553+ self .assertTrue (input_dict == expected_output )
554+
555+ def test_update_about_resource_no_about_file_field_exist (self ):
556+ gen = genabout .GenAbout ()
557+ input_dict = {'about_resource' : 'test.c' , 'about_file' : '/tmp/test.c' }
558+ about_file_exist = False
559+ gen .update_about_resource (input_dict , about_file_exist )
560+ self .assertTrue (input_dict == input_dict , "The dict should not be changed." )
561+
562+ def test_update_about_resource_no_about_file_no_field_isFile (self ):
563+ gen = genabout .GenAbout ()
564+ input_dict = {'about_file' : '/tmp/test.c' }
565+ expected_output = {'about_file' : '/tmp/test.c' , 'about_resource' : 'test.c' }
566+ about_file_exist = False
567+ gen .update_about_resource (input_dict , about_file_exist )
568+ self .assertTrue (input_dict == expected_output )
569+
570+ def test_update_about_resource_no_about_file_no_field_isdir (self ):
571+ gen = genabout .GenAbout ()
572+ input_dict = {'about_file' : '/tmp/test/' }
573+ expected_output = {'about_file' : '/tmp/test/' , 'about_resource' : '.' }
574+ about_file_exist = False
575+ gen .update_about_resource (input_dict , about_file_exist )
576+ self .assertTrue (input_dict == expected_output )
577+
578+ def test_update_about_resource_path_about_file_field_exist (self ):
579+ gen = genabout .GenAbout ()
580+ input_dict = {'about_resource_path' : '/tmp/test.c' , 'about_file' : '/tmp/test.c' }
581+ about_file_exist = True
582+ gen .update_about_resource_path (input_dict , about_file_exist )
583+ self .assertTrue (input_dict == input_dict , "The dict should not be changed." )
584+
585+ def test_update_about_resource_path_about_file_field_not_exist_isFile (self ):
586+ gen = genabout .GenAbout ()
587+ input_dict = {'about_file' : '/tmp/test.c' }
588+ expected_output = {'about_file' : '/tmp/test.c' , 'about_resource_path' : '/tmp/test.c' }
589+ about_file_exist = True
590+ gen .update_about_resource_path (input_dict , about_file_exist )
591+ self .assertTrue (input_dict == expected_output )
592+
593+ def test_update_about_resource_path_about_file_field_not_exist_isDir (self ):
594+ gen = genabout .GenAbout ()
595+ input_dict = {'about_file' : '/tmp/test/' }
596+ expected_output = {'about_file' : '/tmp/test/' , 'about_resource_path' : '/tmp/test/' }
597+ about_file_exist = True
598+ gen .update_about_resource_path (input_dict , about_file_exist )
599+ self .assertTrue (input_dict == expected_output )
600+
601+ def test_update_about_resource_path_no_about_file_field_exist (self ):
602+ gen = genabout .GenAbout ()
603+ input_dict = {'about_resource_path' : '/tmp/test.c' , 'about_file' : '/tmp/test.c' }
604+ about_file_exist = False
605+ gen .update_about_resource_path (input_dict , about_file_exist )
606+ self .assertTrue (input_dict == input_dict , "The dict should not be changed." )
607+
608+ def test_update_about_resource_path_no_about_file_field_not_exist_isFile (self ):
609+ gen = genabout .GenAbout ()
610+ input_dict = {'about_file' : '/tmp/test.c' }
611+ expected_output = {'about_file' : '/tmp/test.c' , 'about_resource_path' : '/tmp/test.c' }
612+ about_file_exist = False
613+ gen .update_about_resource_path (input_dict , about_file_exist )
614+ self .assertTrue (input_dict == expected_output )
615+
616+ def test_update_about_resource_path_no_about_file_field_not_exist_isDir (self ):
617+ gen = genabout .GenAbout ()
618+ input_dict = {'about_file' : '/tmp/test/' }
619+ expected_output = {'about_file' : '/tmp/test/' , 'about_resource_path' : '/tmp/test/' }
620+ about_file_exist = False
621+ gen .update_about_resource_path (input_dict , about_file_exist )
622+ self .assertTrue (input_dict == expected_output )
623+
624+
0 commit comments