How to use test_bad_save method in tavern

Best Python code snippet using tavern

test_forms.py

Source: test_forms.py Github

copy

Full Screen

...42 self.assertTrue(self.session.modified)43 self.assertTrue(oam_status.select_odin_username)44 self.assertIn('ODIN_NAME', self.session['identity'])45 self.assertIn('EMAIL_ADDRESS', self.session['identity'])46 def test_bad_save(self):47 self.session['identity'] = {'PSU_UUID': '000000002'}48 self.session.modified = False49 (oam_status, _) = OAMStatusTracker.objects.get_or_create(psu_uuid=self.session['identity']['PSU_UUID'])50 self.assertFalse(oam_status.select_odin_username)51 self.assertNotIn('ODIN_NAME', self.session['identity'])52 self.assertNotIn('EMAIL_ADDRESS', self.session['identity'])53 form = OdinNameForm(self.session, {"name": 0})54 self.assertTrue(form.is_valid())55 self.assertRaises(APIException, form.save)56 oam_status.refresh_from_db()57 self.assertFalse(self.session.modified)58 self.assertFalse(oam_status.select_odin_username)59 self.assertNotIn('ODIN_NAME', self.session['identity'])60 self.assertNotIn('EMAIL_ADDRESS', self.session['identity'])61class EmailAliasFormTestCase(TestCase):62 choices = ["None",63 "Name 1 - Test1",64 "Name 2 - Test2", ]65 @classmethod66 def setUpTestData(cls):67 cls.session = SessionStore()68 cls.session['TRUENAME_EMAILS'] = cls.choices69 cls.session.save()70 def test_good_init(self):71 # Test successful init without data72 form = EmailAliasForm(self.session)73 self.assertEqual(form.fields["alias"].label, "Email Alias")74 self.assertEqual([c for c in form.fields["alias"].choices], [75 (0, "None"), (1, "Name 1 - Test1"), (2, "Name 2 - Test2")])76 # Test init with data77 form = EmailAliasForm(self.session, {"alias": 1})78 self.assertEqual(form.fields["alias"].label, "Email Alias")79 self.assertTrue(form.is_valid())80 self.assertEqual(form.cleaned_data, {"alias": "1"})81 def test_bad_init(self):82 # Test init with no choices83 self.assertRaises(TypeError, EmailAliasForm)84 # Test init with non-iterable choices85 self.assertRaises(TypeError, EmailAliasForm, 42)86 def test_good_save(self):87 self.session['identity'] = {'PSU_UUID': '123456789'}88 self.session.modified = False89 (oam_status, _) = OAMStatusTracker.objects.get_or_create(psu_uuid=self.session['identity']['PSU_UUID'])90 self.assertFalse(oam_status.select_email_alias)91 self.assertNotIn('EMAIL_ALIAS', self.session['identity'])92 form = EmailAliasForm(self.session, {"alias": 0})93 self.assertTrue(form.is_valid())94 form.save()95 oam_status.refresh_from_db()96 self.assertFalse(self.session.modified)97 self.assertTrue(oam_status.select_email_alias)98 self.assertNotIn('EMAIL_ALIAS', self.session['identity'])99 oam_status.select_email_alias = False100 oam_status.save()101 self.session.modified = False102 form = EmailAliasForm(self.session, {"alias": 1})103 self.assertTrue(form.is_valid())104 form.save()105 oam_status.refresh_from_db()106 self.assertTrue(self.session.modified)107 self.assertTrue(oam_status.select_email_alias)108 self.assertIn('EMAIL_ALIAS', self.session['identity'])109 def test_bad_save(self):110 self.session['identity'] = {'PSU_UUID': '000000002'}111 self.session.save()112 self.session.modified = False113 (oam_status, _) = OAMStatusTracker.objects.get_or_create(psu_uuid=self.session['identity']['PSU_UUID'])114 self.assertFalse(oam_status.select_email_alias)115 self.assertNotIn('EMAIL_ALIAS', self.session['identity'])116 form = EmailAliasForm(self.session, {"alias": 1})117 self.assertTrue(form.is_valid())118 self.assertRaises(APIException, form.save)119 oam_status.refresh_from_db()120 self.assertFalse(self.session.modified)121 self.assertFalse(oam_status.select_email_alias)...

Full Screen

Full Screen

augeas_configurator_test.py

Source: augeas_configurator_test.py Github

copy

Full Screen

...23 self.config.parser._parse_file(os.path.join(24 self.config.parser.root, "conf-available", "bad_conf_file.conf"))25 self.assertRaises(26 errors.PluginError, self.config.check_parsing_errors, "httpd.aug")27 def test_bad_save(self):28 mock_save = mock.Mock()29 mock_save.side_effect = IOError30 self.config.aug.save = mock_save31 self.assertRaises(errors.PluginError, self.config.save)32 def test_bad_save_checkpoint(self):33 self.config.reverter.add_to_checkpoint = mock.Mock(34 side_effect=errors.ReverterError)35 self.config.parser.add_dir(36 self.vh_truth[0].path, "Test", "bad_save_ckpt")37 self.assertRaises(errors.PluginError, self.config.save)38 def test_bad_save_finalize_checkpoint(self):39 self.config.reverter.finalize_checkpoint = mock.Mock(40 side_effect=errors.ReverterError)41 self.config.parser.add_dir(...

Full Screen

Full Screen

test_largefilemanager.py

Source: test_largefilemanager.py Github

copy

Full Screen

...38 "HTTP 400: Bad Request (Must specify format of file contents as 'text' or 'base64')"39 )40 ]41)42def test_bad_save(contents_manager, model, err_message):43 with pytest.raises(tornado.web.HTTPError) as e:44 contents_manager.save(model, model['path'])45 assert expected_http_error(e, 400, expected_message=err_message)46def test_saving_different_chunks(contents_manager):47 cm = contents_manager48 model = {'name': 'test', 'path': 'test', 'type': 'file',49 'content': u'test==', 'format': 'text'}50 name = model['name']51 path = model['path']52 cm.save(model, path)53 for chunk in (1, 2, -1):54 for fm in ('text', 'base64'):55 full_model = cm.get(path)56 full_model['chunk'] = chunk...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

How To Create Custom Menus with CSS Select

When it comes to UI components, there are two versatile methods that we can use to build it for your website: either we can use prebuilt components from a well-known library or framework, or we can develop our UI components from scratch.

Why does DevOps recommend shift-left testing principles?

Companies are using DevOps to quickly respond to changing market dynamics and customer requirements.

How to Recognize and Hire Top QA / DevOps Engineers

With the rising demand for new services and technologies in the IT, manufacturing, healthcare, and financial sector, QA/ DevOps engineering has become the most important part of software companies. Below is a list of some characteristics to look for when interviewing a potential candidate.

Starting & growing a QA Testing career

The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.

Webinar: Move Forward With An Effective Test Automation Strategy [Voices of Community]

The key to successful test automation is to focus on tasks that maximize the return on investment (ROI), ensuring that you are automating the right tests and automating them in the right way. This is where test automation strategies come into play.

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