Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
This makes sure all additional tests from #628 are included
  • Loading branch information
niccokunzmann committed Jun 19, 2024
2 parents a799e4c + e7ec88d commit 4583615
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ Bug fixes:

Minor changes:

- Guide to delete the build folder before running tests
- Add funding information
- Make documentation build with Python 3.12
- Update windows to olson conversion for Greenland Standard Time
- Extend examples in Usage with alarm and recurrence
- Document how to serve the built documentation to view with the browser
- Improve test coverage

Breaking changes:

Expand Down
11 changes: 9 additions & 2 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ Try it out:
>>> icalendar.__version__
'5.0.12'
Building the documentation locally
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Building the documentation
--------------------------
To build the documentation follow these steps:
Expand All @@ -136,3 +136,10 @@ You can also use ``tox`` to build the documentation:
cd icalendar
tox -e docs
If you would like to serve the documentation and access it from your browser,
you can run the HTTP server:
.. code-block:: bash
python3 -m http.server -d docs/_build/html/
8 changes: 8 additions & 0 deletions src/icalendar/tests/prop/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,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 icalendar.prop import vInt
Expand Down Expand Up @@ -58,6 +59,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_vDuration(self):
from icalendar.prop import vDuration
Expand Down Expand Up @@ -250,6 +252,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 icalendar.prop import vUri

Expand All @@ -273,6 +277,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 icalendar.prop import vUTCOffset
Expand Down Expand Up @@ -314,10 +319,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 icalendar.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')
Expand Down
6 changes: 6 additions & 0 deletions src/icalendar/tests/prop/test_vBoolean.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from icalendar.prop import vBoolean
import pytest

def test_true():
assert (vBoolean(True).to_ical() == b'TRUE')
Expand All @@ -9,3 +10,8 @@ def test_false():
def test_roundtrip():
assert (vBoolean.from_ical(vBoolean(True).to_ical()) == True)
assert (vBoolean.from_ical('true') == True)

def test_error():
"""Error: key not exists"""
with pytest.raises(ValueError):
vBoolean.from_ical('ture')
11 changes: 10 additions & 1 deletion src/icalendar/tests/prop/test_vDDDTypes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from icalendar.prop import vDDDTypes
from datetime import date, datetime, timedelta
from datetime import date, datetime, timedelta, time
import pytest


Expand All @@ -21,3 +21,12 @@ def test_timedelta():
def test_bad_input():
with pytest.raises(ValueError):
vDDDTypes(42)

def test_time_from_string():
assert vDDDTypes.from_ical('123000') == time(12, 30)
assert isinstance(vDDDTypes.from_ical('123000'), time)

def test_invalid_period_to_ical():
invalid_period = (datetime(2000, 1, 1), datetime(2000, 1, 2), datetime(2000, 1, 2))
with pytest.raises(ValueError):
vDDDTypes(invalid_period).to_ical()
16 changes: 16 additions & 0 deletions src/icalendar/tests/prop/test_vPeriod.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
from icalendar.prop import vPeriod
from datetime import datetime, timedelta
import pytest


class TestProp(unittest.TestCase):
Expand Down Expand Up @@ -47,3 +48,18 @@ def test_timezoned(tzp):
def test_timezoned_with_timedelta(tzp):
p = vPeriod((tzp.localize(datetime(2000, 1, 1), 'Europe/Copenhagen'), timedelta(days=31)))
assert p.to_ical() == b'20000101T000000/P31D'


@pytest.mark.parametrize(
"params",
[
('20000101T000000', datetime(2000, 1, 2)),
(datetime(2000, 1, 1), '20000102T000000'),
(datetime(2000, 1, 2), datetime(2000, 1, 1)),
(datetime(2000, 1, 2), timedelta(-1)),
]
)
def test_invalid_parameters(params):
"""The parameters are of wrong type or of wrong order."""
with pytest.raises(ValueError):
vPeriod(params)
15 changes: 9 additions & 6 deletions src/icalendar/tests/test_with_doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ def test_docstring_of_python_file(module_name):
# This collection needs to exclude .tox and other subdirectories
DOCUMENTATION_PATH = os.path.join(HERE, "../../../")

DOCUMENT_PATHS = [
os.path.join(DOCUMENTATION_PATH, subdir, filename)
for subdir in ["docs", "."]
for filename in os.listdir(os.path.join(DOCUMENTATION_PATH, subdir))
if filename.lower().endswith(".rst")
]
try:
DOCUMENT_PATHS = [
os.path.join(DOCUMENTATION_PATH, subdir, filename)
for subdir in ["docs", "."]
for filename in os.listdir(os.path.join(DOCUMENTATION_PATH, subdir))
if filename.lower().endswith(".rst")
]
except FileNotFoundError:
raise EnvironmentError("Could not find the documentation - remove the build folder and try again.")

@pytest.mark.parametrize("filename", [
"README.rst",
Expand Down

0 comments on commit 4583615

Please sign in to comment.