1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
# ----------------------------------------------------------------------------- |
3
|
|
|
# Copyright (c) The Spyder Development Team |
4
|
|
|
# |
5
|
|
|
# Licensed under the terms of the MIT License |
6
|
|
|
# (See LICENSE.txt for details) |
7
|
|
|
# ----------------------------------------------------------------------------- |
8
|
|
|
"""Tests changelog output.""" |
9
|
|
|
|
10
|
|
|
# Standard library imports |
11
|
|
|
import os |
12
|
|
|
|
13
|
|
|
# Third party imports |
14
|
|
|
import pytest |
15
|
|
|
|
16
|
|
|
# Local imports |
17
|
|
|
from loghub.main import create_changelog |
18
|
|
|
|
19
|
|
|
REPO = 'spyder-ide/loghub' |
20
|
|
|
TEST_TOKEN = os.environ.get('TEST_TOKEN', '').replace('x', '') |
21
|
|
|
TEST_USER = os.environ.get('TEST_USER', '').replace('x', '') |
22
|
|
|
TEST_PASS = os.environ.get('TEST_CODE', '').replace('x', '') |
23
|
|
|
TEST_MILESTONE = 'test-milestone' |
24
|
|
|
TEST_TAG = 'v0.1.2' |
25
|
|
|
NOT_ON_CI = os.environ.get('CIRCLECI') != 'true' |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
# --- Tests |
29
|
|
|
# ----------------------------------------------------------------------------- |
30
|
|
|
@pytest.mark.skipif(NOT_ON_CI, reason='test on ci server only') |
31
|
|
|
def test_changelog(): |
32
|
|
|
log = create_changelog( |
33
|
|
|
repo=REPO, |
34
|
|
|
token=TEST_TOKEN, |
35
|
|
|
milestone=TEST_MILESTONE, |
36
|
|
|
branch='master', |
37
|
|
|
output_format='changelog') |
38
|
|
|
expected = '''## Version <RELEASE_VERSION> (2016-12-05) |
39
|
|
|
|
40
|
|
|
### Issues Closed |
41
|
|
|
|
42
|
|
|
* [Issue 26](https://github.com/spyder-ide/loghub/issues/26) - Test number 2 |
43
|
|
|
* [Issue 24](https://github.com/spyder-ide/loghub/issues/24) - Issue test |
44
|
|
|
|
45
|
|
|
In this release 2 issues were closed. |
46
|
|
|
|
47
|
|
|
### Pull Requests Merged |
48
|
|
|
|
49
|
|
|
* [PR 25](https://github.com/spyder-ide/loghub/pull/25) - PR: Add tests folder |
50
|
|
|
|
51
|
|
|
In this release 1 pull request was closed. |
52
|
|
|
''' |
53
|
|
|
print([log]) |
54
|
|
|
print([expected]) |
55
|
|
|
assert log == expected |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
@pytest.mark.skipif(NOT_ON_CI, reason='test on ci server only') |
59
|
|
|
def test_changelog_release(): |
60
|
|
|
log = create_changelog( |
61
|
|
|
repo=REPO, |
62
|
|
|
token=TEST_TOKEN, |
63
|
|
|
milestone=TEST_MILESTONE, |
64
|
|
|
branch='master', |
65
|
|
|
output_format='release') |
66
|
|
|
expected = '''## Version <RELEASE_VERSION> (2016-12-05) |
67
|
|
|
|
68
|
|
|
### Issues Closed |
69
|
|
|
|
70
|
|
|
* Issue #26 - Test number 2 |
71
|
|
|
* Issue #24 - Issue test |
72
|
|
|
|
73
|
|
|
In this release 2 issues were closed. |
74
|
|
|
|
75
|
|
|
### Pull Requests Merged |
76
|
|
|
|
77
|
|
|
* PR #25 - PR: Add tests folder |
78
|
|
|
|
79
|
|
|
In this release 1 pull request was closed. |
80
|
|
|
''' |
81
|
|
|
print([log]) |
82
|
|
|
print([expected]) |
83
|
|
|
assert log == expected |
84
|
|
|
|
85
|
|
|
|
86
|
|
|
@pytest.mark.skipif(NOT_ON_CI, reason='test on ci server only') |
87
|
|
|
def test_changelog_release_branch(): |
88
|
|
|
log = create_changelog( |
89
|
|
|
repo=REPO, |
90
|
|
|
token=TEST_TOKEN, |
91
|
|
|
milestone=TEST_MILESTONE, |
92
|
|
|
branch='test-branch', |
93
|
|
|
output_format='release') |
94
|
|
|
expected = '''## Version <RELEASE_VERSION> (2016-12-05) |
95
|
|
|
|
96
|
|
|
### Issues Closed |
97
|
|
|
|
98
|
|
|
* Issue #26 - Test number 2 |
99
|
|
|
* Issue #24 - Issue test |
100
|
|
|
|
101
|
|
|
In this release 2 issues were closed. |
102
|
|
|
|
103
|
|
|
### Pull Requests Merged |
104
|
|
|
|
105
|
|
|
* PR #33 - PR: Test change |
106
|
|
|
|
107
|
|
|
In this release 1 pull request was closed. |
108
|
|
|
''' |
109
|
|
|
print([log]) |
110
|
|
|
print([expected]) |
111
|
|
|
assert log == expected |
112
|
|
|
|