Best Python code snippet using django-test-plus_python
api_parse_test.py
Source:api_parse_test.py
...21from fixtures import read_file22class PluginApiParseTest(TestCase):23 def setUp(self):24 self.parser = PluginParser()25 def test_no_response(self):26 with self.assertRaises(PluginNotFound):27 self.parser.parse(None)28 def test_null_response(self):29 with self.assertRaises(PluginNotFound):30 self.parser.parse('null')31 def test_invalid_json(self):32 content = read_file(__file__, 'better-wp-security.json')33 with self.assertRaises(PluginNotFound):34 self.parser.parse(content[0:-20])35 def test_missing_required_data(self):36 content = '{"slug": "my-test-plugin"}'37 with self.assertRaises(PluginNotFound):38 self.parser.parse(content)39 def test_with_sample_output(self):40 content = read_file(__file__, 'better-wp-security.json')41 info = self.parser.parse(content)42 self.assertEqual(info, Meta(key="plugins/better-wp-security",43 name="iThemes Security (formerly Better WP Security)",44 url="https://ithemes.com/security",45 repositories=[46 Repository(type="subversion",47 location="https://plugins.svn.wordpress.org/better-wp-security/"),48 ]))49 def test_manual_creation(self):50 info = self.parser.create_meta(slug="better-wp-security")51 self.assertEqual(info, Meta(key="plugins/better-wp-security",52 repositories=[53 Repository(type="subversion",54 location="https://plugins.svn.wordpress.org/better-wp-security/"),55 ]))56class ThemeApiParseTest(TestCase):57 def setUp(self):58 self.parser = ThemeParser()59 def test_no_response(self):60 with self.assertRaises(ThemeNotFound):61 self.parser.parse(None)62 def test_null_response(self):63 with self.assertRaises(ThemeNotFound):64 self.parser.parse('null')65 def test_false_response(self):66 with self.assertRaises(ThemeNotFound):67 self.parser.parse('false')68 def test_invalid_json(self):69 content = read_file(__file__, 'twentyeleven.json')70 with self.assertRaises(ThemeNotFound):71 self.parser.parse(content[0:-20])72 def test_missing_required_data(self):73 content = '{"slug": "my-test-theme"}'...
test_client.py
Source:test_client.py
...13 def test_200_ans(self):14 self.assertEqual(process_ans({RESPONSE: 200}), '200 : OK')15 def test_400_ans(self):16 self.assertEqual(process_ans({RESPONSE: 400, ERROR: 'Bad Request'}), '400 : Bad Request')17 def test_no_response(self):18 self.assertRaises(ValueError, process_ans, {ERROR: 'Bad Request'})19if __name__ == '__main__':...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!