def test_add_testcase_andthen_testresult_simple_on_us_view(self): test_case = TestCase(name = 'ABC Test', description = 'Test', priority = 10, user_story = self.story) test_case.save() pre = TestResult.objects.count() b = self.browser b.click("link=Iteration") b.wait() b.click("link=ABC") b.wait() last_location = b.get_location() b.click("xpath=id('add_testresult_%d')/a/img" % test_case.id) b.wait() b.type("id_comments", "this is a test") b.select("id_result", "Pass") b.select("id_tester", "User A") b.type("id_date", "2008-08-01") opt = b.get_select_options("id_test_case")[1] b.select("id_test_case", opt) b.click("css=#content input[type=submit]") b.wait() for x in xrange(15): b.wait() self.assertEqual(TestResult.objects.count(), pre + 1) self.assertEqual(last_location, b.get_location()) test_case.delete()
def setUp(self): self.p1 = Project(name='Test Project 1') self.p2 = Project(name='Test Project 2') self.p1.save() self.p2.save() self.p1.project_members.add(User.objects.get(pk=1)) self.p2.project_members.add(User.objects.get(pk=2)) self.p2.project_members.add(User.objects.get(pk=3)) self.us1 = UserStory(name='User story A', planned=45, state=20, project=self.p1) self.us2 = UserStory(name='User story B', planned=30, state=30, project=self.p2) self.us1.save() self.us2.save() self.tc1 = TestCase(user_story=self.us1, priority=10) self.tc2 = TestCase(user_story=self.us2, priority=10) self.tc3 = TestCase(user_story=self.us2, priority=10) self.tc1.save() self.tc2.save() self.tc3.save()
def test_delete_testresult_simple(self): from datetime import datetime test_case = TestCase(name = 'ABC Test', description = 'Test', priority = 10, user_story = self.story) test_case.save() test_result = TestResult(result = 1, comments = 'Test', tester = User.objects.all()[0], test_case = test_case, date = datetime.today()) test_result.save() pre = TestResult.objects.count() b = self.browser b.click("link=Iteration") b.wait() b.click("link=ABC") b.wait() b.click("link=ABC Test") b.wait() b.click("xpath=id('delete_testresult_%d')/a/img" % (test_result.id)) b.wait() b.click("xpath=id('content')/form/div/input[2]") for x in xrange(20): b.wait() self.assertEqual(TestResult.objects.count(), pre - 1)
def test_delete_testcase_with_testresult(self): from datetime import datetime test_case = TestCase(name = 'ABC Test', description = 'Test', priority = 10, user_story = self.story) test_case.save() test_result = TestResult(result = 1, comments = 'Test', tester = User.objects.all()[0], test_case = test_case, date = datetime.today()) test_result.save() test_result = TestResult(result = 2, comments = 'Test', tester = User.objects.all()[0], test_case = test_case, date = datetime.today()) test_result.save() pre = (TestCase.objects.count(), TestResult.objects.count(),) b = self.browser b.click("link=Iteration") b.wait() b.click("link=ABC") b.wait() last_location = b.get_location() b.click("xpath=id('delete_testcase_%d')/a" % (test_case.id)) b.wait() b.click("xpath=id('content')/form/div/input[2]") for i in xrange(15): b.wait() self.assertEqual(last_location, b.get_location()) self.assertEqual(TestResult.objects.count(), pre[1] - 2) self.assertEqual(TestCase.objects.count(), pre[0] - 1)
def test_edit_testcase_simple(self): test_case = TestCase(name='ABC Test', description='Test', priority=10, user_story=self.story) test_case.save() pk = test_case.id pre = TestCase.objects.count() b = self.browser b.click("link=Iteration") b.wait() b.click("link=ABC") b.wait() b.click("xpath=id('edit_testcase_%d')/a/img" % (test_case.id)) b.wait() b.type("id_name", "hi") b.type("id_description", "bye") b.click("css=#content input[type=submit]") for i in xrange(15): b.wait() self.assertEqual(TestCase.objects.count(), pre) # reload test_case test_case = TestCase.objects.get(pk=pk) self.assertEqual(test_case.name, 'hi') self.assertEqual(test_case.description, 'bye') self.assertEqual(test_case.user_story.id, self.story.id)
class TestTestCaseEditForm(test.TestCase): fixtures = ['database_dump.json'] def setUp(self): self.p1 = Project(name='Test Project 1') self.p2 = Project(name='Test Project 2') self.p1.save() self.p2.save() self.us1 = UserStory(name='User story A', planned=45, state=20, project=self.p1) self.us2 = UserStory(name='User story B', planned=30, state=30, project=self.p2) self.us3 = UserStory(name='User story C', planned=30, state=30, project=self.p2) self.us1.save() self.us2.save() self.us3.save() self.tc1 = TestCase(user_story=self.us1, priority=10) self.tc2 = TestCase(user_story=self.us2, priority=10) self.tc1.save() self.tc2.save() def tearDown(self): for obj in self.tc1, self.tc2, self.us1, self.us2, self.p1, self.p2: obj.delete() def test_test_case_edit_form_has_current_project_us_only(self): form = TestCaseEditForm(project=self.tc1.user_story.project, instance=self.tc1) user_story_choices = list(form.fields['user_story'].choices) self.assertEqual(len(user_story_choices), 2) self.assertEqual(user_story_choices[1][1], unicode(self.us1)) def test_test_case_edit_form_has_current_project_us_only_other(self): form = TestCaseEditForm(project=self.tc2.user_story.project, instance=self.tc2) user_story_choices = list(form.fields['user_story'].choices) self.assertEqual(len(user_story_choices), 3) self.assert_(unicode(self.us2) in set([user_story_choices[1][1], user_story_choices[2][1]])) self.assert_(unicode(self.us3) in set([user_story_choices[1][1], user_story_choices[2][1]]))
def test_edit_testresutl_simple(self): from datetime import datetime test_case = TestCase(name = 'ABC Test', description = 'Test', priority = 10, user_story = self.story) test_case.save() test_result = TestResult(result = 1, comments = 'Test', tester = User.objects.all()[0], test_case = test_case, date = datetime.today()) test_result.save() b = self.browser b.click("link=Iteration") b.wait() b.click("link=ABC") b.wait() b.click("link=ABC Test") b.wait() last_location = b.get_location() b.click("xpath=id('edit_testresult_%d')/a/img" % (test_result.id)) b.wait() b.type("id_comments", "this is a test 2") b.select("id_result", "Fail") b.select("id_tester", "User A") b.type("id_date", "2008-08-02") opt = b.get_select_options("id_test_case")[1] b.select("id_test_case", opt) b.click("css=#content input[type=submit]") for x in xrange(15): b.wait() test_result = TestResult.objects.get(pk = test_result.id) self.assertEqual(test_result.result, 0) self.assertEqual(test_result.comments, "this is a test 2") self.assertEqual(test_result.date, datetime(2008, 8, 2, 0, 0)) # But anyway lets just check the url self.assertEqual(last_location, b.get_location()) test_result.delete() test_case.delete()
def test_delete_testcase_simple(self): test_case = TestCase(name='ABC Test', description='Test', priority=10, user_story=self.story) test_case.save() pre = TestCase.objects.count() b = self.browser b.click("link=Iteration") b.wait() b.click("link=ABC") b.wait() b.click("xpath=id('delete_testcase_%d')/a/img" % (test_case.id)) b.wait() b.wait() b.click("xpath=id('content')/form/div/input[2]") # wait a bit longer that usual, else error. for i in xrange(15): b.wait() self.assertEqual(TestCase.objects.count(), pre-1)
def test_edit_change_us(self): other_story = UserStory(name='DEF', project=self.project, description='a userstory about def', iteration=self.iteration, planned=42, rank=2, state=20, blocked=False) other_story.save() test_case = TestCase(name='ABC Test', description='Test', priority=10, user_story=self.story) test_case.save() pk = test_case.id pre = TestCase.objects.count() b = self.browser b.click("link=Iteration") b.wait() b.click("link=ABC") b.wait() b.click("xpath=id('edit_testcase_%d')/a/img" % (test_case.id)) b.wait() b.type("id_name", "hi") b.type("id_description", "bye") b.select("id_user_story", "US2: DEF") self.assertEqual(b.get_selected_label("id_user_story"), "US2: DEF") b.click("css=#content input[type=submit]") for i in xrange(15): b.wait() self.assertEqual(TestCase.objects.count(), pre) # reload test_case test_case = TestCase.objects.get(pk=pk) self.assertEqual(test_case.name, 'hi') self.assertEqual(test_case.description, 'bye') self.assertEqual(test_case.user_story.id, other_story.id) test_case.delete() other_story.delete()
def setUp(self): self.p1 = Project(name='Test Project 1') self.p2 = Project(name='Test Project 2') self.p1.save() self.p2.save() self.us1 = UserStory(name='User story A', planned=45, state=20, project=self.p1) self.us2 = UserStory(name='User story B', planned=30, state=30, project=self.p2) self.us3 = UserStory(name='User story C', planned=30, state=30, project=self.p2) self.us1.save() self.us2.save() self.us3.save() self.tc1 = TestCase(user_story=self.us1, priority=10) self.tc2 = TestCase(user_story=self.us2, priority=10) self.tc1.save() self.tc2.save()
class TestTestResultForm(test.TestCase): fixtures = ['database_dump.json'] def setUp(self): self.p1 = Project(name='Test Project 1') self.p2 = Project(name='Test Project 2') self.p1.save() self.p2.save() self.p1.project_members.add(User.objects.get(pk=1)) self.p2.project_members.add(User.objects.get(pk=2)) self.p2.project_members.add(User.objects.get(pk=3)) self.us1 = UserStory(name='User story A', planned=45, state=20, project=self.p1) self.us2 = UserStory(name='User story B', planned=30, state=30, project=self.p2) self.us1.save() self.us2.save() self.tc1 = TestCase(user_story=self.us1, priority=10) self.tc2 = TestCase(user_story=self.us2, priority=10) self.tc3 = TestCase(user_story=self.us2, priority=10) self.tc1.save() self.tc2.save() self.tc3.save() def tearDown(self): for obj in self.tc1, self.tc2, self.tc3, self.us1, self.us2, self.p1, self.p2: obj.delete() def test_test_result_form_only_test_cases_of_current_project_simple(self): form = TestResultForm(project=self.p1) test_case_choices = list(form.fields['test_case'].choices) self.assertEqual(len(test_case_choices), 2) self.assertEqual(test_case_choices[1][1], unicode(self.tc1)) tester_choices = list(form.fields['tester'].choices) self.assertEqual(len(tester_choices), 2) self.assertEqual(tester_choices[1][1], User.objects.get(pk=1).__str__()) def test_test_result_form_build_with_instance_has_only_test_cases_of_current_project(self): test_result = TestResult(result=10, test_case=self.tc1, tester=User.objects.all()[0]) form = TestResultForm(project=self.p1,instance=test_result) test_case_choices = list(form.fields['test_case'].choices) self.assertEqual(len(test_case_choices), 2) self.assertEqual(test_case_choices[1][1], unicode(self.tc1)) tester_choices = list(form.fields['tester'].choices) self.assertEqual(len(tester_choices), 2) self.assertEqual(tester_choices[1][1], User.objects.get(pk=1).__str__()) def test_test_result_form_only_test_cases_of_current_project_other(self): form = TestResultForm(project=self.p2) test_case_choices = list(form.fields['test_case'].choices) self.assertEqual(len(test_case_choices), 3) self.assert_(unicode(self.tc2) in set([test_case_choices[1][1], test_case_choices[2][1]])) tester_choices = list(form.fields['tester'].choices) self.assertEqual(len(tester_choices), 3) self.assertEqual(tester_choices[1][1], User.objects.get(pk=2).__str__())