Skip to content

Add new() method to vCalAddress class (fixes #870)#882

Merged
niccokunzmann merged 5 commits into
collective:mainfrom
SashankBhamidi:add-vcaladdress-new-method-issue-870
Jul 22, 2025
Merged

Add new() method to vCalAddress class (fixes #870)#882
niccokunzmann merged 5 commits into
collective:mainfrom
SashankBhamidi:add-vcaladdress-new-method-issue-870

Conversation

@SashankBhamidi

@SashankBhamidi SashankBhamidi commented Jul 17, 2025

Copy link
Copy Markdown
Member

This PR implements the method for the class to provide a consistent API with other icalendar components like .

Changes Made

vCalAddress.new() method implementation:

  • Email as first positional parameter
  • Automatic mailto: prefix handling (adds if missing)
  • All RFC 5545 parameters supported: CN, CUTYPE, DELEGATED-FROM, DELEGATED-TO, DIR, LANGUAGE, PARTSTAT, ROLE, RSVP, SENT-BY
  • Consistent with Event.new() pattern

Comprehensive test suite:

  • 25 test cases covering all parameters and edge cases
  • Integration test with Event attendees
  • Error condition testing
  • Example usage demonstrations

Documentation:

  • Detailed docstring with parameter descriptions
  • Usage examples in docstring
  • RFC 5545 compliance maintained

Example Usage

# Basic usage
addr = vCalAddress.new("user@example.com")

# With parameters
addr = vCalAddress.new(
    "chair@example.com",
    cn="Meeting Chair",
    role="CHAIR",
    rsvp=True
)

# Integration with Event
event = Event.new(summary="Meeting", start=datetime(2026, 1, 1, 12, 0))
attendee = vCalAddress.new("attendee@example.com", cn="John Doe", partstat="ACCEPTED")
event.add("ATTENDEE", attendee)

Testing

All tests pass (25/25) and maintain backward compatibility.

Fixes #870


📚 Documentation preview 📚: https://icalendar--882.org.readthedocs.build/

@SashankBhamidi

Copy link
Copy Markdown
Member Author

All requirements from Issue #870 implemented. Ready for merge.

@coveralls

coveralls commented Jul 17, 2025

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 16389578345

Details

  • 120 of 120 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 97.482%

Totals Coverage Status
Change from base Build 16389139167: 0.04%
Covered Lines: 7114
Relevant Lines: 7287

💛 - Coveralls

Comment thread src/icalendar/cal/event.py Outdated
Comment thread src/icalendar/prop.py Outdated
Comment thread src/icalendar/prop.py Outdated
Comment thread src/icalendar/tests/test_issue_870_vcaladdress_new.py Outdated
Comment thread src/icalendar/tests/test_issue_870_vcaladdress_new.py
Comment thread src/icalendar/tests/test_issue_870_vcaladdress_new.py Outdated
Comment thread src/icalendar/tests/test_issue_870_vcaladdress_new.py
@SashankBhamidi

Copy link
Copy Markdown
Member Author

Looking into the nopytz test failure.

- Add case-insensitive mailto: prefix handling with static helper method
- Implement comprehensive parametrized test structure as suggested
- Fix error type from AttributeError to TypeError
- Add static _get_email() method to avoid code duplication
- Support all RFC 5545 parameters with automatic mailto: handling
- Integration confirmed with Event.new() attendees parameter
- Comprehensive test coverage with 36 test cases
@SashankBhamidi

Copy link
Copy Markdown
Member Author

Ready for merge

  • nopytz test failure resolved (missing import in doctest)
  • All review feedback addressed
  • 36 tests passing

Implementation complete for #870

@SashankBhamidi

Copy link
Copy Markdown
Member Author

@niccokunzmann Could you please review and merge when ready? This would help me continue work on PR #881 without merge conflicts.

Comment thread src/icalendar/prop.py
@niccokunzmann niccokunzmann merged commit 2f6ce64 into collective:main Jul 22, 2025
18 checks passed
@niccokunzmann

Copy link
Copy Markdown
Member

Thanks, this is nice!

@SashankBhamidi SashankBhamidi deleted the add-vcaladdress-new-method-issue-870 branch August 19, 2025 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add new() to vCalAddress

3 participants