Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_due_full(self):
self.cache.buffer[0] = "* [ ] Random task (2015-08-08 15:15)"
vwtask = self.VimwikiTask.from_line(self.cache, 0)
assert vwtask['description'] == u"Random task"
assert vwtask['due'] == local_zone.localize(datetime(2015,8,8,15,15))
assert vwtask['uuid'] == None
assert vwtask['priority'] == None
assert vwtask['indent'] == ''
def execute(self):
self.command("w", regex="written$", lines=1)
# Check that only one tasks with this description exists
assert len(self.tw.tasks.pending()) == 1
due = datetime(2015, 3, 3, 0, 0)
task = self.tw.tasks.pending()[0]
assert task['description'] == 'This is a test task'
assert task['status'] == 'pending'
assert task['due'] == local_zone.localize(due)
def current_year():
return local_zone.localize(datetime.now()).year
def test_due_short(self):
self.cache.buffer[0] = "* [ ] Random task (2015-08-08)"
vwtask = self.VimwikiTask.from_line(self.cache, 0)
assert vwtask['description'] == u"Random task"
assert vwtask['due'] == local_zone.localize(datetime(2015,8,8,0,0))
assert vwtask['uuid'] == None
assert vwtask['priority'] == None
assert vwtask['indent'] == ''
def execute(self):
self.client.type('2gg')
self.command(
"TaskWikiStop",
regex="Task \"test task 2\" stopped.$",
lines=1)
for task in self.tasks:
task.refresh()
now = local_zone.localize(datetime.now())
assert self.tasks[0]['status'] == "pending"
assert self.tasks[1]['status'] == "pending"
assert (now - self.tasks[0]['start']).total_seconds() < 30
assert (self.tasks[0]['start'] - now).total_seconds() < 30
assert self.tasks[1]['start'] == None
def current_month():
current_month_number = local_zone.localize(datetime.now()).month
months = ["January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"]
return months[current_month_number - 1]
def is_local_midnight(timestamp):
return timestamp.astimezone(local_zone).time() == time(0,0,0)
def set_default_time(timestamp):
return timestamp.astimezone(local_zone).replace(
hour=DEFAULT_TIME.hour,
minute=DEFAULT_TIME.minute,
second=DEFAULT_TIME.second,
)