mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
add RequestType SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
511f174c8b
commit
3bf4b3717a
2 changed files with 35 additions and 0 deletions
11
aurweb/models/request_type.py
Normal file
11
aurweb/models/request_type.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
from sqlalchemy import Column, Integer
|
||||||
|
|
||||||
|
from aurweb.models.declarative import Base
|
||||||
|
|
||||||
|
|
||||||
|
class RequestType(Base):
|
||||||
|
__tablename__ = "RequestTypes"
|
||||||
|
|
||||||
|
ID = Column(Integer, primary_key=True)
|
||||||
|
|
||||||
|
__mapper_args__ = {"primary_key": [ID]}
|
24
test/test_request_type.py
Normal file
24
test/test_request_type.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from aurweb.db import create, delete
|
||||||
|
from aurweb.models.request_type import RequestType
|
||||||
|
from aurweb.testing import setup_test_db
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def setup():
|
||||||
|
setup_test_db()
|
||||||
|
|
||||||
|
|
||||||
|
def test_request_type_creation():
|
||||||
|
request_type = create(RequestType, Name="Test Request")
|
||||||
|
assert bool(request_type.ID)
|
||||||
|
assert request_type.Name == "Test Request"
|
||||||
|
delete(RequestType, RequestType.ID == request_type.ID)
|
||||||
|
|
||||||
|
|
||||||
|
def test_request_type_null_name_returns_empty_string():
|
||||||
|
request_type = create(RequestType)
|
||||||
|
assert bool(request_type.ID)
|
||||||
|
assert request_type.Name == str()
|
||||||
|
delete(RequestType, RequestType.ID == request_type.ID)
|
Loading…
Add table
Reference in a new issue