Пример #1
0
 def test_series(self):
     s = NominableSheet(self.data, "test")
     s.name_columns_by_row(2)
     assert s.colnames == ["Column 1", "Column 2", "Column 3"]
     custom_columns = ["C1", "C2", "C3"]
     s.colnames = custom_columns
     assert s.colnames == custom_columns
Пример #2
0
 def test_formatter_by_named_column(self):
     """Test one named column"""
     s = NominableSheet(self.data, "test")
     s.name_columns_by_row(0)
     f = NamedColumnFormatter("Column 1", str)
     s.apply_formatter(f)
     assert s.column["Column 1"] == ["1", "4", "7"]
Пример #3
0
 def test_formatter_by_named_columns(self):
     """Test multiple named columns"""
     s = NominableSheet(self.data, "test")
     s.name_columns_by_row(0)
     f = NamedColumnFormatter(["Column 1", "Column 3"], str)
     s.apply_formatter(f)
     assert s.column["Column 1"] == ["1", "4", "7"]
     assert s.column["Column 3"] == ["3", "6", "9"]
Пример #4
0
 def test_formatter_by_named_row2(self):
     """Test a list of string as index"""
     s = NominableSheet(self.data, "test")
     s.name_rows_by_column(0)
     f = NamedRowFormatter(["Row 1", "Row 2"], str)
     s.apply_formatter(f)
     assert s.row["Row 1"] == ["1", "2", "3"]
     assert s.row["Row 2"] == ["4", "5", "6"]
Пример #5
0
 def test_add(self):
     s = NominableSheet(self.data, "test")
     s.name_columns_by_row(0)
     data = OrderedDict({
         "Column 4": [10, 11, 12]
     })
     s = s.column + data
     assert s.column["Column 4"] == [10, 11, 12]
Пример #6
0
 def test_add(self):
     s = NominableSheet(self.data, "test")
     s.name_rows_by_column(0)
     data = OrderedDict({
         "Row 5": [10, 11, 12]
         }
     )
     s = s.row + data
     assert s.row["Row 5"] == [10, 11, 12]
Пример #7
0
 def test_extend_rows_using_wrong_data_type(self):
     s = NominableSheet(self.data, "test")
     s.name_rows_by_column(0)
     s.extend_rows([1, 2])
Пример #8
0
 def test_formatter_by_named_column_2(self):
     s = NominableSheet(self.data, "test")
     s.name_columns_by_row(2)
     s.column.format("Column 1", str)
     assert s.column["Column 1"] == ["1", "4", "7"]
Пример #9
0
 def test_set_indexed_column(self):
     s = NominableSheet(self.data, "test", name_rows_by_column=0)
     s.column[0] = [12, 3, 4, 5]
     assert s.column[0] == [12, 3, 4, 5]
Пример #10
0
 def test_set_named_row(self):
     s = NominableSheet(self.data, "test")
     s.name_rows_by_column(0)
     s.row["Row 2"] = [11, 11, 11]
     assert s.row["Row 2"] == [11, 11, 11]
Пример #11
0
 def test_delete_indexed_row2(self):
     s = NominableSheet(self.data, "test")
     s.name_rows_by_column(0)
     s.delete_named_row_at(2)
     assert s.number_of_rows() == 3
     s.row["Row 2"]  # already deleted
Пример #12
0
 def test_add_wrong_type(self):
     s = NominableSheet(self.data, "test")
     s.name_rows_by_column(0)
     s = s.row + "string type"  # bang
Пример #13
0
 def test_delete_named_column(self):
     s = NominableSheet(self.data, "test")
     s.name_columns_by_row(2)
     del s.column["Column 2"]
     assert s.number_of_columns() == 2
     s.column["Column 2"]  # bang
Пример #14
0
 def test_row_series_to_dict(self):
     s = NominableSheet(self.data, "test")
     s.name_rows_by_column(0)
     content = s.to_dict(True)
     keys = ["Row 0", "Row 1", "Row 2", "Row 3"]
     assert keys == list(content.keys())
Пример #15
0
 def test_formatter_by_named_row_2(self):
     s = NominableSheet(self.data, "test")
     s.name_rows_by_column(0)
     s.row.format("Row 1", str)
     assert s.row["Row 1"] == ["1", "2", "3"]
Пример #16
0
 def test_rownames(self):
     s = NominableSheet(self.data, "test", name_rows_by_column=0)
     assert s.rownames == ["Row 0", "Row 1", "Row 2", "Row 3"]
     custom_rows = ["R0", "R1", "R2", "R3"]
     s.rownames = custom_rows
     assert s.rownames == custom_rows
Пример #17
0
 def test_formatter_by_named_row(self):
     s = NominableSheet(self.data, "test")
     s.name_rows_by_column(0)
     f = NamedRowFormatter("Row 1", str)
     s.apply_formatter(f)
     assert s.row["Row 1"] == ["1", "2", "3"]
Пример #18
0
 def test_set_indexed_row(self):
     s = NominableSheet(self.data, "test")
     s.name_columns_by_row(2)
     s.row[0] = [10000, 1, 11]
     assert s.row[0] == [10000, 1, 11]
Пример #19
0
 def test_add_wrong_type(self):
     """Add string type"""
     s = NominableSheet(self.data, "test")
     s.name_columns_by_row(0)
     s = s.column + "string type"  # bang
Пример #20
0
 def test_delete_indexed_column(self):
     s = NominableSheet(self.data, "test")
     s.name_columns_by_row(0)
     s.delete_named_column_at(1)
     assert s.number_of_columns() == 2
     s.column["Column 2"]  # access it after deletion, bang