How to use the todoman.model.VtodoWritter function in todoman

To help you get started, we’ve selected a few todoman examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pimutils / todoman / tests / test_backend.py View on Github external
def test_serialize_created_at(todo_factory):
    now = datetime.now(tz=pytz.UTC)
    todo = todo_factory(created_at=now)
    vtodo = VtodoWritter(todo).serialize()

    assert vtodo.get('created') is not None
github pimutils / todoman / tests / test_backend.py View on Github external
def test_vtodo_serialization(todo_factory):
    """Test VTODO serialization: one field of each type."""
    description = 'A tea would be nice, thanks.'
    todo = todo_factory(
        categories=['tea', 'drinking', 'hot'],
        description=description,
        due=datetime(3000, 3, 21),
        start=date(3000, 3, 21),
        priority=7,
        status='IN-PROCESS',
        summary='Some tea',
        rrule='FREQ=MONTHLY',
    )
    writer = VtodoWritter(todo)
    vtodo = writer.serialize()

    assert (
        [str(c) for c in vtodo.get('categories').cats] ==
        ['tea', 'drinking', 'hot']
    )
    assert str(vtodo.get('description')) == description
    assert vtodo.get('priority') == 7
    assert vtodo.decoded('due') == datetime(3000, 3, 21, tzinfo=tzlocal())
    assert vtodo.decoded('dtstart') == date(3000, 3, 21)
    assert str(vtodo.get('status')) == 'IN-PROCESS'
    assert vtodo.get('rrule') == icalendar.vRecur.from_ical('FREQ=MONTHLY')
github pimutils / todoman / tests / test_backend.py View on Github external
def test_normalize_datetime():
    writter = VtodoWritter(None)
    assert (
        writter.normalize_datetime(date(2017, 6, 17)) == date(2017, 6, 17)
    )
    assert (
        writter.normalize_datetime(datetime(2017, 6, 17)) == datetime(
            2017, 6, 17, tzinfo=tzlocal()
        )
    )
    assert (
        writter.normalize_datetime(datetime(2017, 6, 17, 12, 19)) == datetime(
            2017, 6, 17, 12, 19, tzinfo=tzlocal()
        )
    )
    assert (
        writter.normalize_datetime(
            datetime(2017, 6, 17, 12, tzinfo=tzlocal())
github pimutils / todoman / tests / test_backend.py View on Github external
def test_serializer_raises(todo_factory):
    todo = todo_factory()
    writter = VtodoWritter(todo)

    with pytest.raises(Exception):
        writter.serialize_field('nonexistant', 7)
github pimutils / todoman / tests / test_backend.py View on Github external
def test_serialize_dtstart(todo_factory):
    now = datetime.now(tz=pytz.UTC)
    todo = todo_factory(start=now)
    vtodo = VtodoWritter(todo).serialize()

    assert vtodo.get('dtstart') is not None
github pimutils / todoman / todoman / model.py View on Github external
def save(self, todo):
        todo.sequence += 1
        vtodo = VtodoWritter(todo).write()

        self.cache.expire_file(todo.path)
        mtime = _getmtime(todo.path)

        self.cache.add_file(todo.list.name, todo.path, mtime)
        todo.id = self.cache.add_vtodo(vtodo, todo.path, todo.id)
        self.cache.save_to_disk()