Commit 29db2ee5 authored by Kevin Morris's avatar Kevin Morris
Browse files

add Term SQLAlchemy ORM model


Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent fb210158
from sqlalchemy.orm import mapper
from aurweb.schema import Terms
class Term:
def __init__(self,
Description: str = None, URL: str = None,
Revision: int = None):
self.Description = Description
self.URL = URL
self.Revision = Revision
mapper(Term, Terms)
import pytest
from sqlalchemy.exc import IntegrityError
from aurweb.db import create, delete
from aurweb.models.term import Term
def test_term_creation():
term = create(Term, Description="Term description",
URL="https://fake_url.io")
assert bool(term.ID)
assert term.Description == "Term description"
assert term.URL == "https://fake_url.io"
assert term.Revision == 1
delete(Term, Term.ID == term.ID)
def test_term_null_description_raises_exception():
from aurweb.db import session
with pytest.raises(IntegrityError):
create(Term, URL="https://fake_url.io")
session.rollback()
def test_term_null_url_raises_exception():
from aurweb.db import session
with pytest.raises(IntegrityError):
create(Term, Description="Term description")
session.rollback()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment