Skip to content

Commit 56551d8

Browse files
authored
fix bug (#13)
1 parent 3346ebe commit 56551d8

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

continuous_delivery_scripts/utils/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class StaticConfig(GenericConfig):
158158
AWS_BUCKET = "Unknown"
159159
AUTOGENERATE_NEWS_FILE_ON_DEPENDENCY_UPDATE = True
160160
DEPENDENCY_UPDATE_NEWS_MESSAGE = "Dependency upgrade: {message}"
161-
DEPENDENCY_UPDATE_NEWS_TYPE = NewsType.bugfix.name
161+
DEPENDENCY_UPDATE_NEWS_TYPE = NewsType.bugfix
162162
DEPENDENCY_UPDATE_BRANCH_PATTERN = r"^\s*[Dd]ependabot\/.+\/(?P<DEPENDENCY>.+)"
163163
ACCEPTED_THIRD_PARTY_LICENCES = ["Apache-2.0", "BSD*", "JSON", "MIT", "Python-2.0", "PSF-2.0", "MPL-2.0"]
164164
PACKAGES_WITH_CHECKED_LICENCE: List[str] = []

continuous_delivery_scripts/utils/news_file.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import enum
77
import pathlib
88
from datetime import datetime
9+
from typing import Any
910

1011

1112
class NewsType(enum.Enum):
@@ -19,9 +20,14 @@ class NewsType(enum.Enum):
1920
removal = 5
2021

2122

22-
def create_news_file(news_dir: str, news_text: str, news_type: NewsType) -> pathlib.Path:
23+
def create_news_file(news_dir: str, news_text: str, news_type: Any) -> pathlib.Path:
2324
"""Facilitates creating a news file, determining it's file name based on the type."""
24-
file_path = determine_news_file_path(news_dir, news_type)
25+
message_type = NewsType.misc
26+
if isinstance(news_type, str):
27+
message_type = NewsType[news_type]
28+
elif isinstance(news_type, NewsType):
29+
message_type = news_type
30+
file_path = determine_news_file_path(news_dir, message_type)
2531
_write_file(file_path, news_text)
2632
return file_path
2733

news/202108101200.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed news file type bug

tests/news_file/test_create_news_file.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ def test_creates_a_file_with_available_file_name_and_returns_its_path(self, _wri
3131
determine_news_file_path.assert_called_once_with(NEWS_DIR, news_type)
3232
_write_file.assert_called_once_with(file_path, news_text)
3333

34+
@mock.patch("continuous_delivery_scripts.utils.news_file.determine_news_file_path")
35+
@mock.patch("continuous_delivery_scripts.utils.news_file._write_file")
36+
def test_creates_a_file_with_message_type_string(self, _write_file, determine_news_file_path):
37+
news_file_path = pathlib.Path("some/1234501.feature")
38+
determine_news_file_path.return_value = news_file_path
39+
news_text = "Cool feature"
40+
news_type = NewsType.feature
41+
42+
file_path = create_news_file(NEWS_DIR, news_text, news_type.name)
43+
44+
self.assertEqual(file_path, news_file_path)
45+
determine_news_file_path.assert_called_once_with(NEWS_DIR, news_type)
46+
_write_file.assert_called_once_with(file_path, news_text)
47+
3448

3549
class TestDetermineNewsFilePath(TestCase):
3650
def test_finds_first_available_file_path_in_news_dir(self):

0 commit comments

Comments
 (0)