Skip to content

Commit

Permalink
Added modles testts using scope
Browse files Browse the repository at this point in the history
  • Loading branch information
circulon committed Sep 10, 2024
1 parent c9f4065 commit c4bc92b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/mysql/model/test_model_scopes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import unittest

from src.masoniteorm.models import Model
from src.masoniteorm.scopes import SoftDeletesMixin


class User(Model, SoftDeletesMixin):
pass


class TestModelScopes(unittest.TestCase):
def test_find_with_global_scope(self):
user_where = User.where("id", 1).to_sql()
user_find = User.find("1", query=True)
self.assertEqual(user_where, user_find)

def test_find_with_trashed_scope(self):
user_where = User.with_trashed().where("id", 1).to_sql()
user_find = User.with_trashed().find("1", query=True)
self.assertEqual(user_where, user_find)

def test_find_with_only_trashed_scope(self):
user_where = User.only_trashed().where("id", 1).to_sql()
user_find = User.only_trashed().find("1", query=True)
self.assertEqual(user_where, user_find)

0 comments on commit c4bc92b

Please sign in to comment.