Skip to content

Commit

Permalink
テスト効率化
Browse files Browse the repository at this point in the history
  • Loading branch information
medaka0213 committed Sep 20, 2024
1 parent 22cbdfe commit 49d8a36
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/test_search_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class UserNotFound(BaseModel):

class TestSearchTable(unittest.TestCase):
def setUp(self):
for i in range(500):
for i in range(200):
test = User(
name=f"test{str(i).zfill(3)}",
age=i,
Expand Down Expand Up @@ -118,7 +118,7 @@ def test_search_staged_filter(self):
searchEx = [{
"FilterStatus": util_b.FilterStatus.STAGED,
"IndexName": table.__search_index__,
"KeyConditionExpression": Key("sk").eq("search_user_name") & Key("data").begins_with("test2"),
"KeyConditionExpression": Key("sk").eq("search_user_name") & Key("data").begins_with("test1"),
}, {
"FilterStatus": util_b.FilterStatus.FILTER,
"FilterMethod": util_b.attr_method("description", "odd", util_b.QueryType.CONTAINS),
Expand All @@ -144,30 +144,30 @@ def test_search_filter(self):
"FilterExpression": Attr("description").contains("odd"),
}]
res = table.search("user", *searchEx)
self.assertEqual(len(res), 250)
self.assertEqual(len(res), 100)
for r in res:
self.assertIn("odd", r["description"])

# pk_only
res = table.search("user", *searchEx, pk_only=True)
self.assertEqual(len(res), 250)
self.assertEqual(len(res), 100)
for r in res:
self.assertIsInstance(r, str)

def test_search_all(self):
"""全件検索"""
res = table.search("user")
self.assertEqual(len(res), 500)
self.assertEqual(len(res), 200)

# pk_only
res = table.search("user", pk_only=True)
self.assertEqual(len(res), 500)
self.assertEqual(len(res), 200)
for r in res:
self.assertIsInstance(r, str)

def test_all_items(self):
res = table.all_items()
self.assertEqual(len(res), 501)
self.assertEqual(len(res), 201)

def test_list_models(self):
res = table.list_models()
Expand Down

0 comments on commit 49d8a36

Please sign in to comment.