2070
2078
expected_counts = {'info': 0, 'warn': 0, 'error': 0}
2071
2079
self.check_results(r, expected_counts)
2073
def test_check_uses(self):
2074
'''Test check_uses()'''
2075
uses = self._create_top_uses()
2076
self.set_test_snap_yaml("uses", uses)
2081
def test_check_slots(self):
2082
'''Test check_slots()'''
2083
slots = self._create_top_slots()
2084
self.set_test_snap_yaml("slots", slots)
2077
2085
c = SnapReviewLint(self.test_name)
2079
2087
r = c.click_report
2080
2088
expected_counts = {'info': 13, 'warn': 0, 'error': 0}
2081
2089
self.check_results(r, expected_counts)
2083
def test_check_uses_bad_type(self):
2084
'''Test check_uses() - bad type (list)'''
2085
uses = {'skill-caps': {'type': [],
2086
'caps': ['network-client']}}
2087
self.set_test_snap_yaml("uses", uses)
2088
c = SnapReviewLint(self.test_name)
2091
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2092
self.check_results(r, expected_counts)
2094
def test_check_uses_empty_type(self):
2095
'''Test check_uses() - empty type'''
2096
uses = {'skill-caps': {'type': "",
2097
'caps': ['network-client']}}
2098
self.set_test_snap_yaml("uses", uses)
2099
c = SnapReviewLint(self.test_name)
2102
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2103
self.check_results(r, expected_counts)
2105
def test_check_uses_unspecified_type(self):
2106
'''Test check_uses() - unspecified type'''
2107
uses = {'migration-skill': {'caps': ['network-client']}}
2108
self.set_test_snap_yaml("uses", uses)
2109
c = SnapReviewLint(self.test_name)
2091
def test_check_slots_bad_interface(self):
2092
'''Test check_slots() - bad interface (list)'''
2093
slots = {'iface-caps': {'interface': [],
2094
'caps': ['network-client']}}
2095
self.set_test_snap_yaml("slots", slots)
2096
c = SnapReviewLint(self.test_name)
2099
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2100
self.check_results(r, expected_counts)
2102
def test_check_slots_empty_interface(self):
2103
'''Test check_slots() - empty interface'''
2104
slots = {'iface-caps': {'interface': "",
2105
'caps': ['network-client']}}
2106
self.set_test_snap_yaml("slots", slots)
2107
c = SnapReviewLint(self.test_name)
2110
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2111
self.check_results(r, expected_counts)
2113
def test_check_slots_unspecified_interface(self):
2114
'''Test check_slots() - unspecified interface'''
2115
slots = {'old-security': {'caps': ['network-client']}}
2116
self.set_test_snap_yaml("slots", slots)
2117
c = SnapReviewLint(self.test_name)
2111
2119
r = c.click_report
2112
2120
expected_counts = {'info': 3, 'warn': 0, 'error': 0}
2113
2121
self.check_results(r, expected_counts)
2115
def test_check_uses_unknown_type(self):
2116
'''Test check_uses() - type (unknown)'''
2117
uses = {'skill-caps': {'type': 'nonexistent',
2118
'caps': ['network-client']}}
2119
self.set_test_snap_yaml("uses", uses)
2120
c = SnapReviewLint(self.test_name)
2123
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2124
self.check_results(r, expected_counts)
2126
def test_check_uses_unspecified_unknown_type(self):
2127
'''Test check_uses() - unspecified type (unknown)'''
2128
uses = {'nonexistent': {'caps': ['network-client']}}
2129
self.set_test_snap_yaml("uses", uses)
2130
c = SnapReviewLint(self.test_name)
2133
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2134
self.check_results(r, expected_counts)
2136
def test_check_uses_missing_attrib(self):
2137
'''Test check_uses() - missing attrib'''
2138
uses = {'migration-skill': {}}
2139
self.set_test_snap_yaml("uses", uses)
2140
c = SnapReviewLint(self.test_name)
2143
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2144
self.check_results(r, expected_counts)
2146
def test_check_uses_missing_attrib_explicit_type(self):
2147
'''Test check_uses() - missing attrib'''
2148
uses = {'skill-caps': {'type': 'migration-skill'}}
2149
self.set_test_snap_yaml("uses", uses)
2150
c = SnapReviewLint(self.test_name)
2153
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2154
self.check_results(r, expected_counts)
2156
def test_check_uses_unknown_attrib(self):
2157
'''Test check_uses() - unknown attrib'''
2158
uses = {'skill-caps': {'type': "migration-skill",
2159
'nonexistent': 'abc'}}
2160
self.set_test_snap_yaml("uses", uses)
2161
c = SnapReviewLint(self.test_name)
2164
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2165
self.check_results(r, expected_counts)
2167
def test_check_uses_bad_attrib_caps(self):
2168
'''Test check_uses() - bad attrib - caps'''
2169
uses = {'skill-caps': {'type': "migration-skill",
2171
self.set_test_snap_yaml("uses", uses)
2172
c = SnapReviewLint(self.test_name)
2175
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2176
self.check_results(r, expected_counts)
2178
def test_check_uses_bad_attrib_security_override(self):
2179
'''Test check_uses() - bad attrib - security-override'''
2180
uses = {'skill-caps': {'type': "migration-skill",
2181
'security-override': 'bad'}}
2182
self.set_test_snap_yaml("uses", uses)
2183
c = SnapReviewLint(self.test_name)
2186
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2187
self.check_results(r, expected_counts)
2189
def test_check_uses_bad_attrib_security_policy(self):
2190
'''Test check_uses() - bad attrib - security-policy'''
2191
uses = {'skill-caps': {'type': "migration-skill",
2192
'security-policy': 'bad'}}
2193
self.set_test_snap_yaml("uses", uses)
2194
c = SnapReviewLint(self.test_name)
2197
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2198
self.check_results(r, expected_counts)
2200
def test_check_uses_bad_attrib_security_template(self):
2201
'''Test check_uses() - bad attrib - security-template'''
2202
uses = {'skill-caps': {'type': "migration-skill",
2203
'security-template': []}}
2204
self.set_test_snap_yaml("uses", uses)
2205
c = SnapReviewLint(self.test_name)
2208
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2209
self.check_results(r, expected_counts)
2211
def test_check_apps_uses(self):
2212
'''Test check_apps_uses()'''
2213
uses = self._create_top_uses()
2214
apps_uses = self._create_apps_uses()
2215
self.set_test_snap_yaml("uses", uses)
2216
self.set_test_snap_yaml("apps", apps_uses)
2217
c = SnapReviewLint(self.test_name)
2123
def test_check_slots_unknown_interface(self):
2124
'''Test check_slots() - interface (unknown)'''
2125
slots = {'iface-caps': {'interface': 'nonexistent',
2126
'caps': ['network-client']}}
2127
self.set_test_snap_yaml("slots", slots)
2128
c = SnapReviewLint(self.test_name)
2131
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2132
self.check_results(r, expected_counts)
2134
def test_check_slots_unspecified_unknown_interface(self):
2135
'''Test check_slots() - unspecified interface (unknown)'''
2136
slots = {'nonexistent': {'caps': ['network-client']}}
2137
self.set_test_snap_yaml("slots", slots)
2138
c = SnapReviewLint(self.test_name)
2141
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2142
self.check_results(r, expected_counts)
2144
def test_check_slots_missing_attrib(self):
2145
'''Test check_slots() - missing attrib'''
2146
slots = {'old-security': {}}
2147
self.set_test_snap_yaml("slots", slots)
2148
c = SnapReviewLint(self.test_name)
2151
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2152
self.check_results(r, expected_counts)
2154
def test_check_slots_missing_attrib_explicit_interface(self):
2155
'''Test check_slots() - missing attrib'''
2156
slots = {'iface-caps': {'interface': 'old-security'}}
2157
self.set_test_snap_yaml("slots", slots)
2158
c = SnapReviewLint(self.test_name)
2161
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2162
self.check_results(r, expected_counts)
2164
def test_check_slots_unknown_attrib(self):
2165
'''Test check_slots() - unknown attrib'''
2166
slots = {'iface-caps': {'interface': 'old-security',
2167
'nonexistent': 'abc'}}
2168
self.set_test_snap_yaml("slots", slots)
2169
c = SnapReviewLint(self.test_name)
2172
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2173
self.check_results(r, expected_counts)
2175
def test_check_slots_bad_attrib_caps(self):
2176
'''Test check_slots() - bad attrib - caps'''
2177
slots = {'iface-caps': {'interface': 'old-security',
2179
self.set_test_snap_yaml("slots", slots)
2180
c = SnapReviewLint(self.test_name)
2183
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2184
self.check_results(r, expected_counts)
2186
def test_check_slots_bad_attrib_security_override(self):
2187
'''Test check_slots() - bad attrib - security-override'''
2188
slots = {'iface-caps': {'interface': 'old-security',
2189
'security-override': 'bad'}}
2190
self.set_test_snap_yaml("slots", slots)
2191
c = SnapReviewLint(self.test_name)
2194
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2195
self.check_results(r, expected_counts)
2197
def test_check_slots_bad_attrib_security_policy(self):
2198
'''Test check_slots() - bad attrib - security-policy'''
2199
slots = {'iface-caps': {'interface': 'old-security',
2200
'security-policy': 'bad'}}
2201
self.set_test_snap_yaml("slots", slots)
2202
c = SnapReviewLint(self.test_name)
2205
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2206
self.check_results(r, expected_counts)
2208
def test_check_slots_bad_attrib_security_template(self):
2209
'''Test check_slots() - bad attrib - security-template'''
2210
slots = {'iface-caps': {'interface': 'old-security',
2211
'security-template': []}}
2212
self.set_test_snap_yaml("slots", slots)
2213
c = SnapReviewLint(self.test_name)
2216
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2217
self.check_results(r, expected_counts)
2219
def test_check_apps_slots(self):
2220
'''Test check_apps_slots()'''
2221
slots = self._create_top_slots()
2222
apps_slots = self._create_apps_slots()
2223
self.set_test_snap_yaml("slots", slots)
2224
self.set_test_snap_yaml("apps", apps_slots)
2225
c = SnapReviewLint(self.test_name)
2226
c.check_apps_slots()
2219
2227
r = c.click_report
2220
2228
expected_counts = {'info': 10, 'warn': 0, 'error': 0}
2221
2229
self.check_results(r, expected_counts)
2223
def test_check_apps_no_uses(self):
2224
'''Test check_apps_uses() - no uses'''
2225
uses = self._create_top_uses()
2226
apps_uses = {'bar': {'command': 'bin/bar'}}
2227
self.set_test_snap_yaml("uses", uses)
2228
self.set_test_snap_yaml("apps", apps_uses)
2231
def test_check_apps_no_slots(self):
2232
'''Test check_apps_slots() - no slots'''
2233
slots = self._create_top_slots()
2234
apps_slots = {'bar': {'command': 'bin/bar'}}
2235
self.set_test_snap_yaml("slots", slots)
2236
self.set_test_snap_yaml("apps", apps_slots)
2229
2237
c = SnapReviewLint(self.test_name)
2238
c.check_apps_slots()
2231
2239
r = c.click_report
2232
2240
expected_counts = {'info': 0, 'warn': 0, 'error': 0}
2233
2241
self.check_results(r, expected_counts)
2235
def test_check_apps_uses_bad(self):
2236
'''Test check_apps_uses() - bad (dict)'''
2237
uses = self._create_top_uses()
2238
apps_uses = {'bar': {'uses': {}}}
2239
self.set_test_snap_yaml("uses", uses)
2240
self.set_test_snap_yaml("apps", apps_uses)
2241
c = SnapReviewLint(self.test_name)
2244
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2245
self.check_results(r, expected_counts)
2247
def test_check_apps_uses_empty(self):
2248
'''Test check_apps_uses() - empty'''
2249
uses = self._create_top_uses()
2250
apps_uses = {'bar': {'uses': []}}
2251
self.set_test_snap_yaml("uses", uses)
2252
self.set_test_snap_yaml("apps", apps_uses)
2253
c = SnapReviewLint(self.test_name)
2256
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2257
self.check_results(r, expected_counts)
2259
def test_check_apps_uses_bad_entry(self):
2260
'''Test check_apps_uses() - bad entry (dict)'''
2261
uses = self._create_top_uses()
2262
apps_uses = {'bar': {'uses': [{}]}}
2263
self.set_test_snap_yaml("uses", uses)
2264
self.set_test_snap_yaml("apps", apps_uses)
2265
c = SnapReviewLint(self.test_name)
2268
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2269
self.check_results(r, expected_counts)
2271
def test_check_apps_uses_unknown_entry(self):
2272
'''Test check_apps_uses() - unknown'''
2273
uses = self._create_top_uses()
2274
apps_uses = {'bar': {'uses': ['nonexistent']}}
2275
self.set_test_snap_yaml("uses", uses)
2276
self.set_test_snap_yaml("apps", apps_uses)
2277
c = SnapReviewLint(self.test_name)
2280
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2243
def test_check_apps_slots_bad(self):
2244
'''Test check_apps_slots() - bad (dict)'''
2245
slots = self._create_top_slots()
2246
apps_slots = {'bar': {'slots': {}}}
2247
self.set_test_snap_yaml("slots", slots)
2248
self.set_test_snap_yaml("apps", apps_slots)
2249
c = SnapReviewLint(self.test_name)
2250
c.check_apps_slots()
2252
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2253
self.check_results(r, expected_counts)
2255
def test_check_apps_slots_empty(self):
2256
'''Test check_apps_slots() - empty'''
2257
slots = self._create_top_slots()
2258
apps_slots = {'bar': {'slots': []}}
2259
self.set_test_snap_yaml("slots", slots)
2260
self.set_test_snap_yaml("apps", apps_slots)
2261
c = SnapReviewLint(self.test_name)
2262
c.check_apps_slots()
2264
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2265
self.check_results(r, expected_counts)
2267
def test_check_apps_slots_bad_entry(self):
2268
'''Test check_apps_slots() - bad entry (dict)'''
2269
slots = self._create_top_slots()
2270
apps_slots = {'bar': {'slots': [{}]}}
2271
self.set_test_snap_yaml("slots", slots)
2272
self.set_test_snap_yaml("apps", apps_slots)
2273
c = SnapReviewLint(self.test_name)
2274
c.check_apps_slots()
2276
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2277
self.check_results(r, expected_counts)
2279
def test_check_apps_slots_unknown_entry(self):
2280
'''Test check_apps_slots() - unknown'''
2281
slots = self._create_top_slots()
2282
apps_slots = {'bar': {'slots': ['nonexistent']}}
2283
self.set_test_snap_yaml("slots", slots)
2284
self.set_test_snap_yaml("apps", apps_slots)
2285
c = SnapReviewLint(self.test_name)
2286
c.check_apps_slots()
2288
expected_counts = {'info': None, 'warn': 0, 'error': 1}
2289
self.check_results(r, expected_counts)
2291
def test_check_plugs(self):
2292
'''Test check_plugs()'''
2293
plugs = self._create_top_plugs()
2294
self.set_test_snap_yaml("plugs", plugs)
2295
c = SnapReviewLint(self.test_name)
2298
expected_counts = {'info': 0, 'warn': 1, 'error': 0}
2299
self.check_results(r, expected_counts)
2301
def test_check_apps_plugs(self):
2302
'''Test check_apps_plugs()'''
2303
plugs = self._create_top_plugs()
2304
self.set_test_snap_yaml("plugs", plugs)
2305
apps_plugs = self._create_apps_plugs()
2306
self.set_test_snap_yaml("apps", apps_plugs)
2307
c = SnapReviewLint(self.test_name)
2308
c.check_apps_plugs()
2310
expected_counts = {'info': 0, 'warn': 1, 'error': 0}
2281
2311
self.check_results(r, expected_counts)