How to use feature_enabled method in autotest

Best Python code snippet using autotest_python

test_models.py

Source:test_models.py Github

copy

Full Screen

...33 enabled_for_all_courses=enabled_for_all_courses,34 course_id=self.course_id_1,35 enabled_for_course=enabled_for_course_136 ):37 self.assertEqual(PersistentGradesEnabledFlag.feature_enabled(), global_flag)38 self.assertEqual(39 PersistentGradesEnabledFlag.feature_enabled(self.course_id_1),40 global_flag and (enabled_for_all_courses or enabled_for_course_1)41 )42 self.assertEqual(43 PersistentGradesEnabledFlag.feature_enabled(self.course_id_2),44 global_flag and enabled_for_all_courses45 )46 def test_enable_disable_course_flag(self):47 """48 Ensures that the flag, once enabled for a course, can also be disabled.49 """50 with persistent_grades_feature_flags(51 global_flag=True,52 enabled_for_all_courses=False,53 course_id=self.course_id_1,54 enabled_for_course=True55 ):56 self.assertTrue(PersistentGradesEnabledFlag.feature_enabled(self.course_id_1))57 # Prior to TNL-5698, creating a second object would fail due to db constraints58 with persistent_grades_feature_flags(59 global_flag=True,60 enabled_for_all_courses=False,61 course_id=self.course_id_1,62 enabled_for_course=False63 ):64 self.assertFalse(PersistentGradesEnabledFlag.feature_enabled(self.course_id_1))65 def test_enable_disable_globally(self):66 """67 Ensures that the flag, once enabled globally, can also be disabled.68 """69 with persistent_grades_feature_flags(70 global_flag=True,71 enabled_for_all_courses=True,72 ):73 self.assertTrue(PersistentGradesEnabledFlag.feature_enabled())74 self.assertTrue(PersistentGradesEnabledFlag.feature_enabled(self.course_id_1))75 with persistent_grades_feature_flags(76 global_flag=True,77 enabled_for_all_courses=False,78 ):79 self.assertTrue(PersistentGradesEnabledFlag.feature_enabled())80 self.assertFalse(PersistentGradesEnabledFlag.feature_enabled(self.course_id_1))81 with persistent_grades_feature_flags(82 global_flag=False,83 ):84 self.assertFalse(PersistentGradesEnabledFlag.feature_enabled())...

Full Screen

Full Screen

test_tacacsplus.py

Source:test_tacacsplus.py Github

copy

Full Screen

...18 client = mock.MagicMock()19 client.authenticate.side_effect=Exception("foo")20 with mock.patch('awx.sso.backends.django_settings') as settings,\21 mock.patch('awx.sso.backends.logger') as logger,\22 mock.patch('awx.sso.backends.feature_enabled', feature_enabled('enterprise_auth')),\23 mock.patch('tacacs_plus.TACACSClient', return_value=client):24 settings.TACACSPLUS_HOST = 'localhost'25 settings.TACACSPLUS_AUTH_PROTOCOL = 'ascii'26 ret_user = tacacsplus_backend.authenticate(u"user", u"pass")27 assert ret_user is None28 logger.exception.assert_called_once_with(29 "TACACS+ Authentication Error: foo"30 )31def test_client_return_invalid_fails_auth(tacacsplus_backend, feature_enabled):32 auth = mock.MagicMock()33 auth.valid = False34 client = mock.MagicMock()35 client.authenticate.return_value = auth36 with mock.patch('awx.sso.backends.django_settings') as settings,\37 mock.patch('awx.sso.backends.feature_enabled', feature_enabled('enterprise_auth')),\38 mock.patch('tacacs_plus.TACACSClient', return_value=client):39 settings.TACACSPLUS_HOST = 'localhost'40 settings.TACACSPLUS_AUTH_PROTOCOL = 'ascii'41 ret_user = tacacsplus_backend.authenticate(u"user", u"pass")42 assert ret_user is None43def test_client_return_valid_passes_auth(tacacsplus_backend, feature_enabled):44 auth = mock.MagicMock()45 auth.valid = True46 client = mock.MagicMock()47 client.authenticate.return_value = auth48 user = mock.MagicMock()49 user.has_usable_password = mock.MagicMock(return_value=False)50 with mock.patch('awx.sso.backends.django_settings') as settings,\51 mock.patch('awx.sso.backends.feature_enabled', feature_enabled('enterprise_auth')),\52 mock.patch('tacacs_plus.TACACSClient', return_value=client),\53 mock.patch('awx.sso.backends._get_or_set_enterprise_user', return_value=user):54 settings.TACACSPLUS_HOST = 'localhost'55 settings.TACACSPLUS_AUTH_PROTOCOL = 'ascii'56 ret_user = tacacsplus_backend.authenticate(u"user", u"pass")...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Test Managers in Agile – Creating the Right Culture for Your SQA Team

I was once asked at a testing summit, “How do you manage a QA team using scrum?” After some consideration, I realized it would make a good article, so here I am. Understand that the idea behind developing software in a scrum environment is for development teams to self-organize.

The Top 52 Selenium Open Source Projects On GitHub

Selenium, a project hosted by the Apache Software Foundation, is an umbrella open-source project comprising a variety of tools and libraries for test automation. Selenium automation framework enables QA engineers to perform automated web application testing using popular programming languages like Python, Java, JavaScript, C#, Ruby, and PHP.

Quick Guide To Drupal Testing

Dries Buytaert, a graduate student at the University of Antwerp, came up with the idea of developing something similar to a chat room. Moreover, he modified the conventional chat rooms into a website where his friends could post their queries and reply through comments. However, for this project, he thought of creating a temporary archive of posts.

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 autotest 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