mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
add Group SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
e1ab02c2bf
commit
b692b11f62
2 changed files with 32 additions and 0 deletions
11
aurweb/models/group.py
Normal file
11
aurweb/models/group.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
from sqlalchemy.orm import mapper
|
||||||
|
|
||||||
|
from aurweb.schema import Groups
|
||||||
|
|
||||||
|
|
||||||
|
class Group:
|
||||||
|
def __init__(self, Name: str = None):
|
||||||
|
self.Name = Name
|
||||||
|
|
||||||
|
|
||||||
|
mapper(Group, Groups)
|
21
test/test_group.py
Normal file
21
test/test_group.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from sqlalchemy.exc import IntegrityError
|
||||||
|
|
||||||
|
from aurweb.db import create, delete, get_engine
|
||||||
|
from aurweb.models.group import Group
|
||||||
|
|
||||||
|
|
||||||
|
def test_group_creation():
|
||||||
|
get_engine()
|
||||||
|
group = create(Group, Name="Test Group")
|
||||||
|
assert bool(group.ID)
|
||||||
|
assert group.Name == "Test Group"
|
||||||
|
delete(Group, Group.ID == group.ID)
|
||||||
|
|
||||||
|
|
||||||
|
def test_group_null_name_raises_exception():
|
||||||
|
from aurweb.db import session
|
||||||
|
with pytest.raises(IntegrityError):
|
||||||
|
create(Group)
|
||||||
|
session.rollback()
|
Loading…
Add table
Reference in a new issue