Merge lp:~pete-woods/click-reviewers-tools/wrong-scope-ini-path into lp:click-reviewers-tools

Proposed by Pete Woods
Status: Merged
Merged at revision: 219
Proposed branch: lp:~pete-woods/click-reviewers-tools/wrong-scope-ini-path
Merge into: lp:click-reviewers-tools
Diff against target: 146 lines (+34/-33)
2 files modified
clickreviews/cr_scope.py (+20/-11)
clickreviews/tests/test_cr_scope.py (+14/-22)
To merge this branch: bzr merge lp:~pete-woods/click-reviewers-tools/wrong-scope-ini-path
Reviewer Review Type Date Requested Status
Jamie Strandboge (community) Approve
Daniel Holbach Pending
Canonical Store Reviewers Pending
Review via email: mp+228894@code.launchpad.net

Commit message

Change scope reviewing rules to match current ini file path and format

Description of the change

Change scope reviewing rules to match current ini file path and format

See specification at http://bazaar.launchpad.net/~unity-team/unity-scopes-api/trunk/view/head:/CONFIGFILES

To post a comment you must log in.
219. By Pete Woods

Match scope review with actual ini file specifications

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

ACK, thanks! It might be nice to add some checks for the various fields along with tests, but that is a future enhancement.

review: Approve
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Oh, I forgot to mention, there were whitespace pep8 issues as reported by ./run-pep8. I fixed those.

Revision history for this message
Pete Woods (pete-woods) wrote :

Yeah. I was tempted to do that. But ideally want to get this released soon so that scopes can start flowing into the store.

We should also add validation for the Appearance section properties.

Revision history for this message
Pete Woods (pete-woods) wrote :

Thanks for the whitespace fixes :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'clickreviews/cr_scope.py'
2--- clickreviews/cr_scope.py 2014-07-16 17:47:07 +0000
3+++ clickreviews/cr_scope.py 2014-07-30 16:44:52 +0000
4@@ -21,6 +21,8 @@
5 import os
6
7
8+KNOWN_SECTIONS = set(["ScopeConfig", "Appearance"])
9+
10 class ClickReviewScope(ClickReview):
11 '''This class represents click lint reviews'''
12 def __init__(self, fn):
13@@ -48,7 +50,7 @@
14 elif not os.path.isdir(fn):
15 error("'%s' is not a directory" % bn)
16
17- ini_fn = os.path.join(fn, "%s.ini" % self.manifest['name'])
18+ ini_fn = os.path.join(fn, "%s_%s.ini" % (self.manifest['name'], app))
19 ini_fn_bn = os.path.relpath(ini_fn, self.unpack_dir)
20 if not os.path.exists(ini_fn):
21 error("Could not find scope INI file '%s'" % ini_fn_bn)
22@@ -72,13 +74,15 @@
23 n = 'ini_%s_scope_section' % app
24 s = "OK"
25
26- if len(self.scopes[app]["scope_config"].sections()) > 1:
27+ sections = set(self.scopes[app]["scope_config"].sections())
28+ unknown_sections = sections.difference(KNOWN_SECTIONS)
29+
30+ if unknown_sections:
31 t = 'error'
32- s = "'%s' has too many sections: %s" % (
33+ s = "'%s' has unknown sections: %s" % (
34 self.scopes[app]["ini_file_rel"],
35- ", ".join(self.scopes[app]["scope_config"].sections()))
36- elif "ScopeConfig" not in \
37- self.scopes[app]["scope_config"].sections():
38+ ", ".join(unknown_sections))
39+ elif "ScopeConfig" not in sections:
40 t = 'error'
41 s = "Could not find 'ScopeConfig' in '%s'" % (
42 self.scopes[app]["ini_file_rel"])
43@@ -87,13 +91,18 @@
44 self._add_result(t, n, s)
45
46 # Make these all lower case for easier comparisons
47- required = ['scoperunner',
48- 'displayname',
49+ required = ['author',
50+ 'description',
51+ 'displayname']
52+ optional = ['art',
53+ 'hotkey',
54 'icon',
55+ 'idletimeout',
56+ 'invisible',
57+ 'locationdataneeded',
58+ 'resultsttltype',
59+ 'scoperunner',
60 'searchhint']
61- optional = ['description',
62- 'author',
63- 'art']
64
65 missing = []
66 t = 'info'
67
68=== modified file 'clickreviews/tests/test_cr_scope.py'
69--- clickreviews/tests/test_cr_scope.py 2014-07-15 18:35:09 +0000
70+++ clickreviews/tests/test_cr_scope.py 2014-07-30 16:44:52 +0000
71@@ -31,8 +31,9 @@
72 '''Create a scope to pass to tests'''
73 scope = dict()
74 scope["dir_rel"] = "scope-directory"
75- scope["ini_file_rel"] = "%s/%s.ini" % (scope["dir_rel"],
76- self.default_appname)
77+ scope["ini_file_rel"] = "%s/%s_%s.ini" % (scope["dir_rel"],
78+ self.default_appname,
79+ 'foo')
80 scope["scope_config"] = configparser.ConfigParser()
81 scope["scope_config"]['ScopeConfig'] = config_dict
82
83@@ -48,6 +49,11 @@
84 'Art': '',
85 'Icon': 'foo.svg',
86 'SearchHint': 'Search Foo',
87+ 'HotKey': 'h',
88+ 'IdleTimeout': '1234',
89+ 'Invisible': 'false',
90+ 'LocationDataNeeded': 'false',
91+ 'ResultsTtlType': 'small',
92 }
93
94 return config_dict
95@@ -64,9 +70,9 @@
96 self.check_results(r, expected_counts)
97
98 def test_check_scope_ini_missing_required1(self):
99- '''Test check_scope_ini() - missing ScopeRunner'''
100+ '''Test check_scope_ini() - missing Description'''
101 config = self._stub_config()
102- del config['ScopeRunner']
103+ del config['Description']
104 scope = self._create_scope(config)
105
106 self.set_test_scope(self.default_appname, scope)
107@@ -90,9 +96,9 @@
108 self.check_results(r, expected_counts)
109
110 def test_check_scope_ini_missing_required3(self):
111- '''Test check_scope_ini() - missing Icon'''
112+ '''Test check_scope_ini() - missing Author'''
113 config = self._stub_config()
114- del config['Icon']
115+ del config['Author']
116 scope = self._create_scope(config)
117
118 self.set_test_scope(self.default_appname, scope)
119@@ -103,25 +109,11 @@
120 self.check_results(r, expected_counts)
121
122 def test_check_scope_ini_missing_required4(self):
123- '''Test check_scope_ini() - missing SearchHint'''
124- config = self._stub_config()
125- del config['SearchHint']
126- scope = self._create_scope(config)
127-
128- self.set_test_scope(self.default_appname, scope)
129- c = ClickReviewScope(self.test_name)
130- c.check_scope_ini()
131- r = c.click_report
132- expected_counts = {'info': None, 'warn': 0, 'error': 1}
133- self.check_results(r, expected_counts)
134-
135- def test_check_scope_ini_missing_required5(self):
136 '''Test check_scope_ini() - missing multiple'''
137 config = self._stub_config()
138- del config['ScopeRunner']
139+ del config['Description']
140 del config['DisplayName']
141- del config['Icon']
142- del config['SearchHint']
143+ del config['Author']
144 scope = self._create_scope(config)
145
146 self.set_test_scope(self.default_appname, scope)

Subscribers

People subscribed via source and target branches