Skip to content

Commit

Permalink
Prepare 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Nov 19, 2019
1 parent f273729 commit 42593b5
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ are used for versioning (schema follows below):
- ``matyan-create-config`` command renamed to ``matyan-make-config``.
- Next to the commands, functions are tested as well.
- Fix issue with lower edge nog being included when using dotted range.
- Added more tests.

0.2.1
-----
Expand Down
11 changes: 11 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.

0.3
---
2019-11-20

- Most of the functions got optional ``path`` parameter to use as
path to the repository directory.
- ``matyan-create-config`` command renamed to ``matyan-make-config``.
- Next to the commands, functions are tested as well.
- Fix issue with lower edge nog being included when using dotted range.
- Added more tests.

0.2.1
-----
2019-11-19
Expand Down
31 changes: 30 additions & 1 deletion src/matyan/tests/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def prepare_changelog_data(cls):
# Go to cloned repository
os.chdir(cls.test_dir)

# ************************** Markdown *******************************

# Expected output of the `generate-changelog` command.
changelog_output = project_dir(
'tests/output/generate-changelog.md'
Expand All @@ -40,7 +42,7 @@ def prepare_changelog_data(cls):
# Expected output of the `generate-changelog --show-releases`
# command.
changelog_releases_output = project_dir(
'tests/output/generate-changelog-releases.md'
'tests/output/generate-changelog-show-releases.md'
)
with open(changelog_releases_output, 'r') as file:
cls.changelog_releases_output = file.read().strip()
Expand All @@ -54,3 +56,30 @@ def prepare_changelog_data(cls):
with open(changelog_latest_release_show_releases_output, 'r') as file:
cls.changelog_latest_release_show_releases_output \
= file.read().strip()

# **************************** JSON *******************************

# Expected output of the `json-changelog` command.
json_output = project_dir(
'tests/output/json-changelog.json'
)
with open(json_output, 'r') as file:
cls.json_output = file.read().strip()

# Expected output of the `json-changelog --show-releases`
# command.
json_show_releases_output = project_dir(
'tests/output/json-changelog-show-releases.json'
)
with open(json_show_releases_output, 'r') as file:
cls.json_show_releases_output = file.read().strip()

# Expected output of the
# `json-changelog --show-releases --latest-release`
# command.
json_latest_release_show_releases_output = project_dir(
'tests/output/json-changelog-latest-release-show-releases.json'
)
with open(json_latest_release_show_releases_output, 'r') as file:
cls.json_latest_release_show_releases_output \
= file.read().strip()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{'0.2': {'feature': {'MSFT-1238': {'commit_hash': 'c42ff7ed2e5b1a3c42ead2b81735397cefc554b8', 'commit_abbr': 'c42ff7e', 'ticket_number': 'MSFT-1238', 'branch_type': 'feature', 'slug': 'Token-authentication', 'title': 'Token Authentication', 'commits': {'Update authentication docs': {'commit_hash': '513e790ccf0a7f3024fb226b0c530e04528ff046', 'commit_abbr': '513e790', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:50:08 +0100', 'ticket_number': 'MSFT-1238', 'title': 'Update authentication docs'}, 'Implement token authentication': {'commit_hash': '7fbd3035ef40d0f311469ec88088266bc7d13f5c', 'commit_abbr': '7fbd303', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:49:49 +0100', 'ticket_number': 'MSFT-1238', 'title': 'Implement token authentication'}}, 'release': '0.2'}, 'MSFT-1237': {'commit_hash': '2d799b037160961d7ebc6e552dfd63c60b155553', 'commit_abbr': '2d799b0', 'ticket_number': 'MSFT-1237', 'branch_type': 'feature', 'slug': 'Improve-document-sharing', 'title': 'Improve Document Sharing', 'commits': {'Improve document sharing. Add option to share via GDrive': {'commit_hash': 'b54d3263c3d14cc77e73e730228ac064551145cc', 'commit_abbr': 'b54d326', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:48:04 +0100', 'ticket_number': 'MSFT-1237', 'title': 'Improve document sharing. Add option to share via GDrive'}}, 'release': '0.2'}}}}
1 change: 1 addition & 0 deletions src/matyan/tests/output/json-changelog-show-releases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{'0.2': {'feature': {'MSFT-1238': {'commit_hash': 'c42ff7ed2e5b1a3c42ead2b81735397cefc554b8', 'commit_abbr': 'c42ff7e', 'ticket_number': 'MSFT-1238', 'branch_type': 'feature', 'slug': 'Token-authentication', 'title': 'Token Authentication', 'commits': {'Update authentication docs': {'commit_hash': '513e790ccf0a7f3024fb226b0c530e04528ff046', 'commit_abbr': '513e790', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:50:08 +0100', 'ticket_number': 'MSFT-1238', 'title': 'Update authentication docs'}, 'Implement token authentication': {'commit_hash': '7fbd3035ef40d0f311469ec88088266bc7d13f5c', 'commit_abbr': '7fbd303', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:49:49 +0100', 'ticket_number': 'MSFT-1238', 'title': 'Implement token authentication'}}, 'release': '0.2'}, 'MSFT-1237': {'commit_hash': '2d799b037160961d7ebc6e552dfd63c60b155553', 'commit_abbr': '2d799b0', 'ticket_number': 'MSFT-1237', 'branch_type': 'feature', 'slug': 'Improve-document-sharing', 'title': 'Improve Document Sharing', 'commits': {'Improve document sharing. Add option to share via GDrive': {'commit_hash': 'b54d3263c3d14cc77e73e730228ac064551145cc', 'commit_abbr': 'b54d326', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:48:04 +0100', 'ticket_number': 'MSFT-1237', 'title': 'Improve document sharing. Add option to share via GDrive'}}, 'release': '0.2'}}}, '0.1': {'bugfix': {'MSFT-1236': {'commit_hash': '5d20c1b24c0dce57b8972250d09d417e41b6faf2', 'commit_abbr': '5d20c1b', 'ticket_number': 'MSFT-1236', 'branch_type': 'bugfix', 'slug': 'prevent-duplicate-postal-codes', 'title': 'Prevent Duplicate Postal Codes', 'commits': {'Make postal code field unique for the country': {'commit_hash': '4ee17c4126be93bb9d0ffd7b2370f180e7fd0056', 'commit_abbr': '4ee17c4', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:44:58 +0100', 'ticket_number': 'MSFT-1236', 'title': 'Make postal code field unique for the country'}, 'Normalise postal codes for US addresses': {'commit_hash': '47ddb712de58c88e0c0067ba63610c18af6d3815', 'commit_abbr': '47ddb71', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:44:32 +0100', 'ticket_number': 'MSFT-1236', 'title': 'Normalise postal codes for US addresses'}, 'Normalise postal codes for German addresses': {'commit_hash': 'b2e08fd1b52d7837d64250a3d2bf1fd1cdef7849', 'commit_abbr': 'b2e08fd', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:44:01 +0100', 'ticket_number': 'MSFT-1236', 'title': 'Normalise postal codes for German addresses'}}, 'release': '0.1'}}, 'deprecation': {'MSFT-1235': {'commit_hash': 'd794c5aa297d3bf34fe20cb47b3e04a298915357', 'commit_abbr': 'd794c5a', 'ticket_number': 'MSFT-1235', 'branch_type': 'deprecation', 'slug': 'deprecate-old-api', 'title': 'Deprecate Old Api', 'commits': {'Update docs': {'commit_hash': '7ab619cda816e714b66865fd8395af4ad591d080', 'commit_abbr': '7ab619c', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:42:22 +0100', 'ticket_number': 'MSFT-1235', 'title': 'Update docs'}, 'Deprecate API v 2.0': {'commit_hash': 'a84a77fa712d7f4e1e018de2d9b0607943544877', 'commit_abbr': 'a84a77f', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:41:44 +0100', 'ticket_number': 'MSFT-1235', 'title': 'Deprecate API v 2.0'}}, 'release': '0.1'}}, 'feature': {'MSFT-1234': {'commit_hash': '5babfbe19a31a8386f52d730eccd4df60fb775dd', 'commit_abbr': '5babfbe', 'ticket_number': 'MSFT-1234', 'branch_type': 'feature', 'slug': 'car-type-suggester', 'title': 'Car Type Suggester', 'commits': {'Add insurance amount indication based on car weight': {'commit_hash': 'd74a816dd27052fe1ffe61997513b94df8682af3', 'commit_abbr': 'd74a816', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:39:23 +0100', 'ticket_number': 'MSFT-1234', 'title': 'Add insurance amount indication based on car weight'}, 'Initial car type suggester implementation': {'commit_hash': 'a68119cb3b519b35b322aeb14f64c5b41810b39c', 'commit_abbr': 'a68119c', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:37:23 +0100', 'ticket_number': 'MSFT-1234', 'title': 'Initial car type suggester implementation'}}, 'release': '0.1'}}, 'other': {None: {'commits': {'Readme': {'commit_hash': '22dd2c07649bd783275e8ebeb3a4b565af9215a3', 'commit_abbr': '22dd2c0', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:36:27 +0100', 'ticket_number': None, 'title': 'Readme'}}}}}}
1 change: 1 addition & 0 deletions src/matyan/tests/output/json-changelog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{'feature': {'MSFT-1238': {'commit_hash': 'c42ff7ed2e5b1a3c42ead2b81735397cefc554b8', 'commit_abbr': 'c42ff7e', 'ticket_number': 'MSFT-1238', 'branch_type': 'feature', 'slug': 'Token-authentication', 'title': 'Token Authentication', 'commits': {'Update authentication docs': {'commit_hash': '513e790ccf0a7f3024fb226b0c530e04528ff046', 'commit_abbr': '513e790', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:50:08 +0100', 'ticket_number': 'MSFT-1238', 'title': 'Update authentication docs'}, 'Implement token authentication': {'commit_hash': '7fbd3035ef40d0f311469ec88088266bc7d13f5c', 'commit_abbr': '7fbd303', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:49:49 +0100', 'ticket_number': 'MSFT-1238', 'title': 'Implement token authentication'}}, 'release': '0.2'}, 'MSFT-1237': {'commit_hash': '2d799b037160961d7ebc6e552dfd63c60b155553', 'commit_abbr': '2d799b0', 'ticket_number': 'MSFT-1237', 'branch_type': 'feature', 'slug': 'Improve-document-sharing', 'title': 'Improve Document Sharing', 'commits': {'Improve document sharing. Add option to share via GDrive': {'commit_hash': 'b54d3263c3d14cc77e73e730228ac064551145cc', 'commit_abbr': 'b54d326', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:48:04 +0100', 'ticket_number': 'MSFT-1237', 'title': 'Improve document sharing. Add option to share via GDrive'}}, 'release': '0.2'}, 'MSFT-1234': {'commit_hash': '5babfbe19a31a8386f52d730eccd4df60fb775dd', 'commit_abbr': '5babfbe', 'ticket_number': 'MSFT-1234', 'branch_type': 'feature', 'slug': 'car-type-suggester', 'title': 'Car Type Suggester', 'commits': {'Add insurance amount indication based on car weight': {'commit_hash': 'd74a816dd27052fe1ffe61997513b94df8682af3', 'commit_abbr': 'd74a816', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:39:23 +0100', 'ticket_number': 'MSFT-1234', 'title': 'Add insurance amount indication based on car weight'}, 'Initial car type suggester implementation': {'commit_hash': 'a68119cb3b519b35b322aeb14f64c5b41810b39c', 'commit_abbr': 'a68119c', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:37:23 +0100', 'ticket_number': 'MSFT-1234', 'title': 'Initial car type suggester implementation'}}, 'release': '0.1'}}, 'bugfix': {'MSFT-1236': {'commit_hash': '5d20c1b24c0dce57b8972250d09d417e41b6faf2', 'commit_abbr': '5d20c1b', 'ticket_number': 'MSFT-1236', 'branch_type': 'bugfix', 'slug': 'prevent-duplicate-postal-codes', 'title': 'Prevent Duplicate Postal Codes', 'commits': {'Make postal code field unique for the country': {'commit_hash': '4ee17c4126be93bb9d0ffd7b2370f180e7fd0056', 'commit_abbr': '4ee17c4', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:44:58 +0100', 'ticket_number': 'MSFT-1236', 'title': 'Make postal code field unique for the country'}, 'Normalise postal codes for US addresses': {'commit_hash': '47ddb712de58c88e0c0067ba63610c18af6d3815', 'commit_abbr': '47ddb71', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:44:32 +0100', 'ticket_number': 'MSFT-1236', 'title': 'Normalise postal codes for US addresses'}, 'Normalise postal codes for German addresses': {'commit_hash': 'b2e08fd1b52d7837d64250a3d2bf1fd1cdef7849', 'commit_abbr': 'b2e08fd', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:44:01 +0100', 'ticket_number': 'MSFT-1236', 'title': 'Normalise postal codes for German addresses'}}, 'release': '0.1'}}, 'deprecation': {'MSFT-1235': {'commit_hash': 'd794c5aa297d3bf34fe20cb47b3e04a298915357', 'commit_abbr': 'd794c5a', 'ticket_number': 'MSFT-1235', 'branch_type': 'deprecation', 'slug': 'deprecate-old-api', 'title': 'Deprecate Old Api', 'commits': {'Update docs': {'commit_hash': '7ab619cda816e714b66865fd8395af4ad591d080', 'commit_abbr': '7ab619c', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:42:22 +0100', 'ticket_number': 'MSFT-1235', 'title': 'Update docs'}, 'Deprecate API v 2.0': {'commit_hash': 'a84a77fa712d7f4e1e018de2d9b0607943544877', 'commit_abbr': 'a84a77f', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:41:44 +0100', 'ticket_number': 'MSFT-1235', 'title': 'Deprecate API v 2.0'}}, 'release': '0.1'}}, 'other': {None: {'commits': {'Readme': {'commit_hash': '22dd2c07649bd783275e8ebeb3a4b565af9215a3', 'commit_abbr': '22dd2c0', 'author': 'Artur Barseghyan', 'date': '2019-11-17 21:36:27 +0100', 'ticket_number': None, 'title': 'Readme'}}}}}
42 changes: 42 additions & 0 deletions src/matyan/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,48 @@ def test_03_generate_changelog_command_show_latest_release(self):
)
return res

@log_info
def test_04_json_changelog_command(self):
"""Test json changelog command."""
res = subprocess.check_output([
'json-changelog'
]).strip().decode()
self.assertEqual(res, self.json_output)
return res

@log_info
def test_05_json_changelog_command_show_releases(self):
"""Test json changelog command."""
res = subprocess.check_output([
'json-changelog',
'--show-releases'
]).strip().decode()
self.assertEqual(res, self.json_show_releases_output)
return res

@log_info
def test_06_json_changelog_command_show_latest_release(self):
"""Test json changelog command."""
res = subprocess.check_output([
'json-changelog',
'--show-releases',
'--latest-release'
]).strip().decode()
self.assertEqual(
res,
self.json_latest_release_show_releases_output
)
return res

@log_info
def test_07_make_config_file(self):
"""Test make config command."""
res = subprocess.check_output([
'matyan-make-config',
]).strip().decode()
self.assertEqual(res, '')
return res


if __name__ == '__main__':
unittest.main()
46 changes: 45 additions & 1 deletion src/matyan/tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import re
import logging
import unittest
Expand Down Expand Up @@ -74,7 +75,50 @@ def test_03_generate_changelog_latest_release_show_releases(self):
return res

@log_info
def test_04_merge_branch_patterns(self):
def test_04_json_changelog(self):
"""Test JSON changelog."""
res = json_changelog(
include_other=False,
path=self.test_dir
)
self.assertEqual(str(res), self.json_output)
return res

@log_info
def test_05_json_changelog_show_releases(self):
"""Test json changelog."""
res = json_changelog(
include_other=False,
show_releases=True,
path=self.test_dir
)
self.assertEqual(str(res), self.json_show_releases_output)
return res

@log_info
def test_06_json_changelog_latest_release_show_releases(self):
"""Test json changelog."""
res = json_changelog(
include_other=False,
show_releases=True,
latest_release=True,
path=self.test_dir
)
self.assertEqual(
str(res),
self.json_latest_release_show_releases_output
)
return res

@log_info
def test_07_make_config_file(self):
"""Test make config file."""
res = make_config_file()
self.assertTrue(res)
return res

@log_info
def test_08_merge_branch_patterns(self):
"""Test generate changelog."""
merge_messages = {
'Merge pull request #1234 in PROJ/repo from bugfix/PROJ-'
Expand Down
22 changes: 11 additions & 11 deletions src/matyan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,17 +600,17 @@ def validate_between(between: str = None) -> bool:
return True


def get_latest_release(path: str = None) -> str:
"""Get latest release.
Command:
git describe --match '*.*' --abbr=0
:return:
"""
repository = get_repository(path)
return repository.describe('--match', '*.*', '--abbr=0')
# def get_latest_release(path: str = None) -> str:
# """Get latest release.
#
# Command:
#
# git describe --match '*.*' --abbr=0
#
# :return:
# """
# repository = get_repository(path)
# return repository.describe('--match', '*.*', '--abbr=0')


def get_latest_releases(limit: int = 2, path: str = None) -> list:
Expand Down

0 comments on commit 42593b5

Please sign in to comment.