def test_delete_template(self): """Checks if user can delete a template they own and not some other.""" user = m.User.query.first() # Adding another user. other_user = m.User(twitch_id="0987") m.db.session.add(other_user) m.db.session.commit() # Adding a template for the other user. template = m.Template(user_id=other_user.user_id, contents="Hello!") m.db.session.add(template) m.db.session.commit() # Case 1: User deletes their own template. user.delete_template(10) is_template = m.Template.query.get(10) self.assertIsNone = is_template # Case 2: User tries to delete a template they don't own. self.assertRaises(sqlalchemy.orm.exc.NoResultFound, user.delete_template, template.template_id) # Case 3: User tries to delete a template that doesn't exist. self.assertRaises(sqlalchemy.orm.exc.NoResultFound, user.delete_template, 600)
def deploy_blueprint_template(request, template_name, product): template = model.Template(template_name) net = model.Network("node-int-net-01", True) inst = model.Instance('ubuntu', 'Ubuntu14.04init_deprecated', '2', '', False, [net]) service = model.Service(product.name, product) service.add_instance(inst) template.add_service(service) request.deploy_template(template)
def deploy_no_network(request, template_name): atts = [] atts.append({'port': '8080'}) template = model.Template(template_name) product = model.Product('tomcat', 'io.murano.apps.apache.Tomcat', atts) inst = model.Instance('ubuntu', 'Ubuntu14.04init_deprecated', '2', '', False) service = model.Service(product.name, product) service.add_instance(inst) template.add_service(service) request.deploy_template(template)
def deploy_two_networks_in_vm(request, template_name): atts = [] atts.append({'port': '8080'}) template = model.Template(template_name) product = model.Product('tomcat', 'io.murano.apps.apache.Tomcat', atts) net1 = model.Network('new', False) net2 = model.Network("node-int-net-01", True) inst = model.Instance('ubuntu', 'Ubuntu14.04init_deprecated', '2', '', False, [net1, net2]) service = model.Service(product.name, product) service.add_instance(inst) template.add_service(service) request.deploy_template(template)
def deploy_orion_chef(request, template_name): atts = [] atts.append({'port': '1026'}) product = model.Product('orionchef', 'io.murano.conflang.chef.GitChef', atts) template = model.Template(template_name) net = model.Network("node-int-net-01", True) inst = model.Instance('centos', 'CentOS-6.5init_deprecated', '2', 'demo4', False, [net]) service = model.Service(product.name, product) service.add_instance(inst) template.add_service(service) request.deploy_template(template)
def deploy_orion_docker(request, template_name): template = model.Template(template_name) net = model.Network("node-int-net-01", True) inst = model.Instance('ubuntu', 'Ubuntu14.04init_deprecated', '2', '', False, [net]) product = model.Product('docker', 'io.murano.apps.docker.DockerStandaloneHost') service = model.Service(product.name, product) service.add_instance(inst) atts = [] atts.append({'publish': True}) atts.append({'host': product.id}) product = model.Product('dockerorion', 'io.murano.apps.docker.DockerOrion', atts) service2 = model.Service(product.name, product) template.add_service(service) template.add_service(service2) request.deploy_template(template)