How to use test_3_1 method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

tests.py

Source:tests.py Github

copy

Full Screen

1from django.contrib.auth.models import User2from django.test import TestCase3from accounts.models import ShopUser4from .models import Product, Category, Unit, ProductMatrix, Shop, Stock5from .services import search_products_service, get_product_list_service, get_categories_by_root_category_service6class BidTestCase(TestCase):7 def setUp(self) -> None:8 test_category_1 = Category.objects.create(name='Meat', slug='meat', root_category=None)9 self.test_category_2 = Category.objects.create(name='Fruits', slug='fruits', root_category=None)10 test_unit_1 = Unit.objects.create(name='Kilograms', short_name='kg.', type=Unit.WEIGHT)11 test_unit_2 = Unit.objects.create(name='Piece', short_name='pc.', type=Unit.PIECE)12 test_matrix = ProductMatrix.objects.create(name='Small shop')13 self.test_product_1 = Product.objects.create(barcode='111111111', name='Goat meat', slug='goat-meat',14 unit=test_unit_1, price=3.65, category=test_category_1,15 storage_condition=Product.COOLED)16 self.test_product_1.matrix.add(test_matrix)17 test_product_2 = Product.objects.create(barcode='111111112', name='Mango 200g.',18 slug='mango-200g', unit=test_unit_2, price=77.16,19 category=self.test_category_2, storage_condition=Product.COOLED)20 test_product_2.matrix.add(test_matrix)21 # Создание магазина22 test_stock = Stock.objects.create(name='Test stock', stock_type=Stock.ORDINARY)23 test_shop = Shop.objects.create(address='Test address', product_matrix=test_matrix, stock=test_stock)24 # Создание пользователя25 self.test_user = User.objects.create_user('john', 'lennon@thebeatles.com', 'johnpassword')26 ShopUser.objects.create(user=self.test_user, phone=None, shop=test_shop)27 def test_get_product_list_service_no_category(self):28 category, categories, products_list = get_product_list_service(self.test_user)29 self.assertIsNone(category)30 self.assertEqual(len(products_list), 2)31 def test_get_product_list_service_category(self):32 category, categories, products_list = get_product_list_service(self.test_user, self.test_category_2.slug)33 self.assertEqual(category, self.test_category_2)34 self.assertEqual(len(categories), 0)35 self.assertEqual(len(products_list), 1)36 def test_search_products_service(self):37 products = search_products_service(self.test_user, 'goat')38 self.assertEqual(len(products), 1)39 self.assertEqual(products[0], self.test_product_1)40class GetCategoriesByRootTestCase(TestCase):41 def setUp(self) -> None:42 test_1 = Category.objects.create(name='test_1', slug='test_1', root_category=None)43 test_1_1 = Category.objects.create(name='test_1_1', slug='test_1_1', root_category=test_1)44 test_1_2 = Category.objects.create(name='test_1_2', slug='test_1_2', root_category=test_1)45 test_1_2_1 = Category.objects.create(name='test_1_2_1', slug='test_1_2_1', root_category=test_1_2)46 test_2 = Category.objects.create(name='test_2', slug='test_2', root_category=None)47 test_2_1 = Category.objects.create(name='test_2_1', slug='test_2_1', root_category=test_2)48 self.test_3 = Category.objects.create(name='test_3', slug='test_3', root_category=None)49 test_3_1 = Category.objects.create(name='test_3_1', slug='test_3_1', root_category=self.test_3)50 test_3_1_1 = Category.objects.create(name='test_3_1_1', slug='test_3_1_1', root_category=test_3_1)51 test_3_1_1_1 = Category.objects.create(name='test_3_1_1_1', slug='test_3_1_1_1', root_category=test_3_1_1)52 test_3_2 = Category.objects.create(name='test_3_2', slug='test_3_2', root_category=self.test_3)53 def test_None_True(self):54 result = get_categories_by_root_category_service(None, True)55 self.assertEqual(len(result), 11)56 def test_None_False(self):57 result = get_categories_by_root_category_service(None, False)58 self.assertEqual(len(result), 3)59 def test_Value_False(self):60 result = get_categories_by_root_category_service(self.test_3, False)61 self.assertEqual(len(result), 2)62 def test_Value_True(self):63 result = get_categories_by_root_category_service(self.test_3, True)...

Full Screen

Full Screen

eval.py

Source:eval.py Github

copy

Full Screen

