def test_action(fake_datetime): fake_datetime.now = Mock( return_value=datetime.strptime('19:00:00', '%H:%M:%S')) settings = load_settings( '.' ) # we run tests from outside src folder so we have to change path to settings file act = Action(settings) act.ifttt_action = Mock() act.calendar_action = Mock() act.sheet_action = Mock() act.action('white') act.ifttt_action.assert_called_with( 'white', { 'type': 'ifttt', 'summary': 'white_amazon_dash', 'value1': '', 'value2': '', 'value3': '' }) act.calendar_action.assert_called_with( 'white', { 'type': 'calendar', 'calendar_id': '*****@*****.**', 'dashboard': 'anna_work_out', 'restart': 15, 'autoclose': 10800, 'default': 900, 'summary': 'Physiotherapy' }) act.sheet_action.assert_called_with( 'white', { 'type': 'sheet', 'name': 'amazon_dash', 'press_sheet': 'press', 'event_sheet': 'event', 'restart': 15, 'autoclose': 10800, 'default': 900, 'summary': 'Physiotherapy' })
} request = self.service.spreadsheets().batchUpdate( spreadsheetId=self.spreadSheetId, body=COPY_FORMATTING_REQUEST) return request.execute() def get_rows(self, sheet, row=1, rows=1, cols=3): """row 0-based""" result = self.service.spreadsheets().values().get( spreadsheetId=self.spreadSheetId, range='{sheet}!A{row}:{last_col}{last_row}'.format( sheet=sheet, row=row + 1, last_col=chr(ord('A') + cols - 1), last_row=row + rows - 1), valueRenderOption='UNFORMATTED_VALUE').execute() values = result.get('values', []) return values def from_serial_time(self, serial): """Converts google 'serial number' date-time to datetime """ return datetime.datetime(year=1899, month=12, day=30) + datetime.timedelta(days=serial) if __name__ == "__main__": from amazon_dash import load_settings settings = load_settings() sheet = Sheet(settings, 'amazon_dash') row, event = sheet.get_last_event('white') print(event)