def test_get_template_versions(sample_template): original_content = sample_template.content sample_template.content = 'new version' dao_update_template(sample_template) versions = dao_get_template_versions(service_id=sample_template.service_id, template_id=sample_template.id) assert len(versions) == 2 versions = sorted(versions, key=lambda x: x.version) assert versions[0].content == original_content assert versions[1].content == 'new version' assert versions[0].created_at == versions[1].created_at assert versions[0].updated_at is None assert versions[1].updated_at is not None from app.schemas import template_history_schema v = template_history_schema.load(versions, many=True) assert len(v) == 2