1818class BaseMarketTest (TestCase ):
1919 def setUp (self ):
2020 self .client = APIClient ()
21+ self .tags = self .load_tags ()
22+ self .categories = self .load_categories ()
23+ self .users = [
24+ self .load_user ("user" , "user@gmail.com" , "user" , True , True ),
25+ self .load_user ("user1" , "user1@gmail.com" , "user1" , False , False ),
26+ ]
2127
2228 def load_tags (self ):
2329 tags = [
@@ -143,12 +149,6 @@ def normalize(obj, path=""):
143149class TestItemGet (BaseMarketTest ):
144150 def setUp (self ):
145151 super ().setUp ()
146- self .tags = self .load_tags ()
147- self .categories = self .load_categories ()
148- self .users = [
149- self .load_user ("user" , "user@gmail.com" , "user" , True , True ),
150- self .load_user ("user1" , "user1@gmail.com" , "user1" , False , False ),
151- ]
152152 self .items = self .load_items (
153153 "tests/market/self_user_items.json" , self .users [0 ]
154154 ) + self .load_items ("tests/market/user_1_items.json" , self .users [1 ])
@@ -276,12 +276,6 @@ class TestItemPost(BaseMarketTest):
276276
277277 def setUp (self ):
278278 super ().setUp ()
279- self .tags = self .load_tags ()
280- self .categories = self .load_categories ()
281- self .users = [
282- self .load_user ("user" , "user@gmail.com" , "user" , True , True ),
283- self .load_user ("user1" , "user1@gmail.com" , "user1" , False , False ),
284- ]
285279
286280 def test_create_item_all_fields (self ):
287281 payload = {
@@ -462,12 +456,6 @@ def test_create_item_with_profanity_title(self):
462456class TestItemPatch (BaseMarketTest ):
463457 def setUp (self ):
464458 super ().setUp ()
465- self .tags = self .load_tags ()
466- self .categories = self .load_categories ()
467- self .users = [
468- self .load_user ("user" , "user@gmail.com" , "user" , True , True ),
469- self .load_user ("user1" , "user1@gmail.com" , "user1" , False , False ),
470- ]
471459 self .items = self .load_items (
472460 "tests/market/self_user_items.json" , self .users [0 ]
473461 ) + self .load_items ("tests/market/user_1_items.json" , self .users [1 ])
@@ -662,12 +650,6 @@ def test_update_item_not_owned(self):
662650class TestItemDelete (BaseMarketTest ):
663651 def setUp (self ):
664652 super ().setUp ()
665- self .tags = self .load_tags ()
666- self .categories = self .load_categories ()
667- self .users = [
668- self .load_user ("user" , "user@gmail.com" , "user" , True , True ),
669- self .load_user ("user1" , "user1@gmail.com" , "user1" , False , False ),
670- ]
671653 self .items = self .load_items (
672654 "tests/market/self_user_items.json" , self .users [0 ]
673655 ) + self .load_items ("tests/market/user_1_items.json" , self .users [1 ])
@@ -690,12 +672,6 @@ def test_delete_item_not_owned(self):
690672class TestSubletGet (BaseMarketTest ):
691673 def setUp (self ):
692674 super ().setUp ()
693- self .tags = self .load_tags ()
694- self .categories = self .load_categories ()
695- self .users = [
696- self .load_user ("user" , "user@gmail.com" , "user" , True , True ),
697- self .load_user ("user1" , "user1@gmail.com" , "user1" , False , False ),
698- ]
699675 items1 , sublets1 = self .load_sublets ("tests/market/self_user_sublets.json" , self .users [0 ])
700676 items2 , sublets2 = self .load_sublets ("tests/market/user_1_sublets.json" , self .users [1 ])
701677 self .items = items1 + items2
@@ -836,12 +812,6 @@ def test_get_single_sublet_invalid_id(self):
836812class TestSubletPost (BaseMarketTest ):
837813 def setUp (self ):
838814 super ().setUp ()
839- self .tags = self .load_tags ()
840- self .categories = self .load_categories ()
841- self .users = [
842- self .load_user ("user" , "user@gmail.com" , "user" , True , True ),
843- self .load_user ("user1" , "user1@gmail.com" , "user1" , False , False ),
844- ]
845815
846816 def test_create_sublet (self ):
847817 payload = {
@@ -930,12 +900,6 @@ def test_create_sublet(self):
930900class TestSubletPatchDelete (BaseMarketTest ):
931901 def setUp (self ):
932902 super ().setUp ()
933- self .tags = self .load_tags ()
934- self .categories = self .load_categories ()
935- self .users = [
936- self .load_user ("user" , "user@gmail.com" , "user" , True , True ),
937- self .load_user ("user1" , "user1@gmail.com" , "user1" , False , False ),
938- ]
939903 items1 , sublets1 = self .load_sublets ("tests/market/self_user_sublets.json" , self .users [0 ])
940904 items2 , sublets2 = self .load_sublets ("tests/market/user_1_sublets.json" , self .users [1 ])
941905 self .items = items1 + items2
@@ -1100,12 +1064,6 @@ def test_update_sublet_non_sublet_category(self):
11001064class TestOffer (BaseMarketTest ):
11011065 def setUp (self ):
11021066 super ().setUp ()
1103- self .tags = super ().load_tags ()
1104- self .categories = self .load_categories ()
1105- self .users = [
1106- self .load_user ("user" , "user@gmail.com" , "user" , True , True ),
1107- self .load_user ("user1" , "user1@gmail.com" , "user1" , False , False ),
1108- ]
11091067 self .items = self .load_items (
11101068 "tests/market/self_user_items.json" , self .users [0 ]
11111069 ) + self .load_items ("tests/market/user_1_items.json" , self .users [1 ])
@@ -1268,12 +1226,6 @@ def test_delete_offer_nonexistent(self):
12681226class TestFavorites (BaseMarketTest ):
12691227 def setUp (self ):
12701228 super ().setUp ()
1271- self .tags = self .load_tags ()
1272- self .categories = self .load_categories ()
1273- self .users = [
1274- self .load_user ("user" , "user@gmail.com" , "user" , True , True ),
1275- self .load_user ("user1" , "user1@gmail.com" , "user1" , False , False ),
1276- ]
12771229 self .items = self .load_items (
12781230 "tests/market/self_user_items.json" , self .users [0 ]
12791231 ) + self .load_items ("tests/market/user_1_items.json" , self .users [1 ])
@@ -1348,7 +1300,7 @@ def test_delete_favorite(self):
13481300 self .assertEqual (response .status_code , 204 )
13491301 self .assertEqual (Item .objects .get (id = self .items [1 ].id ).favorites .count (), 0 )
13501302
1351- def test_delete_nonexistant_favorite (self ):
1303+ def test_delete_nonexistent_favorite (self ):
13521304 response = self .client .delete (f"/market/items/{ self .items [2 ].id } /favorites/" )
13531305 self .assertEqual (response .status_code , 404 )
13541306 self .assertEqual (Item .objects .get (id = self .items [2 ].id ).favorites .count (), 0 )
@@ -1358,12 +1310,6 @@ def test_delete_nonexistant_favorite(self):
13581310class TestImages (BaseMarketTest ):
13591311 def setUp (self ):
13601312 super ().setUp ()
1361- self .tags = self .load_tags ()
1362- self .categories = self .load_categories ()
1363- self .users = [
1364- self .load_user ("user" , "user@gmail.com" , "user" , True , True ),
1365- self .load_user ("user1" , "user1@gmail.com" , "user1" , False , False ),
1366- ]
13671313 self .items = self .load_items (
13681314 "tests/market/self_user_items.json" , self .users [0 ]
13691315 ) + self .load_items ("tests/market/user_1_items.json" , self .users [1 ])
0 commit comments