Anton Shestakov <av6@dwimlabs.net>, Sun, 17 Jul 2016 05:23:08 +0800
utils: adopt now() (renamed to timestamp()) and parse_timestamp(), test them
tests/test_models.py
Permissions: -rw-r--r--
from datetime import datetime, timedelta from candolint.models import database, Project, Change, Check with database.transaction(): url='https://example.com/alice/test-models', project.domain = 'example.com' project.name = 'hello-world' assert project.get_title() == 'alice/hello-world' project.domain = 'hello-world.com' assert project.get_title() == 'hello-world.com/central' check = Check(started=now) check.finished = now + timedelta(seconds=10) assert check.get_duration() == '10 sec' check.finished = now + timedelta(minutes=5) assert check.get_duration() == '5 min' check.finished = now + timedelta(hours=2) assert check.get_duration() == '120 min' def test_manual_upsert(): 'node': '92cfceb39d57d914ed8b14d0e37643de0797ae56', 'message': 'project: add a thing', 'project': Project.get(name='test-models') with database.transaction(): change, created = Change.manual_upsert(**data) assert change is not None change = Change.get(id=change.id) with database.transaction(): change, created = Change.manual_upsert(**data) assert change is not None change = Change.get(id=change.id) assert change.rev is None assert change.id == old_id