def test_template_create(db, es_clear, templ_doc_public_martigny_data, org_martigny, system_librarian_martigny_no_email): """Test template creation.""" templ_doc_public_martigny_data['toto'] = 'toto' with pytest.raises(ValidationError): temp = Template.create(templ_doc_public_martigny_data, delete_pid=True) db.session.rollback() del templ_doc_public_martigny_data['toto'] temp = Template.create(templ_doc_public_martigny_data, delete_pid=True) assert temp == templ_doc_public_martigny_data assert temp.get('pid') == '1' temp = Template.get_record_by_pid('1') assert temp == templ_doc_public_martigny_data fetched_pid = fetcher(temp.id, temp) assert fetched_pid.pid_value == '1' assert fetched_pid.pid_type == 'tmpl'
def test_template_create(db, es, templ_doc_public_martigny_data, org_martigny, system_librarian_martigny): """Test template creation.""" templ_doc_public_martigny_data['toto'] = 'toto' with pytest.raises(ValidationError): Template.create(templ_doc_public_martigny_data, delete_pid=True) db.session.rollback() next_pid = Template.provider.identifier.next() del templ_doc_public_martigny_data['toto'] temp = Template.create(templ_doc_public_martigny_data, delete_pid=True) next_pid += 1 assert temp == templ_doc_public_martigny_data assert temp.get('pid') == str(next_pid) temp = Template.get_record_by_pid(str(next_pid)) assert temp == templ_doc_public_martigny_data fetched_pid = fetcher(temp.id, temp) assert fetched_pid.pid_value == str(next_pid) assert fetched_pid.pid_type == 'tmpl'