Skip to content

Commit

Permalink
bugfix #343 missing default color
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrowgey committed Jun 26, 2018
1 parent 63ce089 commit 22863c2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gcalcli/gcalcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def _select_cals(self, selected_names):
for cal_name in selected_names:
matches = []
for self_cal in self.allCals:
print(self_cal['summary'])
# For exact match, we should match only 1 entry and accept
# the first entry. Should honor access role order since
# it happens after _GetCached()
Expand All @@ -186,7 +185,7 @@ def _select_cals(self, selected_names):

@staticmethod
def _LocalizeDateTime(dt):
if not hasattr(dt, 'tzinfo'):
if not hasattr(dt, 'tzinfo'): # Why are we skipping these?
return dt
if dt.tzinfo is None:
return dt.replace(tzinfo=tzlocal())
Expand Down Expand Up @@ -1633,6 +1632,7 @@ def parse_reminder(rem):
def parse_cal_names(cal_names):
cal_colors = {}
for name in cal_names:
cal_color = 'default'
parts = name.split("#")
parts_count = len(parts)
if parts_count >= 1:
Expand Down
32 changes: 29 additions & 3 deletions tests/test_gcalcli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import sys
from json import load
from datetime import datetime
from dateutil.tz import tzutc

import pytest
from apiclient.discovery import HttpMock, build
Expand All @@ -9,6 +11,7 @@
get_color_parser,
get_cal_query_parser,
get_output_parser,
parse_cal_names,
parse_reminder)

TEST_DATA_DIR = os.path.dirname(os.path.abspath(__file__)) + '/data'
Expand Down Expand Up @@ -86,7 +89,7 @@ def test_list(capsys, PatchedGCalI):


def test_agenda(PatchedGCalI):
PatchedGCalI(calendar=['jcrowgey*#green']).AgendaQuery()
PatchedGCalI().AgendaQuery()


def test_cal_query(capsys, PatchedGCalI):
Expand All @@ -109,7 +112,7 @@ def test_cal_query(capsys, PatchedGCalI):


def test_add_event(PatchedGCalI):
gcal = PatchedGCalI(calendar=['jcrowgey*#green'])
gcal = PatchedGCalI()
title = 'test event'
where = 'anywhere'
start = 'now'
Expand All @@ -121,7 +124,7 @@ def test_add_event(PatchedGCalI):


def test_quick_add(PatchedGCalI):
gcal = PatchedGCalI(calendar=['jcrowgey*#green'])
gcal = PatchedGCalI()
event_text = 'quick test event'
reminder = '5m sms'
gcal.QuickAddEvent(event_text, reminder=[reminder])
Expand Down Expand Up @@ -158,3 +161,26 @@ def test_parse_reminder():

rem = 'invalid reminder'
assert parse_reminder(rem) is None


def test_parse_cal_names(PatchedGCalI):
cal_names = parse_cal_names(['j*#green'])
gcal = PatchedGCalI(cal_names=cal_names)
gcal.AgendaQuery()

cal_names = parse_cal_names(['j*'])
gcal = PatchedGCalI(cal_names=cal_names)
gcal.AgendaQuery()

cal_names = parse_cal_names(['[email protected]'])
gcal = PatchedGCalI(cal_names=cal_names)
gcal.AgendaQuery()


def test_localized_datetime(PatchedGCalI):
dt = GoogleCalendarInterface._LocalizeDateTime(datetime.now())
assert dt.tzinfo is not None

dt = datetime.now(tzutc())
dt = GoogleCalendarInterface._LocalizeDateTime(dt)
assert dt.tzinfo is not None

0 comments on commit 22863c2

Please sign in to comment.