Commit a9cfbce1 authored by Kevin Morris's avatar Kevin Morris
Browse files

add RelationType SQLAlchemy ORM model


Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent e401b92a
from sqlalchemy.orm import mapper
from aurweb.schema import RelationTypes
class RelationType:
def __init__(self, Name: str = None):
self.Name = Name
mapper(RelationType, RelationTypes)
import pytest
from aurweb.db import create, delete, query
from aurweb.models.relation_type import RelationType
from aurweb.testing import setup_test_db
@pytest.fixture(autouse=True)
def setup():
setup_test_db()
def test_relation_type_creation():
relation_type = create(RelationType, Name="test-relation")
assert bool(relation_type.ID)
assert relation_type.Name == "test-relation"
delete(RelationType, RelationType.ID == relation_type.ID)
def test_relation_types():
conflicts = query(RelationType, RelationType.Name == "conflicts").first()
assert conflicts is not None
assert conflicts.Name == "conflicts"
provides = query(RelationType, RelationType.Name == "provides").first()
assert provides is not None
assert provides.Name == "provides"
replaces = query(RelationType, RelationType.Name == "replaces").first()
assert replaces is not None
assert replaces.Name == "replaces"
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