Skip to content

Commit 0129f06

Browse files
authored
Merge pull request #23 from transtats/devel
merge devel to master branch for 0.3.0 release
2 parents 666e5ee + 16175df commit 0129f06

File tree

12 files changed

+336
-97
lines changed

12 files changed

+336
-97
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ python:
55
- "3.4"
66
- "3.5"
77
- "3.6"
8+
- "3.7"
89

910
addons:
1011
apt:

Changlog.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Changelog
22
=========
33

4+
0.3.0 (2019-08-02)
5+
-----------------
6+
- Add new options exist and health to package command (pnemade)
7+
- update the man page for package command enhancement (pnemade)
8+
- Added new coverage formats in coverage command (suanand)
9+
- Changed "graph_rule" to "coverage_rule" (pnemade)
10+
- Added validation checks to check if server is responding or not (pnemade)
11+
- Updated test cases to accommodate above changes (pnemade)
12+
413
0.2.0 (2018-08-04)
514
-----------------
615
- Add partial bash-completion support for job command (pnemade)

docs/man/transtats.1

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.\" transtats - Command line interface for transtats
2-
.TH "TRANSTATS" "1" "August 2018" "transtats 0.2.0" "User Commands"
2+
.TH "TRANSTATS" "1" "August 2018-2019" "transtats 0.3.0" "User Commands"
33
.SH "NAME"
44
transtats \- Command line interface for transtats
55
.SH "SYNOPSIS"
@@ -45,16 +45,24 @@ Show this message and exit.
4545

4646
.PP
4747
\fBTo check the translation status of any partiular package for all the available release branches on transtats server.\fP
48-
transtats package anaconda
48+
transtats package abrt
49+
50+
.PP
51+
\fBTo check the if package exists on the transtats server.\fP
52+
transtats package --exist abrt
53+
54+
.PP
55+
\fBTo check the translation health of any partiular package for all the available release branches on transtats server.\fP
56+
transtats package --health abrt
4957

5058
.PP
5159
\fBTo check the translation status for available packages in any pre-defined Linux distribution release on transtats server.\fP
52-
transtats release fedora-27
60+
transtats release fedora-31
5361

5462
.PP
5563
\fBTo check the translation status for available packages in any pre-defined Linux distribution release on transtats server.\fP
5664
\fBBut if you need to know this status categorized by individual languages then use --detail\fP
57-
transtats release --detail fedora-27
65+
transtats release --detail fedora-31
5866

5967
.PP
6068
\fBTo know the version of this transtats client.\fP
@@ -69,8 +77,8 @@ Show this message and exit.
6977
These job types are syncupstream, syncdownstream, stringchange.
7078
Various job type command examples are given below
7179
transtats job run stringchange anaconda
72-
transtats job run syncdownstream anaconda --build-system koji --build-tag f29
73-
transtats job run stringchange anaconda --release-slug fedora-29
80+
transtats job run syncdownstream anaconda --build-system koji --build-tag f31
81+
transtats job run stringchange anaconda --release-slug fedora-31
7482

7583
.SH "NOTES"
7684
These commands give output in plain text format. If you need the same output

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
'Intended Audience :: Developers',
4040
'Programming Language :: Python',
4141
'Programming Language :: Python :: 2.7',
42-
'Programming Language :: Python :: 3.4',
4342
'Programming Language :: Python :: 3.5',
4443
'Programming Language :: Python :: 3.6',
44+
'Programming Language :: Python :: 3.7',
4545
],
4646
)

tests/test_data.py

Lines changed: 96 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,100 @@ def mock_package_status():
5151
return mock_rep
5252

5353

