def test_get_workbook(self): workbook = excel.get_workbook(excel_file_contents) self.assertEqual(workbook.sheet_names(), [u'Sheet1'])
from __future__ import unicode_literals from django.core.exceptions import ValidationError from unittest import TestCase from xamcheck_utils import excel from os.path import abspath, dirname, join, normpath CURRENT_DIR = dirname(abspath(__file__)) EXCEL_FILES_ROOT = normpath(join(CURRENT_DIR, 'data/excel-files')) excel_file_path = normpath(join(EXCEL_FILES_ROOT, "excel1.xlsx")) with open(excel_file_path, 'rb') as excel_file: excel_file_contents = excel_file.read() workbook = excel.get_workbook(excel_file_contents) class TestUtilsExcelUtils(TestCase): def test_get_workbook(self): workbook = excel.get_workbook(excel_file_contents) self.assertEqual(workbook.sheet_names(), [u'Sheet1']) def test_get_worksheet_by_index(self): worksheet = excel.get_worksheet_by_index(workbook, 0) self.assertEqual(worksheet.columns_from_right_to_left, 0) def test_get_worksheet_by_name(self): worksheet = excel.get_worksheet_by_name(workbook, 'Sheet1') self.assertEqual(worksheet.columns_from_right_to_left, 0)
from unittest import TestCase # Third Party Stuff from django.core.exceptions import ValidationError # Xamcheck-Utils Stuff from xamcheck_utils import excel CURRENT_DIR = dirname(abspath(__file__)) EXCEL_FILES_ROOT = normpath(join(CURRENT_DIR, 'data/excel-files')) excel_file_path = normpath(join(EXCEL_FILES_ROOT, "excel1.xlsx")) with open(excel_file_path, 'rb') as excel_file: excel_file_contents = excel_file.read() workbook = excel.get_workbook(excel_file_contents) class TestUtilsExcelUtils(TestCase): def test_get_workbook(self): workbook = excel.get_workbook(excel_file_contents) self.assertEqual(workbook.sheet_names(), [u'Sheet1']) def test_get_worksheet_by_index(self): worksheet = excel.get_worksheet_by_index(workbook, 0) self.assertEqual(worksheet.columns_from_right_to_left, 0) def test_get_worksheet_by_name(self): worksheet = excel.get_worksheet_by_name(workbook, 'Sheet1') self.assertEqual(worksheet.columns_from_right_to_left, 0)