Exemplo n.º 1
0
    def delete(self, id):
        """Deletes a selected project.
        """
        #TODO: check permisssions

        project = get_object_or_404(Project, id)

        comp_count = Session.query(Component).filter_by(project_id = id).count()
        if comp_count > 0:
            h.flash("Can't delete the project %s as it still \
                     contains components." % project.name)
            return redirect_to(controller='packages/product',
                               action='index',
                               id=project.product_id)

        name = project.name
        Session.begin()
        Session.delete(project)
        Session.commit()
        h.flash("The project <b>%s</b> has been deleted successfully" % \
                name)

        return redirect_to(controller='packages/product',
                           action='index',
                           id=project.product_id)
 def setUp(self):
     # TODO: this setup is better to move to common fixture
     Session.begin()
     for i in range(1, self.node_num + 1):
         product = Product("product%s" % i)
         for j in range(1, self.node_num + 1):
             if i == 2: # product without projects
                 continue
             project = Project("project%s.%s" % (i, j))
             for k in range(1, self.node_num + 1):
                 if j == 2: # project without components
                     continue
                 component = Component("component%s.%s.%s" % (i, j, k))
                 for l in range(1, self.node_num + 1):
                     if k == 2: # component without sources
                         continue
                     source = Source("source%s.%s.%s.%s" % (i, j, k, l))
                     for m in range(1, self.node_num + 1):
                         if l == 2: # source without binaries
                             continue
                         binary = Binary("binary%s.%s.%s.%s.%s" %
                                         (i, j, k, l, m))
                         source.binaries.append(binary)
                     component.sources.append(source)
                 project.components.append(component)
             product.projects.append(project)
         Session.add(product)
     Session.commit()
Exemplo n.º 3
0
 def setUp(self):
     Session.begin()
     queue = Queue('testqueue')
     queueoption1 = QueueOption('check', '+helloworld', 100)
     queue.allowed_options = "check, build-deb-package"
     queue.options.append(queueoption1)
     Session.add(queue)
     Session.commit()
     self.queue = queue
Exemplo n.º 4
0
def setUpModule():

    # add all the needed objects in DB
    Session.begin()
    product = Product("product1")
    project = Project("project1")
    component = Component("component1")
    project.components.append(component)
    product.projects.append(project)
    Session.add(product)
    Session.commit()
Exemplo n.º 5
0
    def submit_edit(self, id):
        """Processes edited product
        """

        product = get_object_or_404(Product, id)
        Session.begin()
        product.name = self.form_result['name']
        msg = "Product <b>%s</b> has been updated" % product.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/product', id=id)
Exemplo n.º 6
0
    def submit_add(self):
        """Processes new submitted product
        """
        
        Session.begin()
        product = Product(self.form_result['name'])
        Session.add(product)
        msg = "A new product <b>%s</b> has been added" % product.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/packages')
Exemplo n.º 7
0
    def submit_edit(self, id):
        """Processes edited source
        """

        source = get_object_or_404(Source, id)
        Session.begin()
        source.name = self.form_result["name"]
        msg = "Source package <b>%s</b> has been updated" % source.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller="packages/source", action="index", id=id)
Exemplo n.º 8
0
    def submit_binary(self, id):
        """Processes new submitted binary
        """

        source = get_object_or_404(Source, id)
        Session.begin()
        binary = Binary(self.form_result["name"])
        source.binaries.append(binary)
        msg = "A new binary <b>%s</b> has been added" % binary.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller="packages/source", action="index", id=id)
Exemplo n.º 9
0
    def submit_edit(self, id):
        """Processes edited binary
        """

        binary = get_object_or_404(Binary, id)
        Session.begin()
        binary.name = self.form_result['name']
        msg = "Binary package <b>%s</b> has been updated" % binary.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/binary',
                           action='index',
                           id=id)
Exemplo n.º 10
0
    def submit_source(self, id):
        """Processes new submitted source
        """

        component = get_object_or_404(Component, id)
        Session.begin()
        source = Source(self.form_result['name'])
        component.sources.append(source)
        msg = "A new source <b>%s</b> has been added" % source.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/component', 
                           action='index',
                           id=id)
Exemplo n.º 11
0
def setUpModule():

    # add all the needed objects in DB
    Session.begin()
    product = Product("product1")
    project = Project("project1")
    component = Component("component1")
    source = Source("source1")
    binary = Binary("binary")
    source.binaries.append(binary)
    component.sources.append(source)
    project.components.append(component)
    product.projects.append(project)
    Session.add(product)
    Session.commit()
Exemplo n.º 12
0
    def submit_edit(self, id):
        """Processes edited component
        """

        component = get_object_or_404(Component, id)
        Session.begin()
        component.name = self.form_result['name']
        component.description = self.form_result['description']
        msg = "Component <b>%s</b> has been updated" % component.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/component',
                           action='index',
                           id=id)
