Merge lp:~marcustomlinson/unity-scopes-api/metadata_author_attr into lp:unity-scopes-api/devel

Proposed by Marcus Tomlinson
Status: Superseded
Proposed branch: lp:~marcustomlinson/unity-scopes-api/metadata_author_attr
Merge into: lp:unity-scopes-api/devel
Diff against target: 448 lines (+87/-5)
15 files modified
include/unity/scopes/ScopeMetadata.h (+1/-0)
include/unity/scopes/internal/ScopeConfig.h (+2/-0)
include/unity/scopes/internal/ScopeMetadataImpl.h (+3/-0)
include/unity/scopes/internal/smartscopes/SmartScopesClient.h (+1/-0)
scoperegistry/scoperegistry.cpp (+1/-0)
src/scopes/ScopeMetadata.cpp (+5/-0)
src/scopes/internal/ScopeConfig.cpp (+7/-0)
src/scopes/internal/ScopeMetadataImpl.cpp (+18/-1)
src/scopes/internal/smartscopes/SSRegistryObject.cpp (+1/-0)
src/scopes/internal/smartscopes/SmartScopesClient.cpp (+3/-1)
test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp (+38/-1)
test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py (+2/-2)
test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp (+2/-0)
test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp (+2/-0)
test/gtest/scopes/internal/zmq_middleware/RegistryI/RegistryI_test.cpp (+1/-0)
To merge this branch: bzr merge lp:~marcustomlinson/unity-scopes-api/metadata_author_attr
Reviewer Review Type Date Requested Status
Michi Henning (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Paweł Stołowski Pending
Review via email: mp+208553@code.launchpad.net

Commit message

Added "author" to scope metadata and config.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michi Henning (michihenning) wrote :

Looking good, thanks!

review: Approve
233. By Marcus Tomlinson

Merged more-doc-fixes and resolved conflicts

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/unity/scopes/ScopeMetadata.h'
2--- include/unity/scopes/ScopeMetadata.h 2014-02-25 08:25:31 +0000
3+++ include/unity/scopes/ScopeMetadata.h 2014-02-27 08:59:35 +0000
4@@ -55,6 +55,7 @@
5 ScopeProxy proxy() const;
6 std::string display_name() const; // localized
7 std::string description() const; // localized
8+ std::string author() const;
9 std::string art() const; // optional
10 std::string icon() const; // optional
11 std::string search_hint() const; // localized, optional
12
13=== modified file 'include/unity/scopes/internal/ScopeConfig.h'
14--- include/unity/scopes/internal/ScopeConfig.h 2014-02-20 19:19:25 +0000
15+++ include/unity/scopes/internal/ScopeConfig.h 2014-02-27 08:59:35 +0000
16@@ -41,6 +41,7 @@
17 bool overrideable() const; // Optional, returns false if not present
18 std::string display_name() const;
19 std::string description() const;
20+ std::string author() const;
21 std::string art() const; // Optional, throws NotFoundException if not present
22 std::string icon() const; // Optional, throws NotFoundException if not present
23 std::string search_hint() const; // Optional, throws NotFoundException if not present
24@@ -51,6 +52,7 @@
25 bool overrideable_;
26 std::string display_name_;
27 std::string description_;
28+ std::string author_;
29 std::unique_ptr<std::string> art_;
30 std::unique_ptr<std::string> icon_;
31 std::unique_ptr<std::string> search_hint_;
32
33=== modified file 'include/unity/scopes/internal/ScopeMetadataImpl.h'
34--- include/unity/scopes/internal/ScopeMetadataImpl.h 2014-02-10 06:26:09 +0000
35+++ include/unity/scopes/internal/ScopeMetadataImpl.h 2014-02-27 08:59:35 +0000
36@@ -47,6 +47,7 @@
37 ScopeProxy proxy() const;
38 std::string display_name() const; // localized
39 std::string description() const; // localized
40+ std::string author() const;
41 std::string art() const; // optional
42 std::string icon() const; // optional
43 std::string search_hint() const; // localized, optional
44@@ -57,6 +58,7 @@
45 void set_proxy(ScopeProxy const& proxy);
46 void set_display_name(std::string const& display_name);
47 void set_description(std::string const& description);
48+ void set_author(std::string const& author);
49 void set_art(std::string const& art);
50 void set_icon(std::string const& icon);
51 void set_search_hint(std::string const& search_hint);
52@@ -75,6 +77,7 @@
53 ScopeProxy proxy_;
54 std::string display_name_;
55 std::string description_;
56+ std::string author_;
57 std::unique_ptr<std::string> art_; // Optional, hence a pointer
58 std::unique_ptr<std::string> icon_; // Optional, hence a pointer
59 std::unique_ptr<std::string> search_hint_; // Optional, hence a pointer
60
61=== modified file 'include/unity/scopes/internal/smartscopes/SmartScopesClient.h'
62--- include/unity/scopes/internal/smartscopes/SmartScopesClient.h 2014-02-25 12:44:30 +0000
63+++ include/unity/scopes/internal/smartscopes/SmartScopesClient.h 2014-02-27 08:59:35 +0000
64@@ -50,6 +50,7 @@
65 std::string id;
66 std::string name;
67 std::string description;
68+ std::string author;
69 std::string base_url;
70 std::shared_ptr<std::string> icon; // optional
71 std::shared_ptr<std::string> art; // optional
72
73=== modified file 'scoperegistry/scoperegistry.cpp'
74--- scoperegistry/scoperegistry.cpp 2014-02-20 19:19:25 +0000
75+++ scoperegistry/scoperegistry.cpp 2014-02-27 08:59:35 +0000
76@@ -158,6 +158,7 @@
77 mi->set_scope_name(pair.first);
78 mi->set_display_name(sc.display_name());
79 mi->set_description(sc.description());
80+ mi->set_author(sc.author());
81 mi->set_invisible(sc.invisible());
82 try
83 {
84
85=== modified file 'src/scopes/ScopeMetadata.cpp'
86--- src/scopes/ScopeMetadata.cpp 2014-02-10 06:26:09 +0000
87+++ src/scopes/ScopeMetadata.cpp 2014-02-27 08:59:35 +0000
88@@ -86,6 +86,11 @@
89 return p->description();
90 }
91
92+string ScopeMetadata::author() const
93+{
94+ return p->author();
95+}
96+
97 string ScopeMetadata::art() const
98 {
99 return p->art();
100
101=== modified file 'src/scopes/internal/ScopeConfig.cpp'
102--- src/scopes/internal/ScopeConfig.cpp 2014-02-20 19:19:25 +0000
103+++ src/scopes/internal/ScopeConfig.cpp 2014-02-27 08:59:35 +0000
104@@ -40,6 +40,7 @@
105 const string overrideable_str = "Override";
106 const string scope_name_str = "DisplayName";
107 const string description_str = "Description";
108+ const string author_str = "Author";
109 const string art_str = "Art";
110 const string icon_str = "Icon";
111 const string search_hint_str = "SearchHint";
112@@ -60,6 +61,7 @@
113 }
114 display_name_ = parser()->get_string(SCOPE_CONFIG_GROUP, scope_name_str);
115 description_ = parser()->get_string(SCOPE_CONFIG_GROUP, description_str);
116+ author_ = parser()->get_string(SCOPE_CONFIG_GROUP, author_str);
117
118 // For optional values, we store them in a unique_ptr so we can distinguish the "not set at all" case
119 // from the "explicitly set to empty string" case. parser()->get_string throws LogicException if
120@@ -126,6 +128,11 @@
121 return description_;
122 }
123
124+string ScopeConfig::author() const
125+{
126+ return author_;
127+}
128+
129 string ScopeConfig::art() const
130 {
131 if (!art_)
132
133=== modified file 'src/scopes/internal/ScopeMetadataImpl.cpp'
134--- src/scopes/internal/ScopeMetadataImpl.cpp 2014-02-26 07:24:00 +0000
135+++ src/scopes/internal/ScopeMetadataImpl.cpp 2014-02-27 08:59:35 +0000
136@@ -51,7 +51,8 @@
137 scope_name_(other.scope_name_),
138 proxy_(other.proxy_),
139 display_name_(other.display_name_),
140- description_(other.description_)
141+ description_(other.description_),
142+ author_(other.author_)
143 {
144 if (other.art_)
145 {
146@@ -84,6 +85,7 @@
147 proxy_ = rhs.proxy_;
148 display_name_ = rhs.display_name_;
149 description_ = rhs.description_;
150+ author_ = rhs.author_;
151 art_.reset(rhs.art_ ? new string(*rhs.art_) : nullptr);
152 icon_.reset(rhs.icon_ ? new string(*rhs.icon_) : nullptr);
153 search_hint_.reset(rhs.search_hint_ ? new string(*rhs.search_hint_) : nullptr);
154@@ -113,6 +115,11 @@
155 return description_;
156 }
157
158+std::string ScopeMetadataImpl::author() const
159+{
160+ return author_;
161+}
162+
163 std::string ScopeMetadataImpl::art() const
164 {
165 if (art_)
166@@ -178,6 +185,11 @@
167 description_ = description;
168 }
169
170+void ScopeMetadataImpl::set_author(std::string const& author)
171+{
172+ author_ = author;
173+}
174+
175 void ScopeMetadataImpl::set_art(std::string const& art)
176 {
177 art_.reset(new string(art));
178@@ -225,6 +237,7 @@
179 }
180 throw_on_empty("display_name", display_name_);
181 throw_on_empty("description", description_);
182+ throw_on_empty("author", author_);
183
184 VariantMap var;
185 var["scope_name"] = scope_name_;
186@@ -234,6 +247,7 @@
187 var["proxy"] = proxy;
188 var["display_name"] = display_name_;
189 var["description"] = description_;
190+ var["author"] = author_;
191
192 // Optional fields
193 if (art_)
194@@ -306,6 +320,9 @@
195 it = find_or_throw(var, "description");
196 description_ = it->second.get_string();
197
198+ it = find_or_throw(var, "author");
199+ author_ = it->second.get_string();
200+
201 // Optional fields
202
203 it = var.find("art");
204
205=== modified file 'src/scopes/internal/smartscopes/SSRegistryObject.cpp'
206--- src/scopes/internal/smartscopes/SSRegistryObject.cpp 2014-02-26 16:23:32 +0000
207+++ src/scopes/internal/smartscopes/SSRegistryObject.cpp 2014-02-27 08:59:35 +0000
208@@ -210,6 +210,7 @@
209 metadata->set_scope_name(scope.id);
210 metadata->set_display_name(scope.name);
211 metadata->set_description(scope.description);
212+ metadata->set_author(scope.author);
213
214 if (scope.icon)
215 {
216
217=== modified file 'src/scopes/internal/smartscopes/SmartScopesClient.cpp'
218--- src/scopes/internal/smartscopes/SmartScopesClient.cpp 2014-02-25 12:44:30 +0000
219+++ src/scopes/internal/smartscopes/SmartScopesClient.cpp 2014-02-27 08:59:35 +0000
220@@ -197,7 +197,8 @@
221 RemoteScope scope;
222
223 if (!child_node->has_node("id") || !child_node->has_node("name") ||
224- !child_node->has_node("base_url") || !child_node->has_node("description"))
225+ !child_node->has_node("description") || !child_node->has_node("author") ||
226+ !child_node->has_node("base_url"))
227 {
228 break;
229 }
230@@ -205,6 +206,7 @@
231 scope.id = child_node->get_node("id")->as_string();
232 scope.name = child_node->get_node("name")->as_string();
233 scope.description = child_node->get_node("description")->as_string();
234+ scope.author = child_node->get_node("author")->as_string();
235 scope.base_url = child_node->get_node("base_url")->as_string();
236
237 if (child_node->has_node("icon"))
238
239=== modified file 'test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp'
240--- test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp 2014-02-25 12:08:41 +0000
241+++ test/gtest/scopes/internal/ScopeMetadataImpl/ScopeMetadataImpl_test.cpp 2014-02-27 08:59:35 +0000
242@@ -44,6 +44,7 @@
243 mi->set_proxy(ScopeImpl::create(mw_proxy, mw.runtime(), "scope_name"));
244 mi->set_display_name("display_name");
245 mi->set_description("description");
246+ mi->set_author("author");
247
248 // Keep a copy for tests below
249 unique_ptr<ScopeMetadataImpl> mi2(new ScopeMetadataImpl(*mi));
250@@ -55,6 +56,7 @@
251 EXPECT_EQ("endpoint", m.proxy()->endpoint());
252 EXPECT_EQ("display_name", m.display_name());
253 EXPECT_EQ("description", m.description());
254+ EXPECT_EQ("author", m.author());
255
256 // Check that optional fields that are not set throw
257 try
258@@ -106,6 +108,7 @@
259 EXPECT_EQ("endpoint", mi2->proxy()->endpoint());
260 EXPECT_EQ("display_name", mi2->display_name());
261 EXPECT_EQ("description", mi2->description());
262+ EXPECT_EQ("author", mi2->author());
263
264 // Set optional fields on copy.
265 mi2->set_art("art");
266@@ -130,6 +133,7 @@
267 ti->set_proxy(ScopeImpl::create(mw_proxy, mw.runtime(), "tmp scope_name"));
268 ti->set_display_name("tmp display_name");
269 ti->set_description("tmp description");
270+ ti->set_author("tmp author");
271 ti->set_art("tmp art");
272 ti->set_icon("tmp icon");
273 ti->set_search_hint("tmp search_hint");
274@@ -144,6 +148,7 @@
275 EXPECT_EQ("tmp endpoint", ci.proxy()->endpoint());
276 EXPECT_EQ("tmp display_name", ci.display_name());
277 EXPECT_EQ("tmp description", ci.description());
278+ EXPECT_EQ("tmp author", ci.author());
279 EXPECT_EQ("tmp art", ci.art());
280 EXPECT_EQ("tmp icon", ci.icon());
281 EXPECT_EQ("tmp search_hint", ci.search_hint());
282@@ -158,6 +163,7 @@
283 EXPECT_EQ("tmp endpoint", m.proxy()->endpoint());
284 EXPECT_EQ("tmp display_name", m.display_name());
285 EXPECT_EQ("tmp description", m.description());
286+ EXPECT_EQ("tmp author", m.author());
287 EXPECT_EQ("tmp art", m.art());
288 EXPECT_EQ("tmp icon", m.icon());
289 EXPECT_EQ("tmp search_hint", m.search_hint());
290@@ -171,6 +177,7 @@
291 EXPECT_EQ("tmp endpoint", tmp.proxy()->endpoint());
292 EXPECT_EQ("tmp display_name", tmp.display_name());
293 EXPECT_EQ("tmp description", tmp.description());
294+ EXPECT_EQ("tmp author", tmp.author());
295 EXPECT_EQ("tmp art", tmp.art());
296 EXPECT_EQ("tmp icon", tmp.icon());
297 EXPECT_EQ("tmp search_hint", tmp.search_hint());
298@@ -184,6 +191,7 @@
299 EXPECT_EQ("tmp endpoint", tmp2.proxy()->endpoint());
300 EXPECT_EQ("tmp display_name", tmp2.display_name());
301 EXPECT_EQ("tmp description", tmp2.description());
302+ EXPECT_EQ("tmp author", tmp2.author());
303 EXPECT_EQ("tmp art", tmp2.art());
304 EXPECT_EQ("tmp icon", tmp2.icon());
305 EXPECT_EQ("tmp search_hint", tmp2.search_hint());
306@@ -202,6 +210,7 @@
307 mi->set_proxy(ScopeImpl::create(mw_proxy, mw.runtime(), "scope_name"));
308 mi->set_display_name("display_name");
309 mi->set_description("description");
310+ mi->set_author("author");
311 mi->set_art("art");
312 mi->set_icon("icon");
313 mi->set_search_hint("search_hint");
314@@ -211,10 +220,11 @@
315 // Check that serialize() sets the map values correctly
316 auto m = ScopeMetadataImpl::create(move(mi));
317 auto var = m.serialize();
318- EXPECT_EQ(9u, var.size());
319+ EXPECT_EQ(10u, var.size());
320 EXPECT_EQ("scope_name", var["scope_name"].get_string());
321 EXPECT_EQ("display_name", var["display_name"].get_string());
322 EXPECT_EQ("description", var["description"].get_string());
323+ EXPECT_EQ("author", var["author"].get_string());
324 EXPECT_EQ("art", var["art"].get_string());
325 EXPECT_EQ("icon", var["icon"].get_string());
326 EXPECT_EQ("search_hint", var["search_hint"].get_string());
327@@ -228,6 +238,7 @@
328 EXPECT_EQ("endpoint", c.proxy()->endpoint());
329 EXPECT_EQ("display_name", c.display_name());
330 EXPECT_EQ("description", c.description());
331+ EXPECT_EQ("author", c.author());
332 EXPECT_EQ("art", c.art());
333 EXPECT_EQ("icon", c.icon());
334 EXPECT_EQ("search_hint", c.search_hint());
335@@ -288,6 +299,18 @@
336 EXPECT_STREQ("unity::InvalidArgumentException: ScopeMetadata: required attribute 'description' is empty",
337 e.what());
338 }
339+
340+ try
341+ {
342+ mi.set_description("description");
343+ mi.serialize();
344+ FAIL();
345+ }
346+ catch (InvalidArgumentException const&e)
347+ {
348+ EXPECT_STREQ("unity::InvalidArgumentException: ScopeMetadata: required attribute 'author' is empty",
349+ e.what());
350+ }
351 }
352
353 TEST(ScopeMetadataImpl, deserialize_exceptions)
354@@ -380,6 +403,19 @@
355 e.what());
356 }
357 m["description"] = "description";
358+ try
359+ {
360+ ScopeMetadataImpl mi(m, &mw);
361+ mi.deserialize(m);
362+ FAIL();
363+ }
364+ catch (InvalidArgumentException const&e)
365+ {
366+ EXPECT_STREQ("unity::InvalidArgumentException: ScopeMetadata::deserialize(): required attribute "
367+ "'author' is missing",
368+ e.what());
369+ }
370+ m["author"] = "author";
371
372 // Optional attributes
373 m["art"] = "art";
374@@ -394,6 +430,7 @@
375 EXPECT_EQ("endpoint", mi.proxy()->endpoint());
376 EXPECT_EQ("display_name", mi.display_name());
377 EXPECT_EQ("description", mi.description());
378+ EXPECT_EQ("author", mi.author());
379 EXPECT_EQ("art", mi.art());
380 EXPECT_EQ("icon", mi.icon());
381 EXPECT_EQ("search_hint", mi.search_hint());
382
383=== modified file 'test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py'
384--- test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py 2014-02-25 12:44:30 +0000
385+++ test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py 2014-02-27 08:59:35 +0000
386@@ -57,8 +57,8 @@
387 sys.stdout.flush()
388
389 remote_scopes_response = '\
390-[{"base_url": "http://127.0.0.1:' + str(port) + '/demo", "id" : "dummy.scope", "name": "Dummy Demo Scope", "description": "Dummy demo scope.", "icon": "icon" },\
391-{"base_url": "http://127.0.0.1:' + str(port) + '/demo2", "id" : "dummy.scope.2", "name": "Dummy Demo Scope 2", "description": "Dummy demo scope 2.", "art": "art", "invisible": true }]'
392+[{"base_url": "http://127.0.0.1:' + str(port) + '/demo", "id" : "dummy.scope", "name": "Dummy Demo Scope", "description": "Dummy demo scope.", "author": "Mr.Fake", "icon": "icon" },\
393+{"base_url": "http://127.0.0.1:' + str(port) + '/demo2", "id" : "dummy.scope.2", "name": "Dummy Demo Scope 2", "description": "Dummy demo scope 2.", "author": "Mr.Fake", "art": "art", "invisible": true }]'
394
395 search_response = '\
396 {"category": {"renderer_template": "", "id": "cat1", "title": "Category 1"}}\r\n\
397
398=== modified file 'test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp'
399--- test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp 2014-02-26 11:45:39 +0000
400+++ test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp 2014-02-27 08:59:35 +0000
401@@ -67,6 +67,7 @@
402 EXPECT_EQ("dummy.scope", scopes[0].id);
403 EXPECT_EQ("Dummy Demo Scope", scopes[0].name);
404 EXPECT_EQ("Dummy demo scope.", scopes[0].description);
405+ EXPECT_EQ("Mr.Fake", scopes[0].author);
406 EXPECT_EQ(sss_url_ + "/demo", scopes[0].base_url);
407 EXPECT_EQ("icon", *scopes[0].icon);
408 EXPECT_EQ(nullptr, scopes[0].art);
409@@ -75,6 +76,7 @@
410 EXPECT_EQ("dummy.scope.2", scopes[1].id);
411 EXPECT_EQ("Dummy Demo Scope 2", scopes[1].name);
412 EXPECT_EQ("Dummy demo scope 2.", scopes[1].description);
413+ EXPECT_EQ("Mr.Fake", scopes[1].author);
414 EXPECT_EQ(sss_url_ + "/demo2", scopes[1].base_url);
415 EXPECT_EQ(nullptr, scopes[1].icon);
416 EXPECT_EQ("art", *scopes[1].art);
417
418=== modified file 'test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp'
419--- test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp 2014-02-26 11:45:39 +0000
420+++ test/gtest/scopes/internal/smartscopes/smartscopesproxy/smartscopesproxy_test.cpp 2014-02-27 08:59:35 +0000
421@@ -114,6 +114,7 @@
422 EXPECT_EQ("dummy.scope", meta.scope_name());
423 EXPECT_EQ("Dummy Demo Scope", meta.display_name());
424 EXPECT_EQ("Dummy demo scope.", meta.description());
425+ EXPECT_EQ("Mr.Fake", meta.author());
426 EXPECT_EQ("icon", meta.icon());
427 EXPECT_FALSE(meta.invisible());
428
429@@ -133,6 +134,7 @@
430 EXPECT_EQ("dummy.scope", meta.scope_name());
431 EXPECT_EQ("Dummy Demo Scope", meta.display_name());
432 EXPECT_EQ("Dummy demo scope.", meta.description());
433+ EXPECT_EQ("Mr.Fake", meta.author());
434 EXPECT_EQ("icon", meta.icon());
435 EXPECT_FALSE(meta.invisible());
436
437
438=== modified file 'test/gtest/scopes/internal/zmq_middleware/RegistryI/RegistryI_test.cpp'
439--- test/gtest/scopes/internal/zmq_middleware/RegistryI/RegistryI_test.cpp 2014-02-25 12:08:41 +0000
440+++ test/gtest/scopes/internal/zmq_middleware/RegistryI/RegistryI_test.cpp 2014-02-27 08:59:35 +0000
441@@ -49,6 +49,7 @@
442 mi->set_art("art " + name);
443 mi->set_display_name("display name " + name);
444 mi->set_description("description " + name);
445+ mi->set_author("author " + name);
446 mi->set_search_hint("search hint " + name);
447 mi->set_hot_key("hot key " + name);
448 ScopeProxy p = ScopeImpl::create(proxy, mw->runtime(), name);

Subscribers

People subscribed via source and target branches

to all changes: