예제 #1
0
    def test_next_version():

        changelog = model.Changelog(sha='sha', current_version='0.0.1')

        patch_issue = model.ChangelogIssue(title='patch issue',
                                           url='url1',
                                           timestamp=100,
                                           semantic=model.ChangelogIssue.PATCH)

        minor_issue = model.ChangelogIssue(title='minor issue',
                                           url='url2',
                                           timestamp=50,
                                           semantic=model.ChangelogIssue.MINOR)

        major_issue = model.ChangelogIssue(title='major issue',
                                           url='url3',
                                           timestamp=10,
                                           semantic=model.ChangelogIssue.MAJOR)

        changelog.add(patch_issue)
        changelog.add(minor_issue)
        changelog.add(major_issue)

        expected_version = '1.1.1'

        assert expected_version == changelog.next_version
예제 #2
0
    def test_render_all(request):

        changelog = model.Changelog(sha='sha', current_version='0.0.1')

        commit = model.ChangelogCommit(title=request.node.name,
                                       url='url',
                                       timestamp=121234)

        bug = model.ChangelogIssue(title=request.node.name,
                                   url='url',
                                   timestamp=121234,
                                   kind=model.ChangelogIssue.FEATURE)

        issue = model.ChangelogIssue(title=request.node.name,
                                     url='url',
                                     timestamp=121234,
                                     kind=model.ChangelogIssue.ISSUE)

        feature = model.ChangelogIssue(title=request.node.name,
                                       url='url',
                                       timestamp=121234,
                                       kind=model.ChangelogIssue.FEATURE)

        changelog.add(commit)
        changelog.add(bug)
        changelog.add(issue)
        changelog.add(feature)

        expected = """*Changes*


**New Features:**


- {0} ([Issue](url))






**Issues:**


- {0} ([Issue](url))




**Dangling Commits:**


- {0} ([Commit](url))

""".format(request.node.name)

        actual = changelog.render()

        assert expected == actual
예제 #3
0
    def test_render_only_features(request):

        changelog = model.Changelog(sha='sha', current_version='0.0.1')

        feature = model.ChangelogIssue(title=request.node.name,
                                       url='url',
                                       timestamp=121234,
                                       kind=model.ChangelogIssue.FEATURE)

        changelog.add(feature)

        expected = """*Changes*


**New Features:**


- {} ([Issue](url))







""".format(request.node.name)

        actual = changelog.render()

        assert expected == actual
예제 #4
0
    def test_render_only_bugs(request):

        changelog = model.Changelog(sha='sha', current_version='0.0.1')

        bug = model.ChangelogIssue(title=request.node.name,
                                   url='url',
                                   timestamp=121234,
                                   kind=model.ChangelogIssue.BUG)

        changelog.add(bug)

        expected = """*Changes*




**Bug Fixes:**


- {} ([Issue](url))





""".format(request.node.name)

        actual = changelog.render()

        assert expected == actual
예제 #5
0
    def test_add_identical_issues():

        changelog = model.Changelog(sha='sha', current_version='0.0.1')

        issue1 = model.ChangelogIssue(title='issue',
                                      url='url',
                                      timestamp=100,
                                      kind=model.ChangelogIssue.ISSUE)

        issue2 = model.ChangelogIssue(title='issue',
                                      url='url',
                                      timestamp=100,
                                      kind=model.ChangelogIssue.ISSUE)

        changelog.add(issue1)
        changelog.add(issue2)

        expected_number_of_issues = 1

        assert expected_number_of_issues == len(changelog.issues)
예제 #6
0
    def test_add_identical_bugs():

        changelog = model.Changelog(sha='sha', current_version='0.0.1')

        bug1 = model.ChangelogIssue(title='bug',
                                    url='url',
                                    timestamp=100,
                                    kind=model.ChangelogIssue.BUG)

        bug2 = model.ChangelogIssue(title='bug',
                                    url='url',
                                    timestamp=100,
                                    kind=model.ChangelogIssue.BUG)

        changelog.add(bug1)
        changelog.add(bug2)

        expected_number_of_bugs = 1

        assert expected_number_of_bugs == len(changelog.bugs)
