Skip to content

Commit d6f587c

Browse files
authored
refactor: rename settings to config (#42)
1 parent 94066c9 commit d6f587c

File tree

5 files changed

+33
-32
lines changed

5 files changed

+33
-32
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ env.bak/
132132
venv.bak/
133133
.vscode
134134

135-
# Spyder project settings
135+
# Spyder project config
136136
.spyderproject
137137
.spyproject
138138

139-
# Rope project settings
139+
# Rope project config
140140
.ropeproject
141141

142142
# mkdocs documentation
File renamed without changes.

codecov/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import os
33

44
from codecov import diff_grouper, groups, template
5+
from codecov.config import Config
56
from codecov.coverage import PytestCoverage
67
from codecov.coverage.base import Coverage, DiffCoverage
78
from codecov.exceptions import CoreProcessingException, MissingMarker, TemplateException
89
from codecov.github import Github
910
from codecov.github_client import GitHubClient
1011
from codecov.log import log, setup as log_setup
11-
from codecov.settings import Config
1212

1313

1414
class Main:

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
import httpx
1414
import pytest
1515

16+
from codecov.config import Config
1617
from codecov.coverage import Coverage, CoverageInfo, CoverageMetadata, DiffCoverage, FileCoverage, PytestCoverage
1718
from codecov.github_client import GitHubClient
18-
from codecov.settings import Config
1919

2020

2121
@pytest.fixture

tests/test_settings.py renamed to tests/test_config.py

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,44 @@
77

88
import pytest
99

10-
from codecov import settings
10+
from codecov import config
11+
from codecov.exceptions import InvalidAnnotationType, MissingEnvironmentVariable
1112

1213

1314
def test_path_below_existing_file():
1415
with tempfile.NamedTemporaryFile(suffix='.json') as temp_file:
1516
path = pathlib.Path(temp_file.name)
16-
assert settings.path_below(path) == path.resolve()
17+
assert config.path_below(path) == path.resolve()
1718

1819

1920
def test_path_below_nonexistent_file():
2021
path = pathlib.Path('/path/to/nonexistent_file.json')
2122
with pytest.raises(ValueError):
22-
settings.path_below(path)
23+
config.path_below(path)
2324

2425

2526
def test_path_below_directory():
2627
path = pathlib.Path('/path/to/directory')
2728
with pytest.raises(ValueError):
28-
settings.path_below(path)
29+
config.path_below(path)
2930

3031

3132
def test_path_below_non_json_file():
3233
with tempfile.NamedTemporaryFile(suffix='.txt') as temp_file:
3334
path = pathlib.Path(temp_file.name)
3435
with pytest.raises(ValueError):
35-
settings.path_below(path)
36+
config.path_below(path)
3637

3738

3839
def test_config_from_environ_missing():
39-
with pytest.raises(settings.MissingEnvironmentVariable):
40-
settings.Config.from_environ({})
40+
with pytest.raises(MissingEnvironmentVariable):
41+
config.Config.from_environ({})
4142

4243

4344
def test_config__from_environ__sample():
4445
token = secrets.token_urlsafe()
4546
with tempfile.NamedTemporaryFile(suffix='.json') as temp_file:
46-
assert settings.Config.from_environ(
47+
assert config.Config.from_environ(
4748
{
4849
'GITHUB_REPOSITORY': 'your_repository',
4950
'COVERAGE_PATH': temp_file.name,
@@ -63,7 +64,7 @@ def test_config__from_environ__sample():
6364
'COVERAGE_REPORT_URL': 'https://your_coverage_report_url',
6465
'DEBUG': 'False',
6566
}
66-
) == settings.Config(
67+
) == config.Config(
6768
GITHUB_REPOSITORY='your_repository',
6869
COVERAGE_PATH=pathlib.Path(temp_file.name).resolve(),
6970
GITHUB_TOKEN=token, # noqa: S106
@@ -87,7 +88,7 @@ def test_config__from_environ__sample():
8788
def test_config_required_pr_or_ref():
8889
with tempfile.NamedTemporaryFile(suffix='.json') as temp_file:
8990
with pytest.raises(ValueError):
90-
settings.Config.from_environ(
91+
config.Config.from_environ(
9192
{
9293
'GITHUB_TOKEN': 'your_token',
9394
'GITHUB_REPOSITORY': 'your_repository',
@@ -97,8 +98,8 @@ def test_config_required_pr_or_ref():
9798

9899

99100
def test_config_invalid_annotation_type():
100-
with pytest.raises(settings.InvalidAnnotationType):
101-
settings.Config.from_environ({'ANNOTATION_TYPE': 'foo'})
101+
with pytest.raises(InvalidAnnotationType):
102+
config.Config.from_environ({'ANNOTATION_TYPE': 'foo'})
102103

103104

104105
@pytest.mark.parametrize(
@@ -116,78 +117,78 @@ def test_config_invalid_annotation_type():
116117
],
117118
)
118119
def test_str_to_bool(input_data, output_data):
119-
assert settings.str_to_bool(input_data) is output_data
120+
assert config.str_to_bool(input_data) is output_data
120121

121122

122123
def test_config_clean_minimum_green():
123-
value = settings.Config.clean_minimum_green('90')
124+
value = config.Config.clean_minimum_green('90')
124125
assert value == decimal.Decimal('90')
125126

126127

127128
def test_config_clean_minimum_orange():
128-
value = settings.Config.clean_minimum_orange('70')
129+
value = config.Config.clean_minimum_orange('70')
129130
assert value == decimal.Decimal('70')
130131

131132

132133
def test_config_clean_annotate_missing_lines():
133-
value = settings.Config.clean_annotate_missing_lines('True')
134+
value = config.Config.clean_annotate_missing_lines('True')
134135
assert value is True
135136

136137

137138
def test_config_clean_skip_coverage():
138-
value = settings.Config.clean_skip_coverage('False')
139+
value = config.Config.clean_skip_coverage('False')
139140
assert value is False
140141

141142

142143
def test_config_clean_branch_coverage():
143-
value = settings.Config.clean_branch_coverage('False')
144+
value = config.Config.clean_branch_coverage('False')
144145
assert value is False
145146

146147

147148
def test_config_clean_complete_project_report():
148-
value = settings.Config.clean_complete_project_report('True')
149+
value = config.Config.clean_complete_project_report('True')
149150
assert value is True
150151

151152

152153
def test_config_clean_debug():
153-
value = settings.Config.clean_debug('False')
154+
value = config.Config.clean_debug('False')
154155
assert value is False
155156

156157

157158
def test_config_clean_annotation_type():
158-
value = settings.Config.clean_annotation_type('warning')
159+
value = config.Config.clean_annotation_type('warning')
159160
assert value == 'warning'
160161

161162

162163
def test_config_clean_annotation_type_invalid():
163-
with pytest.raises(settings.InvalidAnnotationType):
164-
settings.Config.clean_annotation_type('foo')
164+
with pytest.raises(InvalidAnnotationType):
165+
config.Config.clean_annotation_type('foo')
165166

166167

167168
def test_config_clean_github_pr_number():
168-
value = settings.Config.clean_github_pr_number('123')
169+
value = config.Config.clean_github_pr_number('123')
169170
assert value == 123
170171

171172

172173
def test_config_clean_coverage_path():
173174
with tempfile.NamedTemporaryFile(suffix='.json') as temp_file:
174-
value = settings.Config.clean_coverage_path(temp_file.name)
175+
value = config.Config.clean_coverage_path(temp_file.name)
175176
assert value == pathlib.Path(temp_file.name).resolve()
176177

177178

178179
def test_config_clean_annotations_output_path():
179-
value = settings.Config.clean_annotations_output_path('/path/to/annotations')
180+
value = config.Config.clean_annotations_output_path('/path/to/annotations')
180181
assert value == pathlib.Path('/path/to/annotations')
181182

182183

183184
def test_str_to_bool_invalid():
184-
assert settings.str_to_bool('invalid') is False
185+
assert config.str_to_bool('invalid') is False
185186

186187

187188
def test_config_required_clean_env_var_error():
188189
with tempfile.NamedTemporaryFile(suffix='.json') as temp_file:
189190
with pytest.raises(ValueError):
190-
settings.Config.from_environ(
191+
config.Config.from_environ(
191192
{
192193
'GITHUB_TOKEN': 'your_token',
193194
'GITHUB_REPOSITORY': 'your_repository',

0 commit comments

Comments
 (0)