def setUp(self):
        self.logger = logging.getLogger()
        self.client = SmartsheetClient(api_token, logger=self.logger)

        time_str = str(datetime.datetime.utcnow())
        self.new_sheet_name = 'TestRowAddDelete-%s' % time_str

        col_1 = Column("Col 1 - TextNumber",
                       type=CellTypes.TextNumber,
                       primary=True)
        col_2 = Column("Col 2 - Date", type=CellTypes.Date)
        col_3 = Column("Col 3 - Picklist",
                       type=CellTypes.Picklist,
                       options=['Yes', 'No', 'Maybe'])
        col_4 = Column("Col 4 - Checkbox", type=CellTypes.Checkbox)
        col_5 = Column("Col 5 - ContactList", type=CellTypes.ContactList)
        self.columns = [col_1, col_2, col_3, col_4, col_5]

        self.sheet_info = self.client.createSheet(self.new_sheet_name,
                                                  self.columns,
                                                  location='')
        if self.sheet_info is None:
            err = "Failed (probably) to create sheet: %s" % self.new_sheet_name
            self.logger.error(err)
            raise Exception(err)
        self.sheet = self.sheet_info.loadSheet()
        if self.sheet is None:
            err = "Unable to load newly created sheet: %s" % self.new_sheet_name
            self.logger.error(err)
            raise Exception(err)
        self.logger.info("########### Test %s uses Sheet: %s ############",
                         self.__class__.__name__, self.new_sheet_name)
    def setUp(self):
        self.logger = logging.getLogger()
        self.client = SmartsheetClient(api_token, logger=self.logger)

        time_str = str(datetime.datetime.utcnow())
        self.new_sheet_name = 'TestCellAccess-%s' % time_str

        col_1 = Column("Col 1 - TextNumber",
                       type=CellTypes.TextNumber,
                       primary=True)
        col_2 = Column("Col 2 - Date", type=CellTypes.Date)
        col_3 = Column("Col 3 - Picklist",
                       type=CellTypes.Picklist,
                       options=['Yes', 'No', 'Maybe'])
        col_4 = Column("Col 4 - Checkbox", type=CellTypes.Checkbox)
        col_5 = Column("Col 5 - ContactList", type=CellTypes.ContactList)
        col_6 = Column("Col 6 - TextNumber", type=CellTypes.TextNumber)
        self.columns = [col_1, col_2, col_3, col_4, col_5, col_6]

        self.sheet_info = self.client.createSheet(self.new_sheet_name,
                                                  self.columns,
                                                  location='')
        if self.sheet_info is None:
            err = "Failed (probably) to create sheet: %s" % self.new_sheet_name
            self.logger.error(err)
            raise Exception(err)
        self.sheet = self.sheet_info.loadSheet()
        if self.sheet is None:
            err = "Unable to load newly created sheet: %s" % self.new_sheet_name
            self.logger.error(err)
            raise Exception(err)

        self.logger.info("######### Adding Rows to new Sheet ############")

        rw = self.sheet.makeRowWrapper()
        r = rw.makeRow()
        r[0] = "one"
        r[1] = '2014-12-25'
        r[5] = "one.five"
        rw.addRow(r)

        r = rw.makeRow()
        r[0] = "two"
        r[2] = "Yes"
        r[5] = "two.five"
        rw.addRow(r)

        r = rw.makeRow()
        r[0] = "three"
        r[3] = True
        r[5] = "three.five"
        rw.addRow(r)

        self.sheet.addRows(rw)

        self.logger.info("########### Test %s uses Sheet: %s ############",
                         self.__class__.__name__, self.new_sheet_name)
    def setUp(self):
        self.logger = logging.getLogger()
        self.client = SmartsheetClient(api_token, logger=self.logger)

        time_str = str(datetime.datetime.utcnow())
        self.new_sheet_name = 'testSheetCreateDelete-%s' % time_str

        col_1 = Column("Col 1 - TextNumber",
                       type=CellTypes.TextNumber,
                       primary=True)
        col_2 = Column("Col 2 - Date", type=CellTypes.Date)
        col_3 = Column("Col 3 - Picklist",
                       type=CellTypes.Picklist,
                       options=['Yes', 'No', 'Maybe'])
        col_4 = Column("Col 4 - Checkbox", type=CellTypes.Checkbox)
        col_5 = Column("Col 5 - ContactList", type=CellTypes.ContactList)
        self.columns = [col_1, col_2, col_3, col_4, col_5]
        # TODO: Add some system or autonumber columns.
        self.logger.info("########### Test uses Sheet: %s ############",
                         self.new_sheet_name)
Exemplo n.º 4
0
 def setUp(self):
     self.logger = logging.getLogger()
     self.client = SmartsheetClient(api_token, logger=self.logger)