54-
def mock_rule_coverage():
54+
def mock_package_status_exist():
55+
"""
56+
package_status_exist mock value
57+
"""
58+
mock_rep = Mock()
59+
mock_rep.ok = True
60+
mock_rep.json.return_value = {
61+
"gnome-shell": True
62+
}
63+
return mock_rep
64+
65+
66+
def mock_package_status_health():
67+
"""
68+
package_status_health mock value
69+
"""
70+
mock_rep = Mock()
71+
mock_rep.ok = True
72+
mock_rep.json.return_value = {
73+
"abrt": {
74+
"fedora-30": {
75+
"Arabic": 2,
76+
"Basque": 3,
77+
"Esperanto": 7,
78+
"Friulian": 24,
79+
"Serbian": 14,
80+
"Turkish": 13,
81+
"Urdu": 3
82+
},
83+
"fedora-31": {
84+
"Friulian": 24
85+
}
86+
}
87+
}
88+
return mock_rep
89+
90+
91+
def mock_package_status_health_in_sync():
92+
"""
93+
package_status_health mock value
94+
"""
95+
mock_rep = Mock()
96+
mock_rep.ok = True
97+
mock_rep.json.return_value = {
98+
"authconfig": "Translation platform statistics are in sync with the build system."
99+
}
100+
return mock_rep
101+
102+
103+
def mock_coverage_rule():
55104
"""
56105
rule_coverage mock value
57106
"""
58107
mock_rep = Mock()
59108
mock_rep.ok = True
60109
mock_rep.json.return_value = {
61110
"coverage": {
62-
"branch": "Fedora 27",
63-
"translation_stats": {
64-
"Chinese (Simplified)": {
65-
"python-meh": 100.0,
66-
"anaconda": 98.92,
67-
"pykickstart": 100.0,
68-
"blivet": 100.0
111+
"evolution": {
112+
"translation_platform": {
113+
"German": {
114+
"Total": 5600,
115+
"Translated": 5482,
116+
"Untranslated": 102,
117+
"Remaining": 1.82
118+
},
69119
},
70-
"German": {
71-
"python-meh": 100.0,
72-
"anaconda": 99.25,
73-
"pykickstart": 93.71,
74-
"blivet": 100.0
120+
"build_system": {
121+
"f30": {
122+
"German": {
123+
"Total": 1841,
124+
"Translated": 1841,
125+
"Untranslated": 0,
126+
"Remaining": 0
127+
},
128+
}
75129
}
76130
},
77-
"graph_rule": "rhinstaller"
131+
"libuser": {
132+
"translation_platform": {
133+
"German": {
134+
"Total": 301,
135+
"Translated": 301,
136+
"Untranslated": 0,
137+
"Remaining": 0
138+
},
139+
},
140+
"build_system": {
141+
"f30": {
142+
"Statistics": "Not Synced with Build System for f30"
143+
}
144+
}
145+
},
146+
"release": "fedora-30",
147+
"coverage_rule": "rhinstaller"
78148
}
79149
}
80150
return mock_rep
@@ -175,6 +245,18 @@ def mock_release_workload_detail():
175245
return mock_rep
176246

177247

248+
def mock_package_exists():
249+
"""
250+
package_exists mock value
251+
"""
252+
mock_rep = Mock()
253+
mock_rep.ok = True
254+
mock_rep.json.return_value = {
255+
"iok": True
256+
}
257+
return mock_rep
258+
259+
178260
def mock_job_run():
179261
"""
180262
job_run mock value

tests/test_tscli.py

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def setUp(self):
3333
def tearDown(self):
3434
del os.environ["TRANSTATS_TEST_CONFIG"]
3535

36-
def test_cli_version(self):
36+
def test_version_cli(self):
3737
"""
3838
transtats version
3939
"""
@@ -60,7 +60,7 @@ def test_server_version(self):
6060

6161
def test_package_status(self):
6262
"""
63-
transtats status <package>
63+
transtats package <package>
6464
"""
6565
from tscli import entry_point
6666

@@ -74,20 +74,68 @@ def test_package_status(self):
7474
self.assertIn('Branch', result.output)
7575
self.assertIn('percentage_calculated_on', result.output)
7676

77-
def test_rule_coverage(self):
77+
def test_package_status_exist(self):
78+
"""
79+
transtats package --exist <package>
80+
"""
81+
from tscli import entry_point
82+
83+
with patch('requests.get') as mock_request_get:
84+
mock_request_get.return_value = \
85+
test_data.mock_package_status_exist()
86+
runner = CliRunner()
87+
result = runner.invoke(entry_point, ['package', '--exist',
88+
'--json', 'gnome-shell'])
89+
self.assertEqual(result.exit_code, 0)
90+
self.assertIn('gnome-shell', result.output)
91+
self.assertIn('true', result.output)
92+
93+
def test_package_status_health(self):
94+
"""
95+
transtats package --health <package>
96+
"""
97+
from tscli import entry_point
98+
99+
with patch('requests.get') as mock_request_get:
100+
mock_request_get.return_value = \
101+
test_data.mock_package_status_health()
102+
runner = CliRunner()
103+
result = runner.invoke(entry_point, ['package', '--health',
104+
'--json', 'abrt'])
105+
self.assertEqual(result.exit_code, 0)
106+
self.assertIn('abrt', result.output)
107+
self.assertIn('fedora-30', result.output)
108+
109+
def test_package_status_health_in_sync(self):
110+
"""
111+
transtats package --health <package>
112+
"""
113+
from tscli import entry_point
114+
115+
with patch('requests.get') as mock_request_get:
116+
mock_request_get.return_value = \
117+
test_data.mock_package_status_health_in_sync()
118+
runner = CliRunner()
119+
result = runner.invoke(entry_point, ['package', '--health',
120+
'--json', 'authconfig'])
121+
self.assertEqual(result.exit_code, 0)
122+
self.assertIn('authconfig', result.output)
123+
self.assertIn('are in sync', result.output)
124+
125+
def test_coverage_rule(self):
78126
"""
79127
transtats coverage <graph_rule>
80128
"""
81129
from tscli import entry_point
82130

83131
with patch('requests.get') as mock_request_get:
84132
mock_request_get.return_value = \
85-
test_data.mock_rule_coverage()
133+
test_data.mock_coverage_rule()
86134
runner = CliRunner()
87135
result = runner.invoke(entry_point, ['coverage', 'rhinstaller'])
88136
self.assertEqual(result.exit_code, 0)
89-
self.assertIn('Branch', result.output)
90-
self.assertIn('Graph Rule', result.output)
137+
self.assertIn('Branch : fedora-30', result.output)
138+
self.assertIn('Coverage Rule : rhinstaller', result.output)
91139

92140
def test_release_status(self):
93141
"""
@@ -161,17 +209,19 @@ def test_job_run(self):
161209
"""
162210
from tscli import entry_point
163211

164-
with patch('requests.post') as mock_request_get:
165-
mock_request_get.return_value = \
166-
test_data.mock_job_run()
167-
runner = CliRunner()
168-
result = runner.invoke(entry_point,
169-
['job', 'run', 'stringchange', 'iok',
170-
'--release-slug', 'fedora-29'])
171-
172-
self.assertEqual(result.exit_code, 0)
173-
self.assertIn('Success', result.output)
174-
self.assertIn('Job_Id', result.output)
212+
with patch('requests.get') as mock_request_get:
213+
with patch('requests.post') as mock_request_post:
214+
mock_request_get.return_value = \
215+
test_data.mock_package_exists()
216+
mock_request_post.return_value = \
217+
test_data.mock_job_run()
218+
runner = CliRunner()
219+
result = runner.invoke(entry_point,
220+
['job', 'run', 'stringchange', 'iok',
221+
'--release-slug', 'fedora-29'])
222+
self.assertEqual(result.exit_code, 0)
223+
self.assertIn('Success', result.output)
224+
self.assertIn('Job_Id', result.output)
175225

176226
def test_job_log(self):
177227
"""

tscli/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017 Red Hat, Inc.
1+
# Copyright 2017-2019 Red Hat, Inc.
22
# All Rights Reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -21,7 +21,7 @@
2121
from tscli.stats import commands as trans
2222
from tscli.jobs import commands as jobs
2323

24-
APP_VERSION = "0.2.0"
24+
APP_VERSION = "0.3.0"
2525

2626

2727
class AppContext(object):

tscli/common/commands.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ def version(app_context, server_url, server, json):
3131
if json:
3232
version_dict = {"client": "Transtats client %s" % app_context.version}
3333
if server:
34-
response = ConsumeAPIs(server_url or
35-
app_context.server_url).server_version
34+
response = ConsumeAPIs(server_url or app_context.server_url).server_version
3635
if isinstance(response, dict):
3736
version_dict.update(response)
3837
app_context.print_r(version_dict)

tscli/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def get_config_item(config, section, item):
5757
"""
5858
try:
5959
return config.get(section, item)
60-
except (configparser.NoOptionError, configparser.NoSectionError):
61-
error_msg = ('The item "{0}" is not set in the "{1}" section '
60+
except (configparser.NoOptionError, configparser.NoSectionError, configparser.InterpolationSyntaxError):
61+
error_msg = ('The item "{0}" is not set correctly in the "{1}" section '
6262
'in your config file.'.format(item, section))
6363
raise click.ClickException(error_msg)

0 commit comments

Comments
 (0)