How to use create_bug method in Kiwi

Best Python code snippet using Kiwi_python

tests_views.py

Source:tests_views.py Github

copy

Full Screen

...5 @staticmethod6 def create_other_user():7 return User.objects.create_user(username='other_user', password='password')8 @staticmethod9 def create_bug(user):10 bug = Bugs(name='Test', description='Test desc', author=user)11 bug.save()12 return bug13 def setUp(self):14 self.user = User.objects.create_user(username='username', password='password')15 self.client.login(username='username', password='password')16 # ARCHIVE17 def test_archive_page_status(self):18 response = self.client.get('/bugs/')19 self.assertEqual(response.status_code, 200)20 self.assertTemplateUsed(response, 'archive.html')21 # SINGLE22 def test_single_page_status(self):23 user = self.create_other_user()24 bug = self.create_bug(user)25 response = self.client.get('/bugs/{}/'.format(bug.id))26 self.assertEqual(response.status_code, 200)27 self.assertTemplateUsed(response, 'single.html')28 def test_single_views(self):29 bug = self.create_bug(self.create_other_user())30 self.client.get('/bugs/{}/'.format(bug.id))31 bug.refresh_from_db()32 self.assertEqual(bug.views, 1)33 # test is the session working correctly34 self.client.get('/bugs/{}/'.format(bug.id))35 bug.refresh_from_db()36 self.assertEqual(bug.views, 1)37 def test_views_own_bug(self):38 bug = self.create_bug(self.user)39 self.client.get('/bugs/{}/'.format(bug.id))40 bug.refresh_from_db()41 self.assertEqual(bug.views, 0)42 def test_add_new_comment(self):43 bug = self.create_bug(self.user)44 comment = {45 'comment': 'Test comment'46 }47 response = self.client.post('/bugs/{}/'.format(bug.id), data=comment,48 follow=True)49 self.assertContains(response, "Comment has been added", 1, 200)50 comments = BugComment.objects.filter(bug__pk=bug.id)51 self.assertEqual(len(comments), 1)52 self.assertEqual(comments[0].comment, 'Test comment')53 self.assertEqual(comments[0].bug_id, bug.id)54 # ADD55 def test_add_status(self):56 response = self.client.get('/bugs/new/')57 self.assertEqual(response.status_code, 200)58 self.assertTemplateUsed(response, 'add_edit.html')59 def test_add_new_bug(self):60 new_bug = {61 'name': 'Bug Test',62 'description': 'Bug description'63 }64 response = self.client.post('/bugs/new/', data=new_bug, follow=True)65 self.assertContains(response, "Bug has been created", 1, 200)66 self.assertTemplateUsed(response, 'single.html')67 # EDIT68 def test_edit_status(self):69 bug = self.create_bug(self.user)70 response = self.client.get('/bugs/edit/{}/'.format(bug.id))71 self.assertEqual(response.status_code, 200)72 self.assertTemplateUsed(response, 'add_edit.html')73 def test_edit_bug(self):74 bug = self.create_bug(self.user)75 edit_data = {76 'name': 'New bug name',77 'description': 'New description'78 }79 response = self.client.post('/bugs/edit/{}/'.format(bug.id), data=edit_data, follow=True)80 edited_bug = Bugs.objects.get(id=bug.id)81 self.assertEqual(edited_bug.name, edit_data['name'])82 self.assertEqual(edited_bug.description, edit_data['description'])83 self.assertEqual(edited_bug.status, 'todo')84 self.assertEqual(edited_bug.views, 0)85 self.assertEqual(edited_bug.author_id, self.user.id)86 self.assertContains(response, "Bug has been edited", 1, 200)87 self.assertTemplateUsed(response, 'single.html')88 def test_edit_someone_bug_by_get(self):89 bug = self.create_bug(self.create_other_user())90 response = self.client.post('/bugs/edit/{}/'.format(bug.id), follow=True)91 self.assertContains(response, "You cannot edit someone bug", 1, 200)92 def test_edit_someone_bug_by_post(self):93 bug = self.create_bug(self.create_other_user())94 response = self.client.post('/bugs/edit/{}/'.format(bug.id), follow=True)95 self.assertContains(response, "You cannot edit someone bug", 1, 200)96 # VOTE97 def test_vote_and_un_vote(self):98 user = self.create_other_user()99 bug = self.create_bug(user)100 self.client.post('/bugs/vote/{}/'.format(bug.id))101 bug.refresh_from_db()102 self.assertEqual(len(bug.voted_by.values_list()), 1)103 response = self.client.post('/bugs/vote/{}/'.format(bug.id))104 bug.refresh_from_db()105 self.assertEqual(len(bug.voted_by.values_list()), 0)106 self.assertEqual(response.status_code, 302)107 def test_vote_on_own_bug(self):108 bug = self.create_bug(self.user)109 response = self.client.post('/bugs/vote/{}/'.format(bug.id), follow=True)110 bug.refresh_from_db()111 self.assertEqual(len(bug.voted_by.values_list()), 0)112 self.assertContains(response, "You cannot vote for own bug", 1, 200)113 def test_vote_and_check_redirection_when_next_get_is_defined(self):114 bug = self.create_bug(self.create_other_user())115 response = self.client.post('/bugs/vote/{0}/?next=/bugs/{0}/'.format(bug.id), follow=True)116 self.assertContains(response, "You have voted up for this bug", 1, 200)117 self.assertTemplateUsed(response, 'single.html')118 # DELETE119 def test_delete_bug(self):120 bug = self.create_bug(self.user)121 self.client.post('/bugs/delete/{}/'.format(bug.id), follow=True)122 count_bugs = Bugs.objects.count()123 self.assertEqual(count_bugs, 0)124 def test_delete_someone_bug(self):125 user = self.create_other_user()126 bug = self.create_bug(user)127 response = self.client.post('/bugs/delete/{}/'.format(bug.id), follow=True)...

Full Screen

Full Screen

irc_command_unittest.py

Source:irc_command_unittest.py Github

copy

Full Screen

...44 self.assertEquals("tom: tonyg@chromium.org is tonyg-cr. Why do you ask?",45 whois.execute("tom", ["tonyg@chromium.org"], None, None))46 self.assertEquals("tom: vicki@apple.com hasn't told me their nick. Boo hoo :-(",47 whois.execute("tom", ["vicki@apple.com"], None, None))48 def test_create_bug(self):49 create_bug = CreateBug()50 self.assertEquals("tom: Usage: BUG_TITLE",51 create_bug.execute("tom", [], None, None))52 example_args = ["sherrif-bot", "should", "have", "a", "create-bug", "command"]53 tool = MockTool()54 # MockBugzilla has a create_bug, but it logs to stderr, this avoids any logging.55 tool.bugs.create_bug = lambda a, b, cc=None, assignee=None: 7856 self.assertEquals("tom: Created bug: http://example.com/78",57 create_bug.execute("tom", example_args, tool, None))58 def mock_create_bug(title, description, cc=None, assignee=None):59 raise Exception("Exception from bugzilla!")60 tool.bugs.create_bug = mock_create_bug61 self.assertEquals("tom: Failed to create bug:\nException from bugzilla!",...

Full Screen

Full Screen

test_create.py

Source:test_create.py Github

copy

Full Screen

...4This is some demo content5for testing purpose only6"""7def test_tag_untag(brpy):8 create_bug("foobar")9 h = brpy.FileHandler()10 bug = h.get(0)11 bug.add_tag("pif")12 bug.rm_tag("pif")13 assert "pif" not in bug.tags14 print(bug.tags)15def test_delete_started(brpy):16 create_bug("foobar")17 h = brpy.FileHandler()18 bug = h.get(0)19 h.mark_started(0)20 h.mark_fixed(0)21def test_stop(brpy):22 create_bug("foobar")23 h = brpy.FileHandler()24 bug = h.get(0)25 assert bug["started"] == ""26 h.mark_started(0)27 assert bug["started"] != ""28 h.mark_stopped(0)29 assert bug["timer"] != ""30 remove_bug(0)31def test_multi_creation(brpy, nr=10):32 for n in range(10):33 create_bug("%3d-%s" % (n, time.time()))34 h = brpy.FileHandler()35 assert len(h) == nr36 assert int(h.info["total-count"]) == nr37def test_create_and_delete(brpy):38 for n in range(2):39 create_bug("First bug")40 remove_bug(0)41 create_bug("Second bug")42 create_bug("Third bug")43 remove_bug(1)44 h = brpy.FileHandler()45 assert len(h) == 2 # 2 bugs remains46 assert int(h.info["total-count"]) == 6 # 6 bugs where created in total47def test_iteration(brpy):48 for n in range(10):49 create_bug("Bug %s" % n)50 for b in brpy.FileHandler():51 str(b)52 b.string_as_list(0)53def remove_bug(num):54 h = get_handler()55 h.mark_fixed(num)56def create_bug(title):57 import betterRest.cli as br58 br.Bug.finalize()59 h = get_handler()60 b = br.Bug(title)61 b.original_text = BUG_TEMPLATE62 b["priority"] = "0"63 b["bugid"] = h.info["total-count"]64 b["created"] = br.now()65 h.new_bug(b)66def get_handler():67 import betterRest.cli as br...

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