예제 #7
0
    def test_add_identical_features():

        changelog = model.Changelog(sha='sha', current_version='0.0.1')

        feature1 = model.ChangelogIssue(title='feature',
                                        url='url',
                                        timestamp=100,
                                        kind=model.ChangelogIssue.FEATURE)

        feature2 = model.ChangelogIssue(title='feature',
                                        url='url',
                                        timestamp=100,
                                        kind=model.ChangelogIssue.FEATURE)

        changelog.add(feature1)
        changelog.add(feature2)

        expected_number_of_features = 1

        assert expected_number_of_features == len(changelog.features)
예제 #8
0
    def test_next_version_none(request):

        changelog = model.Changelog(sha='sha', current_version='0.0.1')

        non_release_issue = model.ChangelogIssue(title=request.node.name,
                                                 url='url',
                                                 timestamp=123123)
        changelog.add(non_release_issue)

        expected_version = None

        assert expected_version == changelog.next_version
예제 #9
0
    def test_not_empty_issues(request):

        changelog = model.Changelog(sha='sha', current_version='0.0.1')

        issue = model.ChangelogIssue(title=request.node.name,
                                     url='url',
                                     timestamp=121234,
                                     kind=model.ChangelogIssue.ISSUE)

        changelog.add(issue)

        assert not changelog.empty
예제 #10
0
    def test_add_identical_commits():

        changelog = model.Changelog(sha='sha', current_version='0.0.1')

        commit1 = model.ChangelogCommit(title='commit',
                                        url='url',
                                        timestamp=100)

        commit2 = model.ChangelogIssue(title='commit',
                                       url='url',
                                       timestamp=100)

        changelog.add(commit1)
        changelog.add(commit2)

        expected_number_of_commits = 1

        assert expected_number_of_commits == len(changelog.commits)
예제 #11
0
    def test_add_feature(request):

        changelog = model.Changelog(sha='sha', current_version='0.0.1')

        feature = model.ChangelogIssue(title=request.node.name,
                                       url='url',
                                       timestamp=121234,
                                       kind=model.ChangelogIssue.FEATURE)

        changelog.add(feature)

        expected_feature_title = request.node.name
        expected_number_of_features = 1

        assert expected_number_of_features == len(changelog.features)
        assert expected_feature_title == changelog.features.pop().title
        assert not changelog.bugs
        assert not changelog.issues
        assert not changelog.commits
예제 #12
0
    def _add_issue_to_changelog(self, issue, changelog):

        issue = issue.impl
        self._debug('Fetching labels...', issue=issue.number)
        labels = [label.name for label in list(issue.get_labels())]
        self._debug('Fetched labels.',
                    issue=issue.number,
                    labels=','.join(labels))

        semantic = None

        if 'patch' in labels:
            semantic = model.ChangelogIssue.PATCH
        elif 'minor' in labels:
            semantic = model.ChangelogIssue.MINOR
        elif 'major' in labels:
            semantic = model.ChangelogIssue.MAJOR

        if 'feature' in labels:
            self._debug('Found feature.', issue=issue.number)
            kind = model.ChangelogIssue.FEATURE
        elif 'bug' in labels:
            self._debug('Found bug.', issue=issue.number)
            kind = model.ChangelogIssue.BUG
        else:
            self._debug('Found issue.', issue=issue.number)
            kind = model.ChangelogIssue.ISSUE

        change = model.ChangelogIssue(impl=issue,
                                      title=issue.title,
                                      url=issue.html_url,
                                      timestamp=issue.created_at,
                                      kind=kind,
                                      semantic=semantic)

        self._debug('Adding change to changelog.', change=change.url)
        changelog.add(change)
예제 #13
0
 def test_no_timestamp():
     with pytest.raises(exceptions.InvalidArgumentsException):
         model.ChangelogIssue(title='title', url='url', timestamp=None)