Beispiel #1
0
    def test_issue_modify(self, slackmock):
        issue = Issue()
        issue.title = self.title_name
        issue.project = self.project
        issue.save()

        self.selenium.get(
                '{}{}'.format(
                    self.live_server_url,
                    reverse('issue:edit', kwargs={'project': self.short, 'sqn_i': issue.number})
                    )
                )
        f = self.selenium.find_element_by_css_selector("input.select2-search__field").click()
        time.sleep(1)
        self.selenium.find_elements_by_css_selector('#select2-id_assignee-results li')[0].click()
        self.selenium.find_element_by_id('id_submit_edit').click()
        slackmock().api_call.assert_called_with(
            "chat.postMessage",
            channel="channel",
            attachments=[{
                'fallback': str(self.user) + " changed issue "+self.short+"-1 "+self.title_name+".",
                'pretext': 'Issue changed:',
                'title': self.short+"-1 "+self.title_name,
                'title_link': "http://localhost:8000/project/"+self.short+"/issue/1/",
                'author_name': str(self.user),
                'author_link': "http://localhost:8000" + self.user.get_absolute_url(),
                'author_icon': "http://localhost:8000" + self.user.avatar.url,
                'fields': [{
                    'title': 'Assignee',
                    'value': ' → a',
                    'short': True,
                    }],
                'color': 'good',
            }]
        )
Beispiel #2
0
    def test_comment(self, slackmock):
        issue = Issue()
        issue.title = self.title_name
        issue.project = self.project
        issue.save()

        self.selenium.get(
                '{}{}'.format(
                    self.live_server_url,
                    reverse('issue:detail', kwargs={'project': self.project.name_short, 'sqn_i': issue.number})
                    )
                )
        f = self.selenium.find_element_by_id("id_text")
        f.send_keys(self.comment)
        self.selenium.find_element_by_name("action").click()
        slackmock().api_call.assert_called_with(
            "chat.postMessage",
            channel="channel",
            attachments=[{
                'fallback': str(self.user) + ' commented on \"'+self.short+'-1 '+self.title_name+'\".',
                'pretext': 'New comment:',
                'text': self.comment,
                'title': self.short+"-1 "+self.title_name,
                'title_link': "http://localhost:8000/project/"+self.short+"/issue/1/",
                'author_name': str(self.user),
                'author_link': "http://localhost:8000" + self.user.get_absolute_url(),
                'author_icon': "http://localhost:8000" + self.user.avatar.url,
                'color': 'good',
            }]
        )
Beispiel #3
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 #4
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 #5
0
    def test_issue_modify(self, slackmock):
        issue = Issue()
        issue.title = self.title_name
        issue.project = self.project
        issue.save()

        self.selenium.get('{}{}'.format(
            self.live_server_url,
            reverse('issue:edit',
                    kwargs={
                        'project': self.short,
                        'sqn_i': issue.number
                    })))

        # open assignee autocomplete field
        self.selenium.find_element(By.CSS_SELECTOR,
                                   "input.select2-search__field").click()
        # select first result
        self.selenium.find_elements(
            By.CSS_SELECTOR, '#select2-id_assignee-results li')[0].click()
        # close autocomplete
        self.selenium.find_element(By.CSS_SELECTOR,
                                   "input.select2-search__field").send_keys(
                                       Keys.ESCAPE)

        self.selenium.find_element(By.ID, 'id_submit_edit').click()
        slackmock.chat_postMessage.assert_called_with(
            channel="channel",
            attachments=[{
                'fallback':
                str(self.user) + " changed issue " + self.short + "-1 " +
                self.title_name + ".",
                'pretext':
                'Issue changed:',
                'title':
                self.short + "-1 " + self.title_name,
                'title_link':
                "http://localhost:8000/project/" + self.short + "/issue/1/",
                'author_name':
                str(self.user),
                'author_link':
                "http://localhost:8000" + self.user.get_absolute_url(),
                'author_icon':
                "http://localhost:8000" + self.user.avatar.url,
                'fields': [{
                    'title': 'Assignee',
                    'value': ' → a',
                    'short': True,
                }],
                'color':
                'good',
            }])
Beispiel #6
0
    def test_delete_issue(self):
        issue = Issue(title="foo123")
        issue.project = self.project
        issue.save()

        response = self.client.post(
            reverse('issue:delete',
                    kwargs={
                        'project': self.project.name_short,
                        'sqn_i': issue.number
                    }), {'delete': 'true'})
        self.assertRedirects(
            response,
            reverse('issue:backlog',
                    kwargs={'project': self.project.name_short}))
        response = self.client.get(response['location'])
        self.assertTemplateUsed(response, 'issue/backlog_list.html')
        self.assertNotContains(response, "foo123")
Beispiel #7
0
    def test_delete_with_timelog(self):
        issue = Issue(title="foo")
        issue.project = self.project
        issue.save()
        Timelog(user=self.user, issue=issue, time=timedelta(1)).save()

        response = self.client.post(reverse('issue:delete',
                                            kwargs={
                                                'project':
                                                self.project.name_short,
                                                'sqn_i': issue.number
                                            }), {'delete': 'true'},
                                    follow=True)
        self.assertRedirects(
            response,
            reverse('issue:backlog',
                    kwargs={'project': self.project.name_short}))
        self.assertContains(response, "foo")
        self.assertContains(response, "logged time")
Beispiel #8
0
    def test_view_and_template(self):
        # create
        response = self.client.get(
            reverse('issue:create',
                    kwargs={'project': self.project.name_short}))
        self.assertTemplateUsed(response, create_template)
        self.assertEqual(response.resolver_match.func.__name__,
                         IssueCreateView.as_view().__name__)

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

        # edit
        response = self.client.get(
            reverse('issue:edit',
                    kwargs={
                        'project': self.project.name_short,
                        'sqn_i': number
                    }))
        self.assertTemplateUsed(response, edit_template)
        self.assertEqual(response.resolver_match.func.__name__,
                         IssueEditView.as_view().__name__)

        # detail
        response = self.client.get(
            reverse('issue:detail',
                    kwargs={
                        'project': self.project.name_short,
                        'sqn_i': number
                    }))
        self.assertTemplateUsed(response, detail_template)
        self.assertEqual(response.resolver_match.func.__name__,
                         IssueDetailView.as_view().__name__)
Beispiel #9
0
    def test_create_and_edit_issues_with_get_requests_disabled(self):
        values = {
            'title': "Test-Issue",
            'kanbancol': self.column.pk,
            'type': "Bug",
            'assignee': (self.user.pk),
            'priority': 2,
        }
        # create
        response = self.client.get(
            reverse('issue:create',
                    kwargs={'project': self.project.name_short}), values)
        # didn't store something
        self.assertTemplateUsed(response, create_template)
        try:
            self.assertIsNone(
                Issue.objects.get(title="Test-Issue", assignee=self.user.pk))
        except Issue.DoesNotExist:
            pass

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

        # edit
        response = self.client.get(
            reverse('issue:edit',
                    kwargs={
                        'project': self.project.name_short,
                        'sqn_i': number
                    }), values)
        # didn't store something
        self.assertIsNotNone(
            Issue.objects.get(title="foo", project=self.project))
Beispiel #10
0
    def test_redirect_to_login_and_login_required(self):
        self.client.logout()
        # create
        response = self.client.get(
            reverse('issue:create',
                    kwargs={'project': self.project.name_short}))
        self.assertEqual(response.status_code, 302)
        self.assertEqual(
            response['location'], '/login/?next=' + reverse(
                'issue:create', kwargs={'project': self.project.name_short}))
        response = self.client.get(response['location'])
        # verify the login-required mixin
        self.assertEqual(response.resolver_match.func.__name__,
                         LoginView.as_view().__name__)
        self.assertContains(response, 'Please login to see this page.')

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

        # edit
        response = self.client.get(
            reverse('issue:edit',
                    kwargs={
                        'project': self.project.name_short,
                        'sqn_i': number
                    }))
        self.assertEqual(response.status_code, 302)
        self.assertEqual(
            response['location'],
            '/login/?next=' + reverse('issue:edit',
                                      kwargs={
                                          'project': self.project.name_short,
                                          'sqn_i': number
                                      }))
        response = self.client.get(response['location'])
        # verify the login-required mixin
        self.assertEqual(response.resolver_match.func.__name__,
                         LoginView.as_view().__name__)
        self.assertContains(response, 'Please login to see this page.')

        # detail
        response = self.client.get(
            reverse('issue:detail',
                    kwargs={
                        'project': self.project.name_short,
                        'sqn_i': number
                    }))
        self.assertEqual(response.status_code, 302)
        self.assertEqual(
            response['location'],
            '/login/?next=' + reverse('issue:detail',
                                      kwargs={
                                          'project': self.project.name_short,
                                          'sqn_i': number
                                      }))
        response = self.client.get(response['location'])
        # verify the login-required mixin
        self.assertEqual(response.resolver_match.func.__name__,
                         LoginView.as_view().__name__)
        self.assertContains(response, 'Please login to see this page.')
        pass