From 32f289309579554d85a9971be59ccc24c973840c Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Mon, 29 Mar 2021 15:20:26 -0700 Subject: [PATCH] add aurweb.models.account_type.AccountType Signed-off-by: Kevin Morris --- aurweb/models/__init__.py | 0 aurweb/models/account_type.py | 20 ++++++++++++++++++++ test/test_account_type.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 aurweb/models/__init__.py create mode 100644 aurweb/models/account_type.py create mode 100644 test/test_account_type.py diff --git a/aurweb/models/__init__.py b/aurweb/models/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/aurweb/models/account_type.py b/aurweb/models/account_type.py new file mode 100644 index 00000000..44225e35 --- /dev/null +++ b/aurweb/models/account_type.py @@ -0,0 +1,20 @@ +from sqlalchemy.orm import mapper + +from aurweb.schema import AccountTypes + + +class AccountType: + """ An ORM model of a single AccountTypes record. """ + + def __init__(self, **kwargs): + self.AccountType = kwargs.pop("AccountType") + + def __str__(self): + return str(self.AccountType) + + def __repr__(self): + return "" % ( + self.ID, str(self)) + + +mapper(AccountType, AccountTypes, confirm_deleted_rows=False) diff --git a/test/test_account_type.py b/test/test_account_type.py new file mode 100644 index 00000000..b6a12363 --- /dev/null +++ b/test/test_account_type.py @@ -0,0 +1,28 @@ +import pytest + +from aurweb.models.account_type import AccountType +from aurweb.testing import setup_test_db + + +@pytest.fixture(autouse=True) +def setup(): + setup_test_db() + + +def test_account_type(): + """ Test creating an AccountType, and reading its columns. """ + from aurweb.db import session + account_type = AccountType(AccountType="TestUser") + session.add(account_type) + session.commit() + + # Make sure it got created and was given an ID. + assert bool(account_type.ID) + + # Next, test our string functions. + assert str(account_type) == "TestUser" + assert repr(account_type) == \ + "" % ( + account_type.ID) + + session.delete(account_type)