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

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