def test_cli(self, table_9_content):
        csv_filepath = os.path.join(self.current_tmp, 'tab.csv')
        hepdata_converter._main(['--output-format', 'csv', '--table', 'Table 9', '--separator', ';', self.submission_filepath,
                                 csv_filepath])

        with open(csv_filepath, 'r') as csv_file:
            self.assertEqual(table_9_content, csv_file.read())
Exemple #2
0
    def test_single_file_output(self, oldhepdata_path, oldhepdata_file,
                                oldhepdata_yaml_file):
        data = hepdata_converter.convert(oldhepdata_file,
                                         options={
                                             'input_format':
                                             'oldhepdata',
                                             'output_format':
                                             'yaml',
                                             'single_file':
                                             True,
                                             'hepdata_doi':
                                             '10.17182/hepdata.62535.v1'
                                         })

        yaml_single_output_path = os.path.join(self.current_tmp, 'output.yaml')

        hepdata_converter._main([
            '--input-format', 'oldhepdata', '--output-format', 'yaml',
            '--single-file', oldhepdata_path, yaml_single_output_path
        ])

        print('OUTPUT PATH IS {}'.format(yaml_single_output_path))
        self.assertTrue(os.path.exists(yaml_single_output_path))

        self.assertEqual(oldhepdata_yaml_file, data)
    def test_cli(self, oldhepdata_path, oldhepdata_yaml_path):
        hepdata_converter._main([
            '--input-format', 'oldhepdata', '--output-format', 'yaml',
            oldhepdata_path, self.current_tmp
        ])

        self.assertDirsEqual(oldhepdata_yaml_path, self.current_tmp)
Exemple #4
0
    def test_diroutput(self, oldhepdata_path, csv_path):
        hepdata_converter._main([
            '-i', 'oldhepdata', '-o', 'csv', oldhepdata_path, self.current_tmp
        ])

        self.assertDirsEqual(self.current_tmp,
                             csv_path,
                             file_content_parser=lambda x: x)
Exemple #5
0
    def test_cli(self, table_9_content):
        csv_filepath = os.path.join(self.current_tmp, 'tab.csv')
        hepdata_converter._main([
            '--output-format', 'csv', '--table', 'Table 9', '--separator', ';',
            self.submission_filepath, csv_filepath
        ])

        with open(csv_filepath, 'r') as csv_file:
            self.assertEqual(table_9_content, csv_file.read())
    def test_no_dir_output(self, table_1_content, table_9_content):
        csv_filepath = os.path.join(self.current_tmp, 'csv_dir')
        hepdata_converter._main(['--output-format', 'csv', '--separator', ',', self.submission_filepath,
                                 csv_filepath])

        self.assertTrue(os.path.exists(csv_filepath))
        csv_1 = os.path.join(csv_filepath, 'Table1.csv')
        self.assertTrue(os.path.exists(csv_1))
        with open(csv_1, 'r') as csv_file:
            self.assertMultiLineAlmostEqual(table_1_content.strip(), csv_file.read().strip())

        csv_2 = os.path.join(csv_filepath, 'Table9.csv')
        self.assertTrue(os.path.exists(csv_2))
        with open(csv_2, 'r') as csv_file:
            self.assertMultiLineAlmostEqual(table_9_content.strip(), csv_file.read().strip())
    def test_single_file_output(self, oldhepdata_path, oldhepdata_file, oldhepdata_yaml_file):
        data = hepdata_converter.convert(oldhepdata_file,
                                         options={
                                             'input_format': 'oldhepdata',
                                             'output_format': 'yaml',
                                             'single_file': True})

        yaml_single_output_path = os.path.join(self.current_tmp, 'output.yaml')

        hepdata_converter._main(['--input-format', 'oldhepdata', '--output-format', 'yaml', '--single-file',
                                 oldhepdata_path, yaml_single_output_path])

        print('OUTPUT PATH IS {}'.format(yaml_single_output_path))
        self.assertTrue(os.path.exists(yaml_single_output_path))

        self.assertEqual(oldhepdata_yaml_file, data)
    def test_convert_yaml2csv(self, submission_file, table_csv):
        output_path = os.path.join(self.current_tmp, 'output.csv')
        code, message = hepdata_converter._main(['--input-format', 'yaml', '--output-format', 'csv',
                                                 '--table', 'Table 1', '--pack', submission_file, output_path])

        self.assertEqual(code, 0, message)
        self.assertTrue(os.path.exists(output_path))

        with open(output_path) as f:
            self.assertMultiLineAlmostEqual(table_csv, f.read())
    def test_no_dir_output(self, table_1_content, table_9_content):
        csv_filepath = os.path.join(self.current_tmp, 'csv_dir')
        hepdata_converter._main([
            '--output-format', 'csv', '--validator-schema-version', '0.1.0',
            '--separator', ',', self.submission_filepath, csv_filepath
        ])

        self.assertTrue(os.path.exists(csv_filepath))
        csv_1 = os.path.join(csv_filepath, 'Table1.csv')
        self.assertTrue(os.path.exists(csv_1))
        with open(csv_1, 'r') as csv_file:
            self.assertMultiLineAlmostEqual(table_1_content.strip(),
                                            csv_file.read().strip())

        csv_2 = os.path.join(csv_filepath, 'Table9.csv')
        self.assertTrue(os.path.exists(csv_2))
        with open(csv_2, 'r') as csv_file:
            self.assertMultiLineAlmostEqual(table_9_content.strip(),
                                            csv_file.read().strip())
    def test_convert_yaml2csv(self, submission_file, table_csv):
        output_path = os.path.join(self.current_tmp, 'output.csv')
        code, message = hepdata_converter._main([
            '--input-format', 'yaml', '--output-format', 'csv', '--table',
            'Table 1', '--pack', submission_file, output_path
        ])

        self.assertEqual(code, 0, message)
        self.assertTrue(os.path.exists(output_path))

        with open(output_path) as f:
            self.assertMultiLineAlmostEqual(table_csv, f.read())
    def test_diroutput(self, oldhepdata_path, csv_path):
        hepdata_converter._main(['-i', 'oldhepdata',
                                 '-o', 'csv',
                                 oldhepdata_path, self.current_tmp])

        self.assertDirsEqual(self.current_tmp, csv_path, file_content_parser=lambda x: x)
Exemple #12
0
 def test_version(self):
     r, message = hepdata_converter._main(['--version'])
     self.assertEqual(r, 0)
     self.assertTrue(message.endswith(
         hepdata_converter.version.__version__))
Exemple #13
0
 def test_convert_yaml2yoda(self):
     hepdata_converter._main([
         '--input-format', 'yaml', '--output-format', 'csv', '--table',
         'Table 1', self.current_tmp,
         os.path.join(self.current_tmp, 'output.csv')
     ])
 def test_version(self):
     r, message = hepdata_converter._main(['--version'])
     self.assertEqual(r, 0)
     self.assertTrue(message.endswith(hepdata_converter.version.__version__))
 def test_convert_yaml2yoda(self):
     hepdata_converter._main(['--input-format', 'yaml', '--output-format', 'csv',
                             '--table', 'Table 1',
                             self.current_tmp, os.path.join(self.current_tmp, 'output.csv')])
    def test_cli(self, oldhepdata_path, oldhepdata_yaml_path):
        hepdata_converter._main(
            ["--input-format", "oldhepdata", "--output-format", "yaml", oldhepdata_path, self.current_tmp]
        )

        self.assertDirsEqual(oldhepdata_yaml_path, self.current_tmp)