Skip to content
Snippets Groups Projects
Commit 943d97ef authored by Kevin Morris's avatar Kevin Morris
Browse files

add License SQLAlchemy ORM model


Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent 38dc2bb9
No related branches found
No related tags found
No related merge requests found
from sqlalchemy.orm import mapper
from aurweb.schema import Licenses
class License:
def __init__(self, Name: str = None):
self.Name = Name
mapper(License, Licenses)
import pytest
from sqlalchemy.exc import IntegrityError
from aurweb.db import create
from aurweb.models.license import License
from aurweb.testing import setup_test_db
@pytest.fixture(autouse=True)
def setup():
setup_test_db("Licenses")
def test_license_creation():
license = create(License, Name="Test License")
assert bool(license.ID)
assert license.Name == "Test License"
def test_license_null_name_raises_exception():
from aurweb.db import session
with pytest.raises(IntegrityError):
create(License)
session.rollback()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment