Esempio n. 1
0
    def test_names_matching_case(self):
        writer = PythonDictWriter()
        stringio = io.StringIO()
        table_index_1 = "case_Sensitive"
        table_index_2 = "case_sensitive"
        table_headers = [[]]
        writer.open(
            [
                (table_index_1, table_headers),
                (table_index_2, table_headers)
            ],
            stringio
        )
        writer.close()
        preview = writer.get_preview()

        first_sheet_name = preview[0]['table_name']
        second_sheet_name = preview[1]['table_name']
        self.assertNotEqual(
            first_sheet_name.lower(),
            second_sheet_name.lower(),
            "Sheet names must not be equal. Comparison is NOT case sensitive. Names were '{}' and '{}'".format(
                first_sheet_name, second_sheet_name
            )
        )
Esempio n. 2
0
 def test_exact_max_header_length(self):
     writer = PythonDictWriter()
     writer.max_table_name_size = 19
     stringio = io.StringIO()
     table_index = "sheet_name_for_tabs"
     table_headers = [("header1", "header2")]
     writer.open([(table_index, table_headers)], stringio)
     writer.close()
     preview = writer.get_preview()
     self.assertEqual(preview[0]['table_name'], "sheet_name_for_tabs")
     self.assertLessEqual(len(preview[0]['table_name']),
                          writer.max_table_name_size)
Esempio n. 3
0
 def test_max_header_length(self):
     writer = PythonDictWriter()
     writer.max_table_name_size = 10
     stringio = StringIO.StringIO()
     table_index = "my_table_index"
     table_headers = [("first header", "second header")]
     writer.open([(table_index, table_headers)], stringio)
     writer.close()
     preview = writer.get_preview()
     self.assertGreater(len(table_index), writer.max_table_name_size)
     self.assertLessEqual(len(preview[0]['table_name']),
                          writer.max_table_name_size)
Esempio n. 4
0
 def test_max_header_length_duplicates(self):
     writer = PythonDictWriter()
     writer.max_table_name_size = 7
     stringio = io.StringIO()
     table_headers = [("header1", "header2")]
     writer.open([
         ("prefix1: index", table_headers),
         ("prefix2- index", table_headers),
     ], stringio)
     writer.close()
     preview = writer.get_preview()
     table_names = {table['table_name'] for table in preview}
     self.assertEqual(len(table_names), 2)
Esempio n. 5
0
    def test_names_matching_case(self):
        writer = PythonDictWriter()
        stringio = StringIO.StringIO()
        table_index_1 = "case_Sensitive"
        table_index_2 = "case_sensitive"
        table_headers = [[]]
        writer.open(
            [
                (table_index_1, table_headers),
                (table_index_2, table_headers)
            ],
            stringio
        )
        writer.close()
        preview = writer.get_preview()

        first_sheet_name = preview[0]['table_name']
        second_sheet_name = preview[1]['table_name']
        self.assertNotEqual(
            first_sheet_name.lower(),
            second_sheet_name.lower(),
            "Sheet names must not be equal. Comparison is NOT case sensitive. Names were '{}' and '{}'".format(
                first_sheet_name, second_sheet_name
            )
        )
Esempio n. 6
0
 def test_max_header_length(self):
     writer = PythonDictWriter()
     writer.max_table_name_size = 10
     stringio = StringIO.StringIO()
     table_index = "my_table_index"
     table_headers = [("first header", "second header")]
     writer.open(
         [(table_index, table_headers)],
         stringio
     )
     writer.close()
     preview = writer.get_preview()
     self.assertGreater(len(table_index), writer.max_table_name_size)
     self.assertLessEqual(len(preview[0]['table_name']), writer.max_table_name_size)
Esempio n. 7
0
 def test_max_header_length_duplicates(self):
     writer = PythonDictWriter()
     writer.max_table_name_size = 7
     stringio = io.StringIO()
     table_headers = [("header1", "header2")]
     writer.open(
         [
             ("prefix1: index", table_headers),
             ("prefix2- index", table_headers),
         ],
         stringio
     )
     writer.close()
     preview = writer.get_preview()
     table_names = {table['table_name'] for table in preview}
     self.assertEqual(len(table_names), 2)