Merge lp:~cjwatson/launchpad/snap-find-by-store-name into lp:launchpad
- snap-find-by-store-name
- Merge into devel
Proposed by
Colin Watson
Status: | Merged |
---|---|
Merged at revision: | 19030 |
Proposed branch: | lp:~cjwatson/launchpad/snap-find-by-store-name |
Merge into: | lp:launchpad |
Diff against target: |
297 lines (+152/-3) 4 files modified
database/schema/patch-2210-05-0.sql (+9/-0) lib/lp/snappy/interfaces/snap.py (+17/-0) lib/lp/snappy/model/snap.py (+11/-3) lib/lp/snappy/tests/test_snap.py (+115/-0) |
To merge this branch: | bzr merge lp:~cjwatson/launchpad/snap-find-by-store-name |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code db | Approve | |
Review via email: mp+370562@code.launchpad.net |
Commit message
Add SnapSet.
Description of the change
This will be useful for the next iteration of build.snapcraft.io, and is handy for ad-hoc operational queries as well.
To post a comment you must log in.
Revision history for this message
William Grant (wgrant) : | # |
review:
Approve
(code db)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'database/schema/patch-2210-05-0.sql' | |||
2 | --- database/schema/patch-2210-05-0.sql 1970-01-01 00:00:00 +0000 | |||
3 | +++ database/schema/patch-2210-05-0.sql 2019-08-22 10:39:42 +0000 | |||
4 | @@ -0,0 +1,9 @@ | |||
5 | 1 | -- Copyright 2019 Canonical Ltd. This software is licensed under the | ||
6 | 2 | -- GNU Affero General Public License version 3 (see the file LICENSE). | ||
7 | 3 | |||
8 | 4 | SET client_min_messages=ERROR; | ||
9 | 5 | |||
10 | 6 | CREATE INDEX snap__git_repository_url__idx ON Snap (git_repository_url); | ||
11 | 7 | CREATE INDEX snap__store_name__idx ON Snap (store_name); | ||
12 | 8 | |||
13 | 9 | INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 05, 0); | ||
14 | 0 | 10 | ||
15 | === modified file 'lib/lp/snappy/interfaces/snap.py' | |||
16 | --- lib/lp/snappy/interfaces/snap.py 2019-06-21 11:30:26 +0000 | |||
17 | +++ lib/lp/snappy/interfaces/snap.py 2019-08-22 10:39:42 +0000 | |||
18 | @@ -1005,6 +1005,23 @@ | |||
19 | 1005 | this user; otherwise, only return publicly-visible packages. | 1005 | this user; otherwise, only return publicly-visible packages. |
20 | 1006 | """ | 1006 | """ |
21 | 1007 | 1007 | ||
22 | 1008 | @operation_parameters( | ||
23 | 1009 | store_name=TextLine( | ||
24 | 1010 | title=_("The registered store package name to search for.")), | ||
25 | 1011 | owner=Reference(IPerson, title=_("Owner"), required=False)) | ||
26 | 1012 | @call_with(visible_by_user=REQUEST_USER) | ||
27 | 1013 | @operation_returns_collection_of(ISnap) | ||
28 | 1014 | @export_read_operation() | ||
29 | 1015 | @operation_for_version("devel") | ||
30 | 1016 | def findByStoreName(store_name, owner=None, visible_by_user=None): | ||
31 | 1017 | """Return all snap packages with the given store package name. | ||
32 | 1018 | |||
33 | 1019 | :param store_name: A registered store package name. | ||
34 | 1020 | :param owner: Only return packages owned by this user. | ||
35 | 1021 | :param visible_by_user: If not None, only return packages visible by | ||
36 | 1022 | this user; otherwise, only return publicly-visible packages. | ||
37 | 1023 | """ | ||
38 | 1024 | |||
39 | 1008 | def preloadDataForSnaps(snaps, user): | 1025 | def preloadDataForSnaps(snaps, user): |
40 | 1009 | """Load the data related to a list of snap packages.""" | 1026 | """Load the data related to a list of snap packages.""" |
41 | 1010 | 1027 | ||
42 | 1011 | 1028 | ||
43 | === modified file 'lib/lp/snappy/model/snap.py' | |||
44 | --- lib/lp/snappy/model/snap.py 2019-08-21 10:36:27 +0000 | |||
45 | +++ lib/lp/snappy/model/snap.py 2019-08-22 10:39:42 +0000 | |||
46 | @@ -1244,7 +1244,7 @@ | |||
47 | 1244 | snaps.order_by(Desc(Snap.date_last_modified)) | 1244 | snaps.order_by(Desc(Snap.date_last_modified)) |
48 | 1245 | return snaps | 1245 | return snaps |
49 | 1246 | 1246 | ||
51 | 1247 | def _findByURLVisibilityClause(self, visible_by_user): | 1247 | def _findSnapVisibilityClause(self, visible_by_user): |
52 | 1248 | # XXX cjwatson 2016-11-25: This is in principle a poor query, but we | 1248 | # XXX cjwatson 2016-11-25: This is in principle a poor query, but we |
53 | 1249 | # don't yet have the access grant infrastructure to do better, and | 1249 | # don't yet have the access grant infrastructure to do better, and |
54 | 1250 | # in any case the numbers involved should be very small. | 1250 | # in any case the numbers involved should be very small. |
55 | @@ -1266,7 +1266,7 @@ | |||
56 | 1266 | clauses = [Snap.git_repository_url == url] | 1266 | clauses = [Snap.git_repository_url == url] |
57 | 1267 | if owner is not None: | 1267 | if owner is not None: |
58 | 1268 | clauses.append(Snap.owner == owner) | 1268 | clauses.append(Snap.owner == owner) |
60 | 1269 | clauses.append(self._findByURLVisibilityClause(visible_by_user)) | 1269 | clauses.append(self._findSnapVisibilityClause(visible_by_user)) |
61 | 1270 | return IStore(Snap).find(Snap, *clauses) | 1270 | return IStore(Snap).find(Snap, *clauses) |
62 | 1271 | 1271 | ||
63 | 1272 | def findByURLPrefix(self, url_prefix, owner=None, visible_by_user=None): | 1272 | def findByURLPrefix(self, url_prefix, owner=None, visible_by_user=None): |
64 | @@ -1283,7 +1283,15 @@ | |||
65 | 1283 | clauses = [Or(*prefix_clauses)] | 1283 | clauses = [Or(*prefix_clauses)] |
66 | 1284 | if owner is not None: | 1284 | if owner is not None: |
67 | 1285 | clauses.append(Snap.owner == owner) | 1285 | clauses.append(Snap.owner == owner) |
69 | 1286 | clauses.append(self._findByURLVisibilityClause(visible_by_user)) | 1286 | clauses.append(self._findSnapVisibilityClause(visible_by_user)) |
70 | 1287 | return IStore(Snap).find(Snap, *clauses) | ||
71 | 1288 | |||
72 | 1289 | def findByStoreName(self, store_name, owner=None, visible_by_user=None): | ||
73 | 1290 | """See `ISnapSet`.""" | ||
74 | 1291 | clauses = [Snap.store_name == store_name] | ||
75 | 1292 | if owner is not None: | ||
76 | 1293 | clauses.append(Snap.owner == owner) | ||
77 | 1294 | clauses.append(self._findSnapVisibilityClause(visible_by_user)) | ||
78 | 1287 | return IStore(Snap).find(Snap, *clauses) | 1295 | return IStore(Snap).find(Snap, *clauses) |
79 | 1288 | 1296 | ||
80 | 1289 | def preloadDataForSnaps(self, snaps, user=None): | 1297 | def preloadDataForSnaps(self, snaps, user=None): |
81 | 1290 | 1298 | ||
82 | === modified file 'lib/lp/snappy/tests/test_snap.py' | |||
83 | --- lib/lp/snappy/tests/test_snap.py 2019-08-21 10:36:27 +0000 | |||
84 | +++ lib/lp/snappy/tests/test_snap.py 2019-08-22 10:39:42 +0000 | |||
85 | @@ -1677,6 +1677,34 @@ | |||
86 | 1677 | [snaps[0], snaps[2], snaps[4], snaps[6]], | 1677 | [snaps[0], snaps[2], snaps[4], snaps[6]], |
87 | 1678 | getUtility(ISnapSet).findByURLPrefixes(prefixes, owner=owners[0])) | 1678 | getUtility(ISnapSet).findByURLPrefixes(prefixes, owner=owners[0])) |
88 | 1679 | 1679 | ||
89 | 1680 | def test_findByStoreName(self): | ||
90 | 1681 | # ISnapSet.findByStoreName returns visible Snaps with the given | ||
91 | 1682 | # store name. | ||
92 | 1683 | store_names = ["foo", "bar"] | ||
93 | 1684 | owners = [self.factory.makePerson() for i in range(2)] | ||
94 | 1685 | snaps = [] | ||
95 | 1686 | for store_name in store_names: | ||
96 | 1687 | for owner in owners: | ||
97 | 1688 | for private in (False, True): | ||
98 | 1689 | snaps.append(self.factory.makeSnap( | ||
99 | 1690 | registrant=owner, owner=owner, private=private, | ||
100 | 1691 | store_name=store_name)) | ||
101 | 1692 | snaps.append(self.factory.makeSnap()) | ||
102 | 1693 | self.assertContentEqual( | ||
103 | 1694 | [snaps[0], snaps[2]], | ||
104 | 1695 | getUtility(ISnapSet).findByStoreName(store_names[0])) | ||
105 | 1696 | with person_logged_in(owners[0]): | ||
106 | 1697 | self.assertContentEqual( | ||
107 | 1698 | snaps[:2], | ||
108 | 1699 | getUtility(ISnapSet).findByStoreName( | ||
109 | 1700 | store_names[0], owner=owners[0], | ||
110 | 1701 | visible_by_user=owners[0])) | ||
111 | 1702 | self.assertContentEqual( | ||
112 | 1703 | [snaps[2]], | ||
113 | 1704 | getUtility(ISnapSet).findByStoreName( | ||
114 | 1705 | store_names[0], owner=owners[1], | ||
115 | 1706 | visible_by_user=owners[0])) | ||
116 | 1707 | |||
117 | 1680 | def test_getSnapcraftYaml_bzr_snap_snapcraft_yaml(self): | 1708 | def test_getSnapcraftYaml_bzr_snap_snapcraft_yaml(self): |
118 | 1681 | def getInventory(unique_name, dirname, *args, **kwargs): | 1709 | def getInventory(unique_name, dirname, *args, **kwargs): |
119 | 1682 | if dirname == "snap": | 1710 | if dirname == "snap": |
120 | @@ -2732,6 +2760,7 @@ | |||
121 | 2732 | commercial_admin = ( | 2760 | commercial_admin = ( |
122 | 2733 | getUtility(ILaunchpadCelebrities).commercial_admin.teamowner) | 2761 | getUtility(ILaunchpadCelebrities).commercial_admin.teamowner) |
123 | 2734 | logout() | 2762 | logout() |
124 | 2763 | |||
125 | 2735 | # Anonymous requests can only see public snaps. | 2764 | # Anonymous requests can only see public snaps. |
126 | 2736 | anon_webservice = LaunchpadWebServiceCaller("test", "") | 2765 | anon_webservice = LaunchpadWebServiceCaller("test", "") |
127 | 2737 | response = anon_webservice.named_get( | 2766 | response = anon_webservice.named_get( |
128 | @@ -2741,6 +2770,7 @@ | |||
129 | 2741 | self.assertContentEqual( | 2770 | self.assertContentEqual( |
130 | 2742 | [ws_snaps[0]], | 2771 | [ws_snaps[0]], |
131 | 2743 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | 2772 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) |
132 | 2773 | |||
133 | 2744 | # persons[0] can see their own private snap as well, but not those | 2774 | # persons[0] can see their own private snap as well, but not those |
134 | 2745 | # for other people. | 2775 | # for other people. |
135 | 2746 | webservice = webservice_for_person( | 2776 | webservice = webservice_for_person( |
136 | @@ -2759,6 +2789,7 @@ | |||
137 | 2759 | self.assertContentEqual( | 2789 | self.assertContentEqual( |
138 | 2760 | [ws_snaps[2]], | 2790 | [ws_snaps[2]], |
139 | 2761 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | 2791 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) |
140 | 2792 | |||
141 | 2762 | # Admins can see all snaps. | 2793 | # Admins can see all snaps. |
142 | 2763 | commercial_admin_webservice = webservice_for_person( | 2794 | commercial_admin_webservice = webservice_for_person( |
143 | 2764 | commercial_admin, permission=OAuthPermission.READ_PRIVATE) | 2795 | commercial_admin, permission=OAuthPermission.READ_PRIVATE) |
144 | @@ -2797,6 +2828,7 @@ | |||
145 | 2797 | commercial_admin = ( | 2828 | commercial_admin = ( |
146 | 2798 | getUtility(ILaunchpadCelebrities).commercial_admin.teamowner) | 2829 | getUtility(ILaunchpadCelebrities).commercial_admin.teamowner) |
147 | 2799 | logout() | 2830 | logout() |
148 | 2831 | |||
149 | 2800 | # Anonymous requests can only see public snaps. | 2832 | # Anonymous requests can only see public snaps. |
150 | 2801 | anon_webservice = LaunchpadWebServiceCaller("test", "") | 2833 | anon_webservice = LaunchpadWebServiceCaller("test", "") |
151 | 2802 | response = anon_webservice.named_get( | 2834 | response = anon_webservice.named_get( |
152 | @@ -2812,6 +2844,7 @@ | |||
153 | 2812 | self.assertContentEqual( | 2844 | self.assertContentEqual( |
154 | 2813 | [ws_snaps[0]], | 2845 | [ws_snaps[0]], |
155 | 2814 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | 2846 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) |
156 | 2847 | |||
157 | 2815 | # persons[0] can see both public snaps with this URL, as well as | 2848 | # persons[0] can see both public snaps with this URL, as well as |
158 | 2816 | # their own private snap. | 2849 | # their own private snap. |
159 | 2817 | webservice = webservice_for_person( | 2850 | webservice = webservice_for_person( |
160 | @@ -2829,6 +2862,7 @@ | |||
161 | 2829 | self.assertContentEqual( | 2862 | self.assertContentEqual( |
162 | 2830 | ws_snaps[:2], | 2863 | ws_snaps[:2], |
163 | 2831 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | 2864 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) |
164 | 2865 | |||
165 | 2832 | # Admins can see all snaps with this URL. | 2866 | # Admins can see all snaps with this URL. |
166 | 2833 | commercial_admin_webservice = webservice_for_person( | 2867 | commercial_admin_webservice = webservice_for_person( |
167 | 2834 | commercial_admin, permission=OAuthPermission.READ_PRIVATE) | 2868 | commercial_admin, permission=OAuthPermission.READ_PRIVATE) |
168 | @@ -2873,6 +2907,7 @@ | |||
169 | 2873 | getUtility(ILaunchpadCelebrities).commercial_admin.teamowner) | 2907 | getUtility(ILaunchpadCelebrities).commercial_admin.teamowner) |
170 | 2874 | logout() | 2908 | logout() |
171 | 2875 | prefix = "https://git.example.org/foo/" | 2909 | prefix = "https://git.example.org/foo/" |
172 | 2910 | |||
173 | 2876 | # Anonymous requests can only see public snaps. | 2911 | # Anonymous requests can only see public snaps. |
174 | 2877 | anon_webservice = LaunchpadWebServiceCaller("test", "") | 2912 | anon_webservice = LaunchpadWebServiceCaller("test", "") |
175 | 2878 | response = anon_webservice.named_get( | 2913 | response = anon_webservice.named_get( |
176 | @@ -2889,6 +2924,7 @@ | |||
177 | 2889 | self.assertContentEqual( | 2924 | self.assertContentEqual( |
178 | 2890 | [ws_snaps[i] for i in (0, 4)], | 2925 | [ws_snaps[i] for i in (0, 4)], |
179 | 2891 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | 2926 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) |
180 | 2927 | |||
181 | 2892 | # persons[0] can see all public snaps with this URL prefix, as well | 2928 | # persons[0] can see all public snaps with this URL prefix, as well |
182 | 2893 | # as their own matching private snaps. | 2929 | # as their own matching private snaps. |
183 | 2894 | webservice = webservice_for_person( | 2930 | webservice = webservice_for_person( |
184 | @@ -2907,6 +2943,7 @@ | |||
185 | 2907 | self.assertContentEqual( | 2943 | self.assertContentEqual( |
186 | 2908 | [ws_snaps[i] for i in (0, 1, 4, 5)], | 2944 | [ws_snaps[i] for i in (0, 1, 4, 5)], |
187 | 2909 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | 2945 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) |
188 | 2946 | |||
189 | 2910 | # Admins can see all snaps with this URL prefix. | 2947 | # Admins can see all snaps with this URL prefix. |
190 | 2911 | commercial_admin_webservice = webservice_for_person( | 2948 | commercial_admin_webservice = webservice_for_person( |
191 | 2912 | commercial_admin, permission=OAuthPermission.READ_PRIVATE) | 2949 | commercial_admin, permission=OAuthPermission.READ_PRIVATE) |
192 | @@ -2955,6 +2992,7 @@ | |||
193 | 2955 | logout() | 2992 | logout() |
194 | 2956 | prefixes = [ | 2993 | prefixes = [ |
195 | 2957 | "https://git.example.org/foo/", "https://git.example.org/bar/"] | 2994 | "https://git.example.org/foo/", "https://git.example.org/bar/"] |
196 | 2995 | |||
197 | 2958 | # Anonymous requests can only see public snaps. | 2996 | # Anonymous requests can only see public snaps. |
198 | 2959 | anon_webservice = LaunchpadWebServiceCaller("test", "") | 2997 | anon_webservice = LaunchpadWebServiceCaller("test", "") |
199 | 2960 | response = anon_webservice.named_get( | 2998 | response = anon_webservice.named_get( |
200 | @@ -2971,6 +3009,7 @@ | |||
201 | 2971 | self.assertContentEqual( | 3009 | self.assertContentEqual( |
202 | 2972 | [ws_snaps[i] for i in (0, 4, 8, 12)], | 3010 | [ws_snaps[i] for i in (0, 4, 8, 12)], |
203 | 2973 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | 3011 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) |
204 | 3012 | |||
205 | 2974 | # persons[0] can see all public snaps with any of these URL | 3013 | # persons[0] can see all public snaps with any of these URL |
206 | 2975 | # prefixes, as well as their own matching private snaps. | 3014 | # prefixes, as well as their own matching private snaps. |
207 | 2976 | webservice = webservice_for_person( | 3015 | webservice = webservice_for_person( |
208 | @@ -2989,6 +3028,7 @@ | |||
209 | 2989 | self.assertContentEqual( | 3028 | self.assertContentEqual( |
210 | 2990 | [ws_snaps[i] for i in (0, 1, 4, 5, 8, 9, 12, 13)], | 3029 | [ws_snaps[i] for i in (0, 1, 4, 5, 8, 9, 12, 13)], |
211 | 2991 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | 3030 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) |
212 | 3031 | |||
213 | 2992 | # Admins can see all snaps with any of these URL prefixes. | 3032 | # Admins can see all snaps with any of these URL prefixes. |
214 | 2993 | commercial_admin_webservice = webservice_for_person( | 3033 | commercial_admin_webservice = webservice_for_person( |
215 | 2994 | commercial_admin, permission=OAuthPermission.READ_PRIVATE) | 3034 | commercial_admin, permission=OAuthPermission.READ_PRIVATE) |
216 | @@ -3007,6 +3047,81 @@ | |||
217 | 3007 | [ws_snaps[i] for i in (0, 1, 4, 5, 8, 9, 12, 13)], | 3047 | [ws_snaps[i] for i in (0, 1, 4, 5, 8, 9, 12, 13)], |
218 | 3008 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | 3048 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) |
219 | 3009 | 3049 | ||
220 | 3050 | def test_findByStoreName(self): | ||
221 | 3051 | # lp.snaps.findByStoreName returns visible Snaps with the given | ||
222 | 3052 | # store name. | ||
223 | 3053 | persons = [self.factory.makePerson(), self.factory.makePerson()] | ||
224 | 3054 | store_names = ["foo", "bar"] | ||
225 | 3055 | snaps = [] | ||
226 | 3056 | for store_name in store_names: | ||
227 | 3057 | for person in persons: | ||
228 | 3058 | for private in (False, True): | ||
229 | 3059 | snaps.append(self.factory.makeSnap( | ||
230 | 3060 | registrant=person, owner=person, private=private, | ||
231 | 3061 | store_name=store_name)) | ||
232 | 3062 | with admin_logged_in(): | ||
233 | 3063 | person_urls = [api_url(person) for person in persons] | ||
234 | 3064 | ws_snaps = [ | ||
235 | 3065 | self.webservice.getAbsoluteUrl(api_url(snap)) | ||
236 | 3066 | for snap in snaps] | ||
237 | 3067 | commercial_admin = ( | ||
238 | 3068 | getUtility(ILaunchpadCelebrities).commercial_admin.teamowner) | ||
239 | 3069 | logout() | ||
240 | 3070 | |||
241 | 3071 | # Anonymous requests can only see public snaps. | ||
242 | 3072 | anon_webservice = LaunchpadWebServiceCaller("test", "") | ||
243 | 3073 | response = anon_webservice.named_get( | ||
244 | 3074 | "/+snaps", "findByStoreName", store_name=store_names[0], | ||
245 | 3075 | api_version="devel") | ||
246 | 3076 | self.assertEqual(200, response.status) | ||
247 | 3077 | self.assertContentEqual( | ||
248 | 3078 | [ws_snaps[0], ws_snaps[2]], | ||
249 | 3079 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | ||
250 | 3080 | response = anon_webservice.named_get( | ||
251 | 3081 | "/+snaps", "findByStoreName", store_name=store_names[0], | ||
252 | 3082 | owner=person_urls[0], api_version="devel") | ||
253 | 3083 | self.assertEqual(200, response.status) | ||
254 | 3084 | self.assertContentEqual( | ||
255 | 3085 | [ws_snaps[0]], | ||
256 | 3086 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | ||
257 | 3087 | |||
258 | 3088 | # persons[0] can see both public snaps with this store name, as well | ||
259 | 3089 | # as their own private snap. | ||
260 | 3090 | webservice = webservice_for_person( | ||
261 | 3091 | persons[0], permission=OAuthPermission.READ_PRIVATE) | ||
262 | 3092 | response = webservice.named_get( | ||
263 | 3093 | "/+snaps", "findByStoreName", store_name=store_names[0], | ||
264 | 3094 | api_version="devel") | ||
265 | 3095 | self.assertEqual(200, response.status) | ||
266 | 3096 | self.assertContentEqual( | ||
267 | 3097 | ws_snaps[:3], | ||
268 | 3098 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | ||
269 | 3099 | response = webservice.named_get( | ||
270 | 3100 | "/+snaps", "findByStoreName", store_name=store_names[0], | ||
271 | 3101 | owner=person_urls[0], api_version="devel") | ||
272 | 3102 | self.assertEqual(200, response.status) | ||
273 | 3103 | self.assertContentEqual( | ||
274 | 3104 | ws_snaps[:2], | ||
275 | 3105 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | ||
276 | 3106 | |||
277 | 3107 | # Admins can see all snaps with this store name. | ||
278 | 3108 | commercial_admin_webservice = webservice_for_person( | ||
279 | 3109 | commercial_admin, permission=OAuthPermission.READ_PRIVATE) | ||
280 | 3110 | response = commercial_admin_webservice.named_get( | ||
281 | 3111 | "/+snaps", "findByStoreName", store_name=store_names[0], | ||
282 | 3112 | api_version="devel") | ||
283 | 3113 | self.assertEqual(200, response.status) | ||
284 | 3114 | self.assertContentEqual( | ||
285 | 3115 | ws_snaps[:4], | ||
286 | 3116 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | ||
287 | 3117 | response = commercial_admin_webservice.named_get( | ||
288 | 3118 | "/+snaps", "findByStoreName", store_name=store_names[0], | ||
289 | 3119 | owner=person_urls[0], api_version="devel") | ||
290 | 3120 | self.assertEqual(200, response.status) | ||
291 | 3121 | self.assertContentEqual( | ||
292 | 3122 | ws_snaps[:2], | ||
293 | 3123 | [entry["self_link"] for entry in response.jsonBody()["entries"]]) | ||
294 | 3124 | |||
295 | 3010 | def setProcessors(self, user, snap, names): | 3125 | def setProcessors(self, user, snap, names): |
296 | 3011 | ws = webservice_for_person( | 3126 | ws = webservice_for_person( |
297 | 3012 | user, permission=OAuthPermission.WRITE_PUBLIC) | 3127 | user, permission=OAuthPermission.WRITE_PUBLIC) |