How to use assertInContext method in Django Test Plus

Best Python code snippet using django-test-plus_python

dashboard_tests.py

Source:dashboard_tests.py Github

copy

Full Screen

...37 self.assertEqual(len(report['y_range']), 11)38 self.assertEqual(report['max_revenue'], D('60'))39 def test_has_stats_vars_in_context(self):40 response = self.get(reverse('dashboard:index'))41 self.assertInContext(response, 'total_orders_last_day')42 self.assertInContext(response, 'total_lines_last_day')43 self.assertInContext(response, 'average_order_costs')44 self.assertInContext(response, 'total_revenue_last_day')45 self.assertInContext(response, 'hourly_report_dict')46 self.assertInContext(response, 'total_products')47 self.assertInContext(response, 'total_open_stock_alerts')48 self.assertInContext(response, 'total_closed_stock_alerts')49 self.assertInContext(response, 'total_site_offers')50 self.assertInContext(response, 'total_vouchers')51 self.assertInContext(response, 'total_orders')52 self.assertInContext(response, 'total_lines')53 self.assertInContext(response, 'total_revenue')...

Full Screen

Full Screen

test_views.py

Source:test_views.py Github

copy

Full Screen

...9 """10 An unauthenticated user should see the normal landing page.11 """12 self.get_check_200("home")13 self.assertInContext("template_to_render")14 self.assertContext("template_to_render", "pages/frontend/index.html")15 def test_dashboard(self):16 """17 Test two things:18 1) An authenticated user should see the dashboard.19 2) The context keys regarding contracts should be 'None'.20 """21 with self.login(username=self.user1, password="password"):22 self.get_check_200("home")23 self.assertInContext("template_to_render")24 self.assertContext("template_to_render", "pages/backend/index.html")25 self.assertInContext("form")26 # The current user should not have any contracts/shifts yet27 self.assertInContext("all_contracts")28 self.assertContext("all_contracts", None)29 self.assertInContext("default_contract")30 self.assertContext("default_contract", None)31 self.assertInContext("last_shifts")...

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 Django Test Plus 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