improved testing of ical parser
This commit is contained in:
parent
71d89d45d8
commit
42e66abf90
@ -1,26 +1,42 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from inkycal.modules.ical_parser import iCalendar
|
from inkycal.modules.ical_parser import iCalendar
|
||||||
|
from urllib.request import urlopen
|
||||||
import arrow
|
import arrow
|
||||||
|
import os
|
||||||
|
|
||||||
ical = iCalendar()
|
ical = iCalendar()
|
||||||
|
test_ical = 'https://calendar.google.com/calendar/ical/en.usa%23holiday%40group.v.calendar.google.com/public/basic.ics'
|
||||||
|
|
||||||
class ical_parser_test(unittest.TestCase):
|
class ical_parser_test(unittest.TestCase):
|
||||||
|
|
||||||
def test_load_url(self):
|
def test_load_url(self):
|
||||||
print('testing loading via URL')
|
print('testing loading via URL...', end="")
|
||||||
ical.load_url('https://calendar.google.com/calendar/ical/en.usa%23holiday%40group.v.calendar.google.com/public/basic.ics')
|
ical.load_url(test_ical)
|
||||||
|
print('OK')
|
||||||
|
|
||||||
def test_get_events(self):
|
def test_get_events(self):
|
||||||
print('testing parsing of events')
|
print('testing parsing of events...', end="")
|
||||||
ical.get_events(arrow.now(), arrow.now().shift(weeks=30))
|
ical.get_events(arrow.now(), arrow.now().shift(weeks=30))
|
||||||
|
print('OK')
|
||||||
|
|
||||||
def test_sorting(self):
|
def test_sorting(self):
|
||||||
print('testing sorting of events')
|
print('testing sorting of events...', end="")
|
||||||
ical.sort()
|
ical.sort()
|
||||||
|
print('OK')
|
||||||
|
|
||||||
def test_show_events(self):
|
def test_show_events(self):
|
||||||
print('testing if events can be shown')
|
print('testing if events can be shown...', end="")
|
||||||
ical.show_events()
|
ical.show_events()
|
||||||
|
print('OK')
|
||||||
|
|
||||||
|
def test_laod_from_file(self):
|
||||||
|
print('testing loading from file...', end="")
|
||||||
|
dummy = str(urlopen(test_ical).read().decode())
|
||||||
|
with open('dummy.ical', mode="w") as file:
|
||||||
|
file.write(dummy)
|
||||||
|
ical.load_from_file('dummy.ical')
|
||||||
|
print('OK')
|
||||||
|
os.remove('dummy.ical')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user