def test_lookup_paths(self, app): n = Namespace(name='Hello') p = Package(name='Dog Bog', namespace=n) p.save() n2 = Namespace(name='Molten') n2.save() p2 = Package(name='Dog Bog', namespace=n2) p2.save() expected_path = 'hello/dog-bog' assert Package.lookup_paths([expected_path]) == [p]
def route_update_suite_packages(suite_slug): suite = get_suite(suite_slug) paths = request.json packages = Package.lookup_paths(paths) package_paths = [p.path for p in packages] missing_paths = [path for path in paths if path not in package_paths] if missing_paths: raise ErrorResponse(errors=[ PackageNotFoundErrorResponse(path) for path in missing_paths ], status=400) suite.packages = packages suite.save() return suite_schema.jsonify(suite)