Exemplo n.º 13
0
    def submit_project(self, id):
        """Processes new submitted project
        """
        
        product = get_object_or_404(Product, id)
        Session.begin()
        project = Project(self.form_result['name'])
        product.projects.append(project)
        msg = "A new project <b>%s</b> has been added" % project.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/product', 
                           action='index',
                           id=id)
Exemplo n.º 14
0
    def submit_component(self, id):
        """Processes new submitted component
        """

        project = get_object_or_404(Project, id)
        Session.begin()
        component = Component(self.form_result['name'])
        component.description = self.form_result['description']
        project.components.append(component)
        msg = "A new component <b>%s</b> has been added" % component.name
        Session.commit()
        h.flash(msg)

        return redirect_to(controller='packages/project', 
                           action='index',
                           id=id)
Exemplo n.º 15
0
    def delete(self, id):
        """Deletes a selected binary.
        """
        #TODO: check permisssions

        binary = get_object_or_404(Binary, id)

        name = binary.name
        Session.begin()
        Session.delete(binary)
        Session.commit()
        h.flash("The binary package <b>%s</b> has been deleted successfully" % \
                name)

        return redirect_to(controller='packages/source',
                           action='index',
                           id=binary.source_id)
Exemplo n.º 16
0
def setUpModule():

    # add all the needed objects in DB
    Session.begin()
    product = Product("product1")
    product_to_edit = Product("product_to_edit")
    product_to_delete = Product("product_to_delete")
    project1 = Project("project1")
    project2 = Project("project2")
    component = Component("component1")
    project1.components.append(component)
    product.projects.append(project1)
    product.projects.append(project2)
    Session.add(product)
    Session.add(product_to_edit)
    Session.add(product_to_delete)
    Session.commit()
Exemplo n.º 17
0
    def test_delete(self):
        """ Test ProductController.delete action
        """

        product = Session.query(Product).\
                filter_by(name='product_to_delete').first()
        product_id = product.id
        response = self.app.post(url(controller='packages/product',
                                         action='delete',
                                         id=product_id))
        # Test response...
        assert response.status == 302, "Wrong response code"
        print "Location: ", response.header_dict['location']
        print "Expected location: ", url(controller='packages/packages', host='localhost'), \
                    "Wrong response location"
        assert response.header_dict['location'] == \
                url(controller='packages/packages', host='localhost'), \
                    "Wrong response location"
        # reset sqlalchemy cache
        Session.begin()
        Session.commit()
        count = Session.query(Product).\
                filter_by(name='product_to_delete').count()
        assert count == 0, "Product hasn't been deleted"

        # Try to delete product which has children
        product = Session.query(Product).\
                filter_by(name='product1').first()
        product_id = product.id
        response = self.app.post(url(controller='packages/product',
                                         action='delete',
                                         id=product_id))
        # Test response...
        assert response.status == 302, "Wrong response code"
        assert response.header_dict['location'] == \
                url(controller='packages/product',
                        host='localhost',
                        id=product_id), \
                    "Wrong response location"
        # reset sqlalchemy cache
        Session.begin()
        Session.commit()
        count = Session.query(Product).\
                filter_by(name='product1').count()
        assert count == 1, "Product has been deleted"
Exemplo n.º 18
0
    def get_tasks(self):
        """Return tasks created for Request instance.
        
        If tasks have not been created then process options
        with registered option handlers which create tasks
        according to provided options.
        """

        if self.tasks:
            return self.tasks

        generator = TaskGenerator()
        for opt, value in self.options:
            generator.process(opt, value)
        Session.begin()
        self.tasks = generator.out()
        Session.commit()
        return self.tasks
Exemplo n.º 19
0
    def delete(self, id):
        """Deletes a selected source.
        """
        # TODO: check permisssions

        source = get_object_or_404(Source, id)

        bin_count = Session.query(Binary).filter_by(source_id=id).count()
        if bin_count > 0:
            h.flash(
                "Can't delete the source %s as it still \
                     contains binaries."
                % source.name
            )
            return redirect_to(controller="packages/component", action="index", id=source.component_id)

        name = source.name
        Session.begin()
        Session.delete(source)
        Session.commit()
        h.flash("The source <b>%s</b> has been deleted successfully" % name)

        return redirect_to(controller="packages/component", action="index", id=source.component_id)
Exemplo n.º 20
0
 def test_submit_edit(self):
     """ Test ProductController.submit_edit action
     """
     product = Session.query(Product).\
             filter_by(name='product_to_edit').first()
     product_id = product.id
     response = self.app.post(url(controller='packages/product',
                                      action='submit_edit',
                                      id=product_id),
                              params={
                                 'name': 'product_new_name'
                              })
     # Test response...
     assert response.status == 302, "Wrong response code"
     assert response.header_dict['location'] == \
             url(controller='packages/product',
                     host='localhost',
                     id=product_id), \
                 "Wrong response location"
     # reset sqlalchemy cache
     Session.begin()
     Session.commit()
     product_n = Session.query(Product).filter_by(id=product_id).first()
     assert product_n.name == 'product_new_name', "Wrong product name"