mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
aurweb.db: add query, create, delete helpers
Takes sqlalchemy kwargs or stanzas: query(Model, Model.Column == value) query(Model, and_(Model.Column == value, Model.Column != "BAD!")) Updated tests to reflect the new utility and a comment about upcoming function deprecation is added to get_account_type(). From here on, phase out the use of get_account_type(). + aurweb.db: Added create utility function + aurweb.db: Added delete utility function The `delete` function can be used to delete a record by search kwargs directly. Example: delete(User, User.ID == 6) All three functions added in this commit are typically useful to perform these operations without having to import aurweb.db.session. Removes a bit of redundancy overall. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
5185df629e
commit
a836892cde
5 changed files with 84 additions and 9 deletions
|
@ -1,5 +1,8 @@
|
|||
import pytest
|
||||
|
||||
import aurweb.config
|
||||
|
||||
from aurweb.db import query
|
||||
from aurweb.models.account_type import AccountType
|
||||
from aurweb.models.user import User
|
||||
from aurweb.testing import setup_test_db
|
||||
|
@ -26,7 +29,6 @@ def test_user():
|
|||
Salt="efgh", ResetKey="blahblah")
|
||||
session.add(user)
|
||||
session.commit()
|
||||
|
||||
assert user in account_type.users
|
||||
|
||||
# Make sure the user was created and given an ID.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue