Пример #1
0
    def test_it_throws_an_exception_given_a_url_without_an_issue_number(self):
        github_url = "https://github.com/carlosmaniero/jigjs/issues/"

        with self.assertRaises(InvalidGithubUrlException) as context:
            IssueToBeCreated(github_url)

        self.assertEquals(context.exception.url, github_url)
Пример #2
0
    def test_it_throws_an_exception_given_a_url_without_owner(self):
        github_url = "https://github.com/"

        with self.assertRaises(InvalidGithubUrlException) as context:
            IssueToBeCreated(github_url)

        self.assertEquals(context.exception.url, github_url)
Пример #3
0
    def test_it_throws_an_exception_given_an_non_github_url(self):
        bitbucket_url = "http://bitbucket.com/carlosmaniero/issue/1"

        with self.assertRaises(InvalidGithubUrlException) as context:
            IssueToBeCreated(bitbucket_url)

        self.assertEquals(context.exception.url, bitbucket_url)
Пример #4
0
 def to_python(self, value):
     if not value:
         return
     try:
         return IssueToBeCreated(value)
     except InvalidGithubUrlException as e:
         raise ValidationError(
             f"It must be a Github issue URL. Found: {e.url}")
Пример #5
0
    def test_is_saves_the_issue(self) -> None:
        issue_to_be_created = IssueToBeCreated(
            "https://github.com/carlosmaniero/iwannacontrib-issues-test"
            "-integration-test/issues/1")
        service = CreateIssueService()

        issue = service.create_issue(self.github, issue_to_be_created)
        self.assertEquals(Issue.objects.get(id=issue.id), issue)
Пример #6
0
    def test_parses_the_url(self):
        github_url = "https://github.com/carlosmaniero/jigjs/issues/19"

        issue = IssueToBeCreated(github_url)
        self.assertEquals(issue.number, 19, 'issue id must be right')
        self.assertEquals(issue.repository, 'jigjs',
                          'repository must be right')
        self.assertEquals(issue.owner, 'carlosmaniero', 'owner must be right')
Пример #7
0
    def test_it_throws_an_exception_given_a_not_found_issue(self) -> None:
        issues_url = "https://github.com/carlosmaniero/iwannacontrib-issues-test-integration-test/issues/666"
        issue_to_be_created = IssueToBeCreated(issues_url)
        service = CreateIssueService()

        with self.assertRaises(IssueNotFoundException) as context:
            service.create_issue(self.github, issue_to_be_created)

        self.assertEquals(context.exception.url, issues_url)
Пример #8
0
    def test_it_creates_an_issue(self) -> None:
        issue_to_be_created = IssueToBeCreated(
            "https://github.com/carlosmaniero/iwannacontrib-issues-test"
            "-integration-test/issues/1")
        service = CreateIssueService()

        issue = service.create_issue(self.github, issue_to_be_created)

        self.assertEquals(issue.id, 1)
        self.assertEquals(issue.name, "Test Issue")
        self.assertEquals(issue.body,
                          "This issue is used at project integration tests.")
        self.assertEquals(issue.repository.name,
                          "iwannacontrib-issues-test-integration-test")
        self.assertEquals(issue.repository.owner.owner, "carlosmaniero")
        self.assertEquals(issue.main_language.name, "Python")
Пример #9
0
    def test_it_throws_an_exception_given_issue_already_exists(self) -> None:
        issue = Issue(
            number=1,
            name='any title',
            body='any body',
            main_language=ProgrammingLanguage.get_other_default_language(),
            repository=Repository.objects.create(
                name='iwannacontrib-issues-test-integration-test',
                owner=Owner.objects.create(owner='carlosmaniero')))
        issue.save()

        issues_url = "https://github.com/carlosmaniero/iwannacontrib-issues-test-integration-test/issues/1"
        issue_to_be_created = IssueToBeCreated(issues_url)
        service = CreateIssueService()

        with self.assertRaises(IssueAlreadyExists) as context:
            service.create_issue(self.github, issue_to_be_created)

        self.assertEquals(context.exception.url, issues_url)