1from informed3 import informed_search2from uninformed import uninformed_search3import time4def performace():5 """6 Evaluate the performance of informed & uninformed search algorithms.7 8 Metrics:9 - time taken to run the search10 - length of the optimal path found11 """12 # Test input for 3*3 puzzle13 test_3_1 = [[1,2,3], [4,5,6], [8,7,0]]14 test_3_2 = [[1,8,3], [5,2,4], [0,7,6]]15 test_3_3 = [[8,6,7], [2,5,4], [3,0,1]]16 # Test input for 4*4 puzzle17 test_4_1 = [[1,2,3,4], [5,6,7,8], [10,11,0,12], [9,13,15,14]]18 test_4_2 = [[12,15,6,10], [4,9,5,8], [14,13,0,2], [1,7,11,3]]19 # test_4_3 = [[14,10,5,13], [11, 8, 1, 3], [2,9,12,6], [15,4,0,7]]20 test_4_3 = [[13, 5, 3, 4], [2, 1, 8, 0], [9, 15, 10, 11], [14, 12, 6, 7]]21 test_4_4 = [[9, 5, 12, 4], [0, 1, 3, 10], [14, 13, 11, 2], [15, 7, 6, 8]]22 # Test input for 5*5 puzzle23 # test_5_1 = [[1,2,3,4,5], [6,7,8,9,10], [11,12,0,14,15], [16,17,13,18,19], [21,22,23,20,24]]24 # test_5_2 = [[5,7,20,18,8], [14,16,4,23,3], [1,11,2,24,13], [21,10,19,0,17], [15,12,6,22,9]]25 # test_5_3 = [[21,12,8,18,20], [24,1,17,13,11], [22,4,19,9,5], [15,2,10,0,16], [7,23,6,14,3]]26 test_5_1 = [[1,2,3,4,5], [6,7,8,9,10], [11,12,0,14,15], [16,17,13,20,19], [21,22,23,18,24]]27 test_5_2 = [[1, 3, 4, 10, 5], [7, 2, 8, 0, 14], [6, 11, 12, 9, 15], [16, 17, 13, 18, 19], [21, 22, 23, 24, 20]]28 test_5_3 = [[1, 3, 4, 0, 10], [7, 2, 12, 8, 5], [6, 11, 13, 15, 14], [17, 23, 18, 9, 19], [16, 21, 22, 24, 20]]29 test_5_4 = [[1, 3, 4, 10, 5], [7, 2, 12, 8, 14], [6, 11, 13, 15, 0], [17, 23, 18, 9, 19], [16, 21, 22, 24, 20]]30 test_5_5 = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 14, 0, 15], [16, 17, 13, 18, 19], [21, 22, 23, 24, 20]]31 # Goal states32 goal_3 = [[1,2,3], [4,5,6], [7,8,0]]33 goal_4 = [[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,0]]34 goal_5 = [[1,2,3,4,5], [6,7,8,9,10], [11,12,13,14,15], [16,17,18,19,20], [21,22,23,24,0]]35 # Test for uninformed search36 # timer(test_3_1, goal_3, "test_3_1", False)37 # timer(test_3_2, goal_3, "test_3_2", False)38 # timer(test_3_3, goal_3, "test_3_3", False)39 # timer(test_4_1, goal_4, "test_4_1", False)40 # timer(test_4_2, goal_4, "test_4_2", False)41 # timer(test_4_3, goal_4, "test_4_3", False)42 #timer(test_5_1, goal_5, "test_5_1", False)43 #timer(test_5_2, goal_5, "test_5_2", False)44 #timer(test_5_3, goal_5, "test_5_3", False)45 # Test for informed search46 # timer(test_3_1, goal_3, "test_3_1", True)47 # timer(test_3_2, goal_3, "test_3_2", True)48 # timer(test_3_3, goal_3, "test_3_3", True)49 timer(test_4_1, goal_4, "test_4_1", True)50 timer(test_4_2, goal_4, "test_4_2", True)51 timer(test_4_3, goal_4, "test_4_3", True)52 timer(test_4_4, goal_4, "test_4_4", True)53 # timer(test_5_1, goal_5, "test_5_1", True)54 # timer(test_5_2, goal_5, "test_5_2", True)55 # timer(test_5_3, goal_5, "test_5_3", True)56 # timer(test_5_4, goal_5, "test_5_4", True) 57 # timer(test_5_5, goal_5, "test_5_5", True)58def timer(test, goal, testname, is_informed):59 # record elapsed time60 start = time.time()61 if (not is_informed):62 run = uninformed_search(test, goal)63 else:64 run = informed_search(test, goal)65 end = time.time()66 print(testname + ": %.8f s" %(end - start))67 # record optimal path length found68 if (isinstance(run, list) and len(run) == 1 and run[0] == "UNSOLVABLE"):69 print("path length: UNSOLVABLE")70 else:71 print("path length: " + str(len(run)))72if __name__ == '__main__':...

Full Screen

Full Screen

test_fixture.py

Source:test_fixture.py Github

copy

Full Screen

...43 print(type(setup_module))44 assert "ok" # 通过assert return true or false45 print('~~~~~Test_2_3 called.')46@pytest.mark.test_session47def test_3_1(sess_scope):48 print(type(sess_scope))49 assert "ok" 50 print('~~~~~Test_3_1 called.') 51@pytest.mark.test_session52def test_3_2(sess_scope):53 print(type(sess_scope))54 assert "ok" 55 print('~~~~~Test_3_2 called.') 56@pytest.mark.test_session57def test_3_3(sess_scope):58 print(type(sess_scope))59 assert "ok" 60 print('~~~~~Test_3_3 called.') 61# if __name__=='__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful