def test_template_add_includes_obj(self): t1 = Template("foo:bar") t2 = Template("bar:baz") t3 = Template("baz:daz") p1 = Package("foo") p2 = Package("bar") p3 = Package("baz") p4 = Package("~baz") t1.add_package(p1) t2.add_package(p2) t2.add_package(p3) t3.add_package(p4) # check includes t1.includes = [t2] self.assertEqual(["bar:baz"], t1.includes) # check includes (rebuild) t1.includes = [t2, t3] self.assertEqual(["bar:baz", "baz:daz"], t1.includes) # check package resolution t1.includes = [t2] self.assertEqual(PackageSet([p1, p2, p3]), t1.packages_all) # check package resolution (ordered) t1.includes = [t2, t3] self.assertEqual(PackageSet([p1, p2, p3]), t1.packages_all) t1.includes = [t3, t2] self.assertEqual(PackageSet([p1, p2, p4]), t1.packages_all)
def test_template_add_includes_str(self): t1 = Template("foo:bar") t1.includes = 'foo' self.assertEqual(["foo:foo"], t1.includes) t1.includes = ['foo', 'bar@baz'] self.assertEqual(["foo:foo", "foo:bar@baz"], t1.includes) t1.includes = 'foo,bar@baz,baz' self.assertEqual(["foo:foo", "foo:bar@baz", "foo:baz"], t1.includes)
def test_template_add_includes_str(self): t1 = Template("foo:bar") t1.includes = 'foo' self.assertEqual(["foo:foo"], t1.includes) t1.includes = ['foo','bar@baz'] self.assertEqual(["foo:foo", "foo:bar@baz"], t1.includes) t1.includes = 'foo,bar@baz,baz' self.assertEqual(["foo:foo", "foo:bar@baz", "foo:baz"], t1.includes)
def run_add(self): t = Template(self.args.template, user=self.args.username) # add template bits that are specified if self.args.title is not None: t.title = self.args.title if self.args.description is not None: t.description = self.args.description if self.args.includes is not None: t.includes = self.args.includes if self.args.public is not None: t.public = self.args.public try: res = self.cs.template_create(t) except ServiceException as e: logging.exception(e) return 1 logging.info('Template added.') return 0
def run_update(self): t = Template(self.args.template, user=self.args.username) try: t = self.cs.template_get(t, resolve_includes=False) except ServiceException as e: logging.exception(e) return 1 # add template bits that are specified for update if self.args.title is not None: t.title = self.args.title if self.args.description is not None: t.description = self.args.description if self.args.includes is not None: t.includes = self.args.includes if self.args.public is not None: t.public = self.args.public try: res = self.cs.template_update(t) except ServiceException as e: logging.exception(e) return 1 logging.info('Template updated.') return 0
def run_add(self): t = Template(self.args.template, user=self.args.username) if self.args.username: if not self.cs.authenticate(self.args.username, getpass.getpass('Password ({0}): '.format(self.args.username))): print('error: unable to authenticate with canvas service.') return 1 # add template bits that are specified if self.args.title is not None: t.title = self.args.title if self.args.description is not None: t.description = self.args.description if self.args.includes is not None: t.includes = self.args.includes if self.args.public is not None: t.public = self.args.public try: res = self.cs.template_create(t) except ServiceException as e: print(e) return 1 print('info: template added.') return 0