mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
add RelationType SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
e401b92acb
commit
a9cfbce11e
2 changed files with 43 additions and 0 deletions
11
aurweb/models/relation_type.py
Normal file
11
aurweb/models/relation_type.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
from sqlalchemy.orm import mapper
|
||||||
|
|
||||||
|
from aurweb.schema import RelationTypes
|
||||||
|
|
||||||
|
|
||||||
|
class RelationType:
|
||||||
|
def __init__(self, Name: str = None):
|
||||||
|
self.Name = Name
|
||||||
|
|
||||||
|
|
||||||
|
mapper(RelationType, RelationTypes)
|
32
test/test_relation_type.py
Normal file
32
test/test_relation_type.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
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"
|
Loading…
Add table
Reference in a new issue