示例#1
0
    def test_header_row_in_csv_output(self):
        expected_header = (
            'about_file,name,version,about_resource,'
            'spec_version,date,description,description_file,'
            'home_url,download_url,readme,readme_file,install,install_file,'
            'changelog,changelog_file,news,news_file,news_url,notes,notes_file,'
            'contact,owner,author,author_file,copyright,copyright_file,'
            'notice_file,notice_url,license_text_file,license_url,license_spdx,'
            'redistribute,attribute,track_changes,vcs_tool,vcs_repository,'
            'vcs_path,vcs_tag,vcs_branch,vcs_revision,checksum_sha1,checksum_md5,'
            'checksum_sha256,dje_component,dje_license_key,dje_organization,'
            'dje_license_name,scm_branch,scm_repository,signature_gpg_file,'
            'redistribute_sources,dje_license,about_format,usage,'
            'license_text,notice,scm_path,scm_tool,scm_rev,scm_tag,organization,'
            'warnings,errors'
        )

        test_file = 'about_code_tool/tests/testdata/basic'
        output = get_temp_file()
        collector = Collector(test_file)
        collector.write_to_csv(output)
        with open(output) as f:
            header_row = f.readline().replace('\n', '').replace('\r', '')
        header_row_array = header_row.split(',')
        expected_header_array = expected_header.split(',')
        self.assertEqual(len(expected_header_array), len(header_row_array))
        for key in header_row_array:
            self.assertTrue(key in expected_header_array)
示例#2
0
 def test_return_path_is_not_abspath_and_contains_subdirs_on_dir(self):
     # Using a relative path for the purpose of this test
     test_file = 'about_code_tool/tests/testdata/basic'
     output = get_temp_file()
     collector = Collector(test_file)
     collector.write_to_csv(output)
     expected = '/basic'
     # FIXME: why [2]? what this test means?
     # CY: Since the output is going to have 2 rows (header row and row with
     # the test file data), the below partition('\n')[2] means to only read
     # the data row and ignroe the header row. This test is to make sure 
     # the path in the data row is not an absolute path.
     with open(output) as f:
         self.assertTrue(f.read().partition('\n')[2].startswith(expected))