-
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,9 @@ def test_prop_vBoolean(self): | |
self.assertEqual(vBoolean.from_ical(vBoolean(True).to_ical()), True) | ||
self.assertEqual(vBoolean.from_ical('true'), True) | ||
|
||
# Error: key not exists | ||
self.assertRaises(ValueError, vBoolean.from_ical, 'ture') | ||
|
||
def test_prop_vCalAddress(self): | ||
from ..prop import vCalAddress | ||
txt = b'MAILTO:[email protected]' | ||
|
@@ -65,6 +68,7 @@ def test_prop_vFloat(self): | |
self.assertEqual(vFloat(1.0).to_ical(), b'1.0') | ||
self.assertEqual(vFloat.from_ical('42'), 42.0) | ||
self.assertEqual(vFloat(42).to_ical(), b'42.0') | ||
self.assertRaises(ValueError, vFloat.from_ical, '1s3') | ||
|
||
def test_prop_vInt(self): | ||
from ..prop import vInt | ||
|
@@ -107,10 +111,16 @@ def test_prop_vDDDTypes(self): | |
|
||
self.assertTrue(isinstance(vDDDTypes.from_ical('20010101'), date)) | ||
|
||
self.assertEqual(vDDDTypes.from_ical('123000'), time(12, 30)) | ||
self.assertIsInstance(vDDDTypes.from_ical('123000'), time) | ||
|
||
self.assertEqual(vDDDTypes.from_ical('P31D'), timedelta(31)) | ||
|
||
self.assertEqual(vDDDTypes.from_ical('-P31D'), timedelta(-31)) | ||
|
||
invalid_period = (datetime(2000, 1, 1), datetime(2000, 1, 2), datetime(2000, 1, 2)) | ||
self.assertRaises(ValueError, vDDDTypes(invalid_period).to_ical) | ||
|
||
# Bad input | ||
self.assertRaises(ValueError, vDDDTypes, 42) | ||
|
||
|
@@ -123,6 +133,7 @@ def test_prop_vDate(self): | |
self.assertEqual(vDate.from_ical('20010102'), date(2001, 1, 2)) | ||
|
||
self.assertRaises(ValueError, vDate, 'd') | ||
self.assertRaises(ValueError, vDate.from_ical, '200102') | ||
|
||
def test_prop_vDatetime(self): | ||
from ..prop import vDatetime | ||
|
@@ -205,6 +216,17 @@ def test_prop_vPeriod(self): | |
self.assertEqual(vPeriod(per).to_ical(), | ||
b'20000101T000000/20000102T000000') | ||
|
||
# Error: one of the params is not instance of date/datetime | ||
per = ('20000101T000000', datetime(2000, 1, 2)) | ||
self.assertRaises(ValueError, vPeriod, per) | ||
|
||
per = (datetime(2000, 1, 1), '20000102T000000') | ||
self.assertRaises(ValueError, vPeriod, per) | ||
|
||
# Error: first params > second params | ||
per = (datetime(2000, 1, 2), datetime(2000, 1, 1)) | ||
self.assertRaises(ValueError, vPeriod, per) | ||
|
||
per = (datetime(2000, 1, 1), timedelta(days=31)) | ||
self.assertEqual(vPeriod(per).to_ical(), b'20000101T000000/P31D') | ||
|
||
|
@@ -397,6 +419,8 @@ def test_prop_vTime(self): | |
# We should also fail, right? | ||
self.assertRaises(ValueError, vTime.from_ical, '263000') | ||
|
||
self.assertRaises(ValueError, vTime, '263000') | ||
|
||
def test_prop_vUri(self): | ||
from ..prop import vUri | ||
|
||
|
@@ -420,6 +444,7 @@ def test_prop_vGeo(self): | |
self.assertEqual(vGeo(g).to_ical(), '37.386013;-122.082932') | ||
|
||
self.assertRaises(ValueError, vGeo, 'g') | ||
self.assertRaises(ValueError, vGeo.from_ical, '1s3;1s3') | ||
|
||
def test_prop_vUTCOffset(self): | ||
from ..prop import vUTCOffset | ||
|
@@ -461,10 +486,13 @@ def test_prop_vUTCOffset(self): | |
|
||
self.assertRaises(ValueError, vUTCOffset.from_ical, '+2400') | ||
|
||
self.assertRaises(ValueError, vUTCOffset, '0:00:00') | ||
|
||
def test_prop_vInline(self): | ||
from ..prop import vInline | ||
|
||
self.assertEqual(vInline('Some text'), 'Some text') | ||
self.assertEqual(vInline('Some text').to_ical(), b'Some text') | ||
self.assertEqual(vInline.from_ical('Some text'), 'Some text') | ||
|
||
t2 = vInline('other text') | ||
|