Commit 068c8ba6 authored by Kevin Morris's avatar Kevin Morris
Browse files

add DependencyType SQLAlchemy ORM model


Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent 4201348d
from sqlalchemy.orm import mapper
from aurweb.schema import DependencyTypes
class DependencyType:
def __init__(self, Name: str = None):
self.Name = Name
mapper(DependencyType, DependencyTypes)
import pytest
from aurweb.db import create, delete, query
from aurweb.models.dependency_type import DependencyType
from aurweb.testing import setup_test_db
@pytest.fixture(autouse=True)
def setup():
setup_test_db()
def test_dependency_types():
dep_types = ["depends", "makedepends", "checkdepends", "optdepends"]
for dep_type in dep_types:
dependency_type = query(DependencyType,
DependencyType.Name == dep_type).first()
assert dependency_type is not None
def test_dependency_type_creation():
dependency_type = create(DependencyType, Name="Test Type")
assert bool(dependency_type.ID)
assert dependency_type.Name == "Test Type"
delete(DependencyType, DependencyType.ID == dependency_type.ID)
def test_dependency_type_null_name_uses_default():
dependency_type = create(DependencyType)
assert dependency_type.Name == str()
delete(DependencyType, DependencyType.ID == dependency_type.ID)
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