Beispiel #1
0
    def test_redirect_to_login_and_login_required(self):
        self.client.logout()
        # create
        redirect_to_login_and_login_required(
            self,
            'issue:create',
            address_kwargs={'project': self.project.name_short})

        # create issue for edit and detail tests
        issue = Issue(title="foo")
        issue.project = self.project
        issue.save()
        number = issue.number

        # edit
        redirect_to_login_and_login_required(self,
                                             'issue:edit',
                                             address_kwargs={
                                                 'project':
                                                 self.project.name_short,
                                                 'sqn_i': number
                                             })
        # detail
        redirect_to_login_and_login_required(self,
                                             'issue:detail',
                                             address_kwargs={
                                                 'project':
                                                 self.project.name_short,
                                                 'sqn_i': number
                                             })
Beispiel #2
0
    def setUp(self):
        self.user = get_user_model().objects.create_user(
            'a_user', '*****@*****.**', 'a1234568')
        self.project = Project(name="Projectname",
                               name_short="proj",
                               creator=self.user)
        self.project.save()
        self.project.manager.add(self.user)
        self.short = self.project.name_short

        tag = Tag(project=self.project, tag_text="foo")
        tag.save()
        Issue(project=self.project, title="a").save()
        issue = Issue(project=self.project, title="b")
        issue.save()
        issue.tags.add(tag)

        # Uses the cookie hack from:
        # https://stackoverflow.com/questions/22494583/login-with-code-when-using-liveservertestcase-with-django
        client = Client()
        client.login(username='******', password='******')
        self.cookie = client.cookies['sessionid']
        self.selenium.get("{}{}".format(self.live_server_url,
                                        reverse('invite_users:invite_users')))
        self.selenium.add_cookie({
            'name': 'sessionid',
            'value': self.cookie.value,
            'secure': False,
            'path': '/'
        })
        self.selenium.refresh()
Beispiel #3
0
    def setUp(self):
        self.client.force_login(self.user)
        # NOTE: these elements get modified by some testcases, so they should NOT be created in setUpTestData()
        self.project = Project(creator=self.user, name_short='PRJ', activity_only_for_managers=False)
        self.project.save()
        self.project.developer.add(self.user)

        self.project2 = Project(creator=self.user, activity_only_for_managers=True, name_short='PRJJ')
        self.project2.save()
        self.project2.manager.add(self.user)
        self.project2.developer.add(self.user, self.user2)

        self.kanbancol = KanbanColumn(project=self.project, position=4, name='test')
        self.kanbancol.save()
        self.issue = Issue(title='a very very very very very very very long issue title',
                           project=self.project,
                           due_date='2016-12-16',
                           kanbancol=self.kanbancol,
                           storypoints='3'
                           )
        self.issue.save()
        self.issue.assignee.add(self.user)
        self.issue2 = Issue(title='second_issue', project=self.project)
        self.issue2.save()
        self.issue2.assignee.add(self.user)
        self.time = now().strftime("%Y-%m-%d %H:%M:%S")

        # success logedit_address_kwargs
        self.sqn_l1_address_kwarg = {"project": self.issue.project.name_short,
                                     "sqn_i": self.issue.number,
                                     "sqn_l": 1
                                     }
Beispiel #4
0
    def test_comment_delete(self):
        # create sample issue
        issue = Issue(title="Test-Issue",
                      project=self.project,
                      kanbancol=self.column,
                      type="Bug")
        issue.save()
        # create sample comment
        comment = Comment(text="Test Comment", creator=self.user, issue=issue)
        comment.save()

        # delete the comment
        response = self.client.get(reverse('issue:delete_comment',
                                           kwargs={
                                               'project':
                                               self.project.name_short,
                                               'sqn_i': issue.number,
                                               'pk_c': comment.pk
                                           }),
                                   follow=True)
        self.assertRedirects(
            response,
            reverse('issue:detail',
                    kwargs={
                        'project': self.project.name_short,
                        'sqn_i': issue.number
                    }))
        self.assertFalse(issue.comments.all().exists())
Beispiel #5
0
    def test_view_and_template(self):
        # create
        view_and_template(self,
                          IssueCreateView,
                          create_template,
                          'issue:create',
                          address_kwargs={'project': self.project.name_short})

        # create issue for edit and detail tests
        issue = Issue(title="foo")
        issue.project = self.project
        issue.save()
        number = issue.number

        # edit
        view_and_template(self,
                          IssueEditView,
                          edit_template,
                          'issue:edit',
                          address_kwargs={
                              'project': self.project.name_short,
                              'sqn_i': number
                          })
        # detail
        view_and_template(self,
                          IssueDetailView,
                          detail_template,
                          'issue:detail',
                          address_kwargs={
                              'project': self.project.name_short,
                              'sqn_i': number
                          })
Beispiel #6
0
    def test_managerfunctions(self):
        issue1 = Issue(title="issue1",
                       project=self.project,
                       kanbancol=self.column)
        issue1.save()
        sprint_current = Sprint(project=self.project,
                                startdate=(timezone.now() - timedelta(days=1)))
        sprint_current.save()
        sprint_old = Sprint(project=self.project,
                            startdate=(timezone.now() - timedelta(days=14)),
                            enddate=(timezone.now() - timedelta(days=1)))
        sprint_old.save()

        issues_wo_sprint = Issue.objects.without_sprint()
        self.assertTrue(issue1 in issues_wo_sprint)

        issue1.sprint = sprint_current
        issue1.save()
        issues_cur_sprint = Issue.objects.current_sprint()
        self.assertTrue(issue1 in issues_cur_sprint)
        issue1.sprint = sprint_old
        issue1.save()
        issues_cur_sprint = Issue.objects.current_sprint()
        issues_wo_sprint = Issue.objects.without_sprint()
        self.assertFalse(issue1 in issues_cur_sprint)
        self.assertFalse(issue1 in issues_wo_sprint)
    def setUp(self):
        self.user = get_user_model().objects.create_user('a', 'b', 'c')
        self.user2 = get_user_model().objects.create_user('d', 'e', 'f')
        self.project = Project(creator=self.user,
                               name="Selenium-Project",
                               name_short="SLN")
        self.project.save()
        self.project.developer.add(self.user)
        self.project.developer.add(self.user2)
        self.project.manager.add(self.user)

        self.issue = Issue(title="Test-Issue",
                           project=self.project,
                           kanbancol=self.project.kanbancol.first(),
                           type="Bug")
        self.issue.save()

        # Uses the cookie hack from:
        # https://stackoverflow.com/questions/22494583/login-with-code-when-using-liveservertestcase-with-django
        client = Client()
        client.login(username='******', password='******')
        self.cookie = client.cookies['sessionid']
        self.selenium.get("{}{}".format(self.live_server_url,
                                        reverse('invite_users:invite_users')))
        self.selenium.add_cookie({
            'name': 'sessionid',
            'value': self.cookie.value,
            'secure': False,
            'path': '/'
        })
        self.selenium.refresh()
Beispiel #8
0
    def test_edit_same_settings_as_set(self):
        driver = self.selenium
        issue = Issue(title="title",
                      kanbancol=KanbanColumn.objects.get(project=self.project,
                                                         name="Todo"),
                      due_date=str(datetime.date.today()),
                      priority=3,
                      storypoints=2,
                      description="blubber",
                      project=self.project)
        issue.save()
        issue.assignee.add(self.user)
        driver.get("{}{}".format(
            self.live_server_url,
            reverse('issue:edit',
                    kwargs={
                        'project': self.project.name_short,
                        'sqn_i': issue.number
                    })))
        self.assertEqual(
            len(Select(driver.find_element_by_id("id_kanbancol")).options), 4)

        # issue must not depend on itself
        driver.find_element_by_xpath("(//input[@type='search'])[2]").send_keys(
            '\n')
        time.sleep(1)
        self.assertEqual(
            len(
                driver.find_elements_by_css_selector(
                    '#select2-id_dependsOn-results li')), 1)
        for i in driver.find_elements_by_css_selector(
                '#select2-id_dependsOn-results li'):
            self.assertEqual(i.text, "No results found")
Beispiel #9
0
    def test_mute(self):
        self.client.force_login(self.user1)
        issue = Issue(title="asdf", project=self.project, creator=self.user1)
        issue.save()

        self.client.post(
            reverse("discussion:mute",
                    kwargs={
                        "project": self.short,
                        "sqn_i": issue.number
                    }))

        Comment(creator=self.user2, issue=issue).save()
        res = self.client.get(reverse("discussion:list"))
        self.assertContains(res, "No unread messages.")
        # test next post parameter
        response = self.client.post(reverse("discussion:follow",
                                            kwargs={
                                                "project": self.short,
                                                "sqn_i": issue.number
                                            }), {'next': '/timelog'},
                                    follow=True)
        self.assertRedirects(response, reverse('timelog:loginfo'))
        response = self.client.post(reverse("discussion:mute",
                                            kwargs={
                                                "project": self.short,
                                                "sqn_i": issue.number
                                            }), {'next': '/timelog'},
                                    follow=True)
        self.assertRedirects(response, reverse('timelog:loginfo'))
Beispiel #10
0
    def setUpTestData(cls):
        # NOTE: if you modify those elements they need to be created in setUp, instead of here
        cls.user = get_user_model().objects.create_user('a', 'b', 'c')
        cls.user2 = get_user_model().objects.create_user('d', 'e', 'f')
        cls.project = Project(creator=cls.user, name_short='PRJ')
        cls.project.save()
        cls.project.developer.add(cls.user)
        cls.project2 = Project(creator=cls.user, name_short='PROJ')
        cls.project2.save()
        cls.project2.developer.add(cls.user)
        cls.project2.developer.add(cls.user2)
        # create test data (They are needed for search-purpose only)
        cls.issue = Issue(title="Test-Issue",
                          project=cls.project,
                          kanbancol=cls.project.kanbancol.first(),
                          type="Bug")
        cls.issue.save()
        issue = Issue(title="Blub-Issue", project=cls.project, kanbancol=cls.project.kanbancol.first(), type="Bug")
        issue.save()
        issue = Issue(title="Bla-Issue", project=cls.project, kanbancol=cls.project.kanbancol.first(), type="Task")
        issue.save()

        cls.issuep2 = Issue(title="Bling-Issue",
                            project=cls.project2,
                            kanbancol=cls.project2.kanbancol.first(),
                            type="Task")
        cls.issuep2.due_date = datetime.date(2000, 1, 1)
        cls.issuep2.save()
Beispiel #11
0
 def setUp(self):
     self.client.force_login(self.user)
     # NOTE: this element gets modified by some of those tests, so this shall NOT be created in setUpTestData()
     self.project = Project(creator=self.user, name_short='PRJ')
     self.project.save()
     self.project.developer.add(self.user)
     self.project.developer.add(self.user2)
     # NOTE: this element gets modified by some of those tests, so this shall NOT be created in setUpTestData()
     self.kanbancol = KanbanColumn(project=self.project,
                                   position=4,
                                   name='test')
     self.kanbancol.save()
     # NOTE: this element gets modified by some of those tests, so this shall NOT be created in setUpTestData()
     self.issue = Issue(
         title='a very very very very very very very long issue title',
         project=self.project,
         due_date='2016-12-16',
         kanbancol=self.kanbancol,
         storypoints='3')
     self.issue.save()
     self.issue2 = Issue(title='issue title',
                         project=self.project,
                         due_date='2016-12-16',
                         kanbancol=self.kanbancol,
                         storypoints='3')
     self.issue2.save()
     self.issue.assignee.add(self.user)
 def setUp(self):
     # NOTE: these elements get modified by some testcases, so they should NOT be created in setUpTestData()
     self.project = Project(creator=self.user1, name_short='asdf')
     self.project.save()
     self.project.developer.add(self.user1)
     self.project.developer.add(self.user2)
     self.project.manager.add(self.user1)
     self.project2 = Project(creator=self.user2, name_short='asdg')
     self.project2.save()
     self.project2.manager.add(self.user2)
     self.issue = Issue(title='test', project=self.project)
     self.issue.save()
     self.issue2 = Issue(title='test', project=self.project2)
     self.issue2.save()
     self.comment = Comment(text='test', creator=self.user1, issue=self.issue)
     self.comment.save()
     self.comment2 = Comment(text='test', creator=self.user2, issue=self.issue2)
     self.comment2.save()
     self.log = Timelog(time=datetime.timedelta(hours=2), user=self.user1, issue=self.issue)
     self.log.save()
     self.log2 = Timelog(time=datetime.timedelta(hours=2), user=self.user2, issue=self.issue2)
     self.log2.save()
     self.user1_auth = 'Basic ' + base64.b64encode('user1:c'.encode()).decode()
     self.user2_auth = 'Basic ' + base64.b64encode('user2:c'.encode()).decode()
     self.client.credentials(HTTP_AUTHORIZATION=self.user1_auth)
Beispiel #13
0
    def test_required_fields(self):
        driver = self.selenium

        # create issue and attach file
        issue = Issue(title="title",
                      kanbancol=KanbanColumn.objects.get(project=self.project,
                                                         name="Todo"),
                      due_date=str(datetime.date.today()),
                      priority=3,
                      storypoints=2,
                      description="blubber",
                      project=self.project)
        issue.save()

        driver.get("{}{}".format(
            self.live_server_url,
            reverse('issue:detail',
                    kwargs={
                        'project': self.project.name_short,
                        'sqn_i': issue.number
                    })))
        driver.find_element_by_id("attachment-btn").click()

        # assert that no attachment is created
        self.assertEqual(issue.attachments.count(), 0)
Beispiel #14
0
    def setUp(self):
        self.client.force_login(self.user)
        # NOTE: this element gets modified by some of those tests, so this shall NOT be created in setUpTestData()
        self.project = Project(creator=self.user, name_short='PRJ', activity_only_for_managers=False)
        self.project.save()
        self.project.developer.add(self.user)

        self.project2 = Project(creator=self.user, activity_only_for_managers=True, name_short='PRJJ')
        self.project2.save()
        self.project2.manager.add(self.user)
        self.project2.developer.add(self.user, self.user2)

        # NOTE: this element gets modified by some of those tests, so this shall NOT be created in setUpTestData()
        self.kanbancol = KanbanColumn(project=self.project, position=4, name='test')
        self.kanbancol.save()
        # NOTE: this element gets modified by some of those tests, so this shall NOT be created in setUpTestData()
        self.issue = Issue(title='a very very very very very very very long issue title',
                           project=self.project,
                           due_date='2016-12-16',
                           kanbancol=self.kanbancol,
                           storypoints='3'
                           )
        self.issue.save()
        self.issue.assignee.add(self.user)
        self.issue2 = Issue(title='second_issue', project=self.project)
        self.issue2.save()
        self.issue2.assignee.add(self.user)
        self.time = now().strftime("%Y-%m-%d %H:%M:%S")
Beispiel #15
0
    def test_add_and_remove_issue_from_sprint(self):
        kanbancol = KanbanColumn(name='Column', position=1, project=self.project)
        kanbancol.save()
        issue = Issue(title="Test-Issue", kanbancol=kanbancol, project=self.project, type="Bug")
        issue.save()

        # add to sprint
        response = self.client.post(reverse('sprint:assigntosprint', kwargs={'project': self.project.name_short}),
                                    {'sqn_i': issue.number}, follow=True,
                                    HTTP_REFERER=reverse('backlog:backlog',
                                                         kwargs={'project': self.project.name_short}))
        self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': self.project.name_short,
                                                                          'sqn_s': self.sprint.seqnum}))

        self.assertEqual(Issue.objects.get(pk=issue.pk).sprint, Sprint.objects.get(pk=self.sprint.pk))

        # remove from sprint
        response = self.client.post(reverse('sprint:assigntosprint', kwargs={'project': self.project.name_short}),
                                    {'sqn_s': self.sprint.seqnum, 'sqn_i': issue.number}, follow=True,
                                    HTTP_REFERER=reverse('backlog:backlog', kwargs={'project': self.project.name_short})
                                    )
        self.assertRedirects(response, reverse('backlog:backlog', kwargs={'project': self.project.name_short,
                                                                          'sqn_s': self.sprint.seqnum}))

        self.assertEqual(Issue.objects.get(pk=issue.pk).sprint, None)
Beispiel #16
0
    def setUp(self):
        self.user = get_user_model().objects.create_user(
            'test', '*****@*****.**', 'test')
        self.project = Project(creator=self.user, name_short='PRJ')
        self.project.save()
        self.project.developer.add(self.user)
        # NOTE: those elements get modified by some of those tests, so this shall NOT be created in setUpTestData()
        self.issue = Issue(title='issue title',
                           project=self.project,
                           due_date='2016-12-16',
                           storypoints='3')
        self.issue.save()
        self.issue2 = Issue(title='title2',
                            project=self.project,
                            due_date='2016-12-16',
                            storypoints='3')
        self.issue2.save()
        self.issue.assignee.add(self.user)

        # Uses the cookie hack from:
        # https://stackoverflow.com/questions/22494583/login-with-code-when-using-liveservertestcase-with-django
        client = Client()
        client.login(username='******', password='******')
        self.cookie = client.cookies['sessionid']
        self.selenium.get("{}{}".format(self.live_server_url,
                                        reverse('timelog:loginfo')))
        self.selenium.add_cookie({
            'name': 'sessionid',
            'value': self.cookie.value,
            'secure': False,
            'path': '/'
        })
        self.selenium.refresh()
Beispiel #17
0
 def setUp(self):
     self.client.force_login(self.user)
     # NOTE: these elements get modified by some testcases, so they should NOT be created in setUpTestData()
     self.project = Project(creator=self.user, name_short='PRJ')
     self.project.save()
     self.issue = Issue(title="Test-Issue", project=self.project, type="Bug")
     self.issue.save()
Beispiel #18
0
    def test_required_field_in_edit(self):
        driver = self.selenium

        # create issue
        issue = Issue(title="title",
                      kanbancol=KanbanColumn.objects.get(project=self.project,
                                                         name="Todo"),
                      due_date=str(datetime.date.today()),
                      priority=3,
                      storypoints=2,
                      description="blubber",
                      project=self.project)
        issue.save()

        driver.get("{}{}".format(
            self.live_server_url,
            reverse('issue:detail',
                    kwargs={
                        'project': self.project.name_short,
                        'sqn_i': issue.number
                    })))

        # add comment
        driver.find_element_by_id("id_text").clear()
        driver.find_element_by_id("id_text").send_keys("test-comment")
        driver.find_element_by_name("action").click()

        # edit comment with empty text field => should fail
        driver.find_element_by_id("issue_detail_comment_edit_1").click()
        driver.find_element_by_id("id_text").clear()
        driver.find_element_by_id("comment-btn").click()
        self.assertIn("Edit comment", driver.page_source)
        self.assertEqual(issue.comments.first().text, "test-comment")
        self.assertEqual(issue.comments.count(), 1)
    def test_number_kanbancolumns_for_case_not_default(self):
        driver = self.selenium
        issue = Issue(title="title", kanbancol=KanbanColumn.objects.get(project=self.project, name="Todo"),
                      due_date=str(datetime.date.today()), priority=3, storypoints=2, description="blubber",
                      project=self.project
                      )
        issue.save()
        issue.assignee.add(self.user)

        driver.get("{}{}".format(self.live_server_url, reverse('issue:create',
                                                               kwargs={'project': self.project2.name_short})))
        driver.find_element_by_id("id_title").send_keys("title")
        # assert that 2nd project has one kanban col more
        self.assertEqual(len(Select(driver.find_element_by_id("id_kanbancol")).options), 5)

        # assert that dependsOn now has one entry
        driver.get('{}{}'.format(self.live_server_url, reverse('backlog:backlog',
                                                               kwargs={'project': self.project.name_short}
                                                               )))
        driver.find_element_by_link_text("New issue").click()
        driver.find_element_by_xpath("(//input[@type='search'])[2]").send_keys('\n')
        time.sleep(1)
        self.assertEqual(len(driver.find_elements_by_css_selector('#select2-id_dependsOn-results li')), 1)
        for i in driver.find_elements_by_css_selector('#select2-id_dependsOn-results li'):
            self.assertIn("title", i.text)
Beispiel #20
0
    def test_reachable_and_elements_exist(self):
        driver = self.selenium

        # create attachment file
        filecontent1 = 'Hello World File 1'
        temp1 = tempfile.NamedTemporaryFile(delete=False)
        temp1.write(filecontent1.encode())
        temp1.close()

        # create issue and attach file
        issue = Issue(title="title", kanbancol=KanbanColumn.objects.get(project=self.project, name="Todo"),
                      due_date=str(datetime.date.today()), priority=3, storypoints=2, description="blubber",
                      project=self.project
                      )
        issue.save()

        driver.get("{}{}".format(self.live_server_url, reverse('issue:detail',
                                 kwargs={'project': self.project.name_short, 'sqn_i': issue.number})))

        driver.find_element_by_css_selector(
            "#attachment-form > div.form-group > div.row.bootstrap3-multi-input > div.col-xs-12 > #id_file"
            ).clear()
        driver.find_element_by_css_selector(
            "#attachment-form > div.form-group > div.row.bootstrap3-multi-input > div.col-xs-12 > #id_file"
            ).send_keys(temp1.name)
        driver.find_element_by_id("attachment-btn").click()

        # assert that attached file exists
        self.assertIn(driver.find_element_by_id("issue_detail_attach_get_1").text, temp1.name)
        self.assertEqual(issue.attachments.count(), 1)
        attachment = issue.attachments.first()
        self.assertIn(filecontent1, attachment.file.read().decode())

        os.remove(temp1.name)
Beispiel #21
0
 def setUp(self):
     self.client.force_login(self.user)
     # NOTE: these elements get modified by some testcases, so they should NOT be created in setUpTestData()
     self.issue = Issue(project=self.project,
                        due_date='2016-12-16',
                        kanbancol=self.kanbancol,
                        storypoints='3')
     self.issue.save()
     self.time = timezone.now().strftime("%Y-%m-%d %H:%M:%S")
Beispiel #22
0
    def test_timelog_loginfo_and_issue_loginfo_log_time_in_multiple_issues_and_projects_for_own_user(
            self):
        response = self.client.post(reverse('issue:log',
                                            kwargs={
                                                "project":
                                                self.issue.project.name_short,
                                                "sqn_i": self.issue.number
                                            }), {
                                                'time': '1h30m',
                                                'created_at': self.time
                                            },
                                    follow=True)
        response = self.client.post(reverse('issue:log',
                                            kwargs={
                                                "project":
                                                self.issue.project.name_short,
                                                "sqn_i": self.issue2.number
                                            }), {
                                                'time': '15m',
                                                'created_at': self.time
                                            },
                                    follow=True)
        response = self.client.get(reverse('timelog:loginfo'))
        # first log
        self.assertContains(response, "1 Hour and 30 Minutes")
        # second log - second issue
        self.assertContains(response, "15 Minutes")

        project2 = Project(creator=self.user, name_short='PRJ2')
        project2.save()
        project2.developer.add(self.user)
        # both are shown in timelog:loginfo
        response = self.client.get(reverse('timelog:loginfo'))
        self.assertContains(response, "1 Hour and 30 Minutes")
        self.assertContains(response, "15 Minutes")

        # additional log for a different project
        issue3 = Issue(title='third_issue', project=project2)
        issue3.save()
        issue3.assignee.add(self.user)
        response = self.client.post(reverse('issue:log',
                                            kwargs={
                                                "project": project2.name_short,
                                                "sqn_i": issue3.number
                                            }), {
                                                'time': '20m',
                                                'created_at': self.time
                                            },
                                    follow=True)

        # all three are shown in timelog:loginfo
        response = self.client.get(reverse('timelog:loginfo'))
        self.assertContains(response, "1 Hour and 30 Minutes")
        self.assertContains(response, "15 Minutes")
        self.assertContains(response, "20 Minutes")
Beispiel #23
0
 def setUp(self):
     # NOTE: these element gets modified by some of those tests, so they should NOT be created in setUpTestData()
     self.client.force_login(self.user)
     self.project = Project(creator=self.user, name_short=proj_short)
     self.project.save()
     self.project.manager.add(self.user)
     self.project.developer.add(self.user)
     self.column = KanbanColumn(name='Column', position=4, project=self.project)
     self.column.save()
     self.issue = Issue(title="Test-Issue", project=self.project, kanbancol=self.column, type="Bug")
     self.issue.save()
Beispiel #24
0
    def setUp(self):
        self.client.force_login(self.user)
        # NOTE: this element gets modified by some of those tests, so this shall NOT be created in setUpTestData()
        self.project = Project(creator=self.user, name_short='PRJ')
        self.project.save()

        self.issue = Issue(title="Test-Issue",
                           project=self.project,
                           kanbancol=self.project.kanbancol.first(),
                           type="Bug")
        self.issue.save()
Beispiel #25
0
    def test_upload_attachment(self):
        # TODO TESTCASE upload file as an attachment
        # TODO TESTCASE upload file together with a comment
        driver = self.selenium

        # create attachment file
        filecontent1 = 'Hello World File 1'
        temp1 = tempfile.NamedTemporaryFile(delete=False)
        temp1.write(filecontent1.encode())
        temp1.close()

        # create issue and attach file
        issue = Issue(title="title",
                      kanbancol=KanbanColumn.objects.get(project=self.project,
                                                         name="Todo"),
                      due_date=str(datetime.date.today()),
                      priority=3,
                      storypoints=2,
                      description="blubber",
                      project=self.project)
        issue.save()

        driver.get("{}{}".format(
            self.live_server_url,
            reverse('issue:detail',
                    kwargs={
                        'project': self.project.name_short,
                        'sqn_i': issue.number
                    })))

        driver.find_element(
            By.CSS_SELECTOR,
            "#attachment-form > div.form-group > div.row.bootstrap3-multi-input > \
                            div.col-xs-12 > #id_file").clear()
        driver.find_element(
            By.CSS_SELECTOR,
            "#attachment-form > div.form-group > div.row.bootstrap3-multi-input > \
                            div.col-xs-12 > #id_file").send_keys(temp1.name)
        driver.find_element(By.ID, "attachment-btn").click()

        # assert that attached file exists
        self.assertIn(
            driver.find_element(By.ID, "issue_detail_attach_get_1").text,
            temp1.name)
        self.assertEqual(issue.attachments.count(), 1)
        attachment = issue.attachments.first()
        self.assertIn(filecontent1, attachment.file.read().decode())
        attachment.file.close()

        # delete the uploaded file from the server
        os.unlink(MEDIA_ROOT + '/' + attachment.file.name)
        # delete the uploaded file locally
        os.unlink(temp1.name)
Beispiel #26
0
    def setUp(self):
        # NOTE: these elements get modified by some testcases, so they should NOT be created in setUpTestData()
        # notify user2 on new issues
        self.user2.set_preference("notify_mail", json.dumps({'PRJ': ['NewIssue']}))
        self.project = Project(creator=self.user1, name_short='PRJ', name='Project')
        self.project.save()
        self.project.developer.add(self.user1)
        self.project.developer.add(self.user2)
        self.project.manager.add(self.user1)

        self.issue1 = Issue(creator=self.user1, title='test', project=self.project)
        self.issue1.save()
 def create_some_issues(self):
     col = KanbanColumn.objects.filter(project=self.project)
     col2 = KanbanColumn.objects.filter(project=self.project2)
     iss = []
     iss.append(Issue(title='asd', kanbancol=col.get(pk=1), priority=0, type='Bug', project=self.project))
     iss.append(Issue(title='asd2', kanbancol=col.get(pk=2), priority=1, type='Story', project=self.project))
     iss.append(Issue(title='asd3', kanbancol=col.get(pk=3), priority=2, type='Task', project=self.project))
     iss.append(Issue(title='asd4', kanbancol=col.get(pk=3), priority=3, archived=True, project=self.project))
     iss.append(Issue(title='asd5', kanbancol=col2.first(), priority=4, project=self.project2))
     for issue in iss:
         issue.save()
         issue.assignee.add(self.user)
     return iss
Beispiel #28
0
    def create(self, validated_data):
        # TODO 이슈 생성 시에 태그 같이 생성
        tags_data = validated_data.pop('tags')

        # TODO 로그인된 사용자 세션 입력으로 바꾸기
        validated_data['user_id'] = 1

        issue = Issue(**validated_data)
        for tag_data in tags_data:
            tag = IssueTag.objects.create(**tag_data)
            issue.tags.add(tag)
        issue.save()
        return issue
Beispiel #29
0
 def test_get_timelogs(self):
     response = self.client.get(reverse('api:timelogs-list'))
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.json().get('count'), 1)
     issue = Issue(title='asdf', project=self.project)
     issue.save()
     log = Timelog(issue=issue,
                   user=self.user1,
                   time=datetime.timedelta(hours=2))
     log.save()
     response = self.client.get(reverse('api:timelogs-list'))
     self.assertEqual(response.status_code, status.HTTP_200_OK)
     self.assertEqual(response.json().get('count'), 2)
Beispiel #30
0
    def test_seen(self):
        self.client.force_login(self.user1)
        issue = Issue(title="iss1", project=self.project, creator=self.user2)
        issue.save()

        res = self.client.get(reverse("discussion:list"))
        self.assertContains(res, "iss1")

        self.client.post(
            reverse("discussion:seen", kwargs={'project': self.short}),
            {'issue': issue.number})
        res = self.client.get(reverse("discussion:list"))
        self.assertContains(res, "No unread messages.")
Beispiel #31
0
 def setUpTestData(cls):
     # NOTE: if you modify these elements they need to be created in setUp(), instead of here
     cls.user = get_user_model().objects.create_user('test', '*****@*****.**', 'test1234')
     cls.project = Project(creator=cls.user, name_short='PRJ')
     cls.project.save()
     cls.project.developer.add(cls.user)
     cls.kanbancol = KanbanColumn(project=cls.project, position=4, name='test')
     cls.kanbancol.save()
     cls.issue = Issue(project=cls.project, due_date='2016-12-16', kanbancol=cls.kanbancol, storypoints='3')
     cls.issue.save()
     cls.issue2 = Issue(project=cls.project, due_date='2016-12-16', kanbancol=cls.kanbancol, storypoints='3')
     cls.time = timezone.now().replace(microsecond=100000)
     cls.timestamp = cls.time.timestamp()
Beispiel #32
0
class IndexTest(TestCase):
    """
    smoke test the basic pages
    """ 
    def setUp(self):
        super(IndexTest , self).setUp()
        u = User.objects.create_user("test","*****@*****.**","test")
        self.i = Issue( title="test" , body="test", user=u )
        self.i.save()

    def tearDown(self):
        super( IndexTest , self ).tearDown()


    def test_smoke_test(self):
        """ smoke test loading the basic pages should just work"""
        urls = [ ]
        urls.append('/')
        urls.append(reverse('api_doc'))
        for url in urls:
            response = self.client.get(url)
            self.assertEqual(response.status_code , 200)

    def test_dashboard_test(self):
        """ smoke test views """
        self.assertEquals(
            self.client.login(username='******', password='******'), True) 

        urls = [ ]
        urls.append('/')
        urls.append(reverse('my_issues', args=["new"]))
        for url in urls:
            response = self.client.get(url)
            self.assertEqual(response.status_code , 200)

    def test_anonymous_votes(self):
        url = reverse("vote", args=[self.i.pk] )
        response = self.client.post(url, direction=1)
        self.assertEqual(response.status_code, 302)
Beispiel #33
0
def propose(user, title, body, direction, source_url,
            source_type=u"website", is_draft=False, issue_no=None):
    """ 
    Propose an issue into the game
    """
    if not issue_no:
        userprofile = user.get_profile()
        if not role_to_actions[userprofile.role].has_key('propose'): return 

        new_issue = Issue(
            title = title,
            url = source_url,
            source_type = source_type,
            body = body,
            user = user,
            is_draft = is_draft,
        )
        new_issue.save()

        user.message_set.create(message="You created issue \"%s\" successfully " % new_issue.title  )
        score.propose(user)
        levels.upgrade[userprofile.role](userprofile)
    else:
        # we are editing one TODO remove this possibility?
        issue = get_object_or_404(Issue, pk=issue_no)

        # Now change the issue and issue body to the appropriate values.
        issue.title = title
        issue.is_draft = is_draft
        issue.body = body
        issue.source_type = source_type
        issue.source_url = source_url
        issue.save()
        new_issue = issue

    Vote.objects.record_vote(user , new_issue, direction,)    

    return new_issue
Beispiel #34
0
 def setUp(self):
     super(IndexTest , self).setUp()
     u = User.objects.create_user("test","*****@*****.**","test")
     self.i = Issue( title="test" , body="test", user=u )
     self.i.save()