def test_basic_insert_nonunique(self):
        for (hostname, ip, port, cpus, ram, state, ram_allocation,
             cpu_allocation) in self.modelArguments(limit=1):
            modelA = Agent()
            modelA.hostname = hostname
            modelA.ip = ip
            modelA.port = port
            modelB = Agent()
            modelB.hostname = hostname
            modelB.ip = ip
            modelB.port = port
            db.session.add(modelA)
            db.session.add(modelB)

            with self.assertRaises(DatabaseError):
                db.session.commit()

            db.session.rollback()
    def test_basic_insert_nonunique(self):
        for (hostname, ip, port, cpus, ram, state,
             ram_allocation, cpu_allocation) in self.modelArguments(limit=1):
            modelA = Agent()
            modelA.hostname = hostname
            modelA.ip = ip
            modelA.port = port
            modelB = Agent()
            modelB.hostname = hostname
            modelB.ip = ip
            modelB.port = port
            db.session.add(modelA)
            db.session.add(modelB)

            with self.assertRaises(DatabaseError):
                db.session.commit()

            db.session.rollback()
Ejemplo n.º 3
0
 def models(self, limit=None):
     """
     Iterates over the class level variables and produces an agent
     model.  This is done so that we test endpoints in the extreme ranges.
     """
     generator = self.modelArguments(limit=limit)
     for (hostname, ip, port, cpus, ram, state, ram_allocation,
          cpu_allocation) in generator:
         agent = Agent()
         agent.hostname = hostname
         agent.remote_ip = ip
         agent.port = port
         agent.cpus = cpus
         agent.free_ram = agent.ram = ram
         agent.state = state
         agent.ram_allocation = ram_allocation
         agent.cpu_allocation = cpu_allocation
         yield agent
Ejemplo n.º 4
0
 def models(self, limit=None):
     """
     Iterates over the class level variables and produces an agent
     model.  This is done so that we test endpoints in the extreme ranges.
     """
     generator = self.modelArguments(limit=limit)
     for (hostname, ip, port, cpus, ram, state,
          ram_allocation, cpu_allocation) in generator:
         agent = Agent()
         agent.hostname = hostname
         agent.remote_ip = ip
         agent.port = port
         agent.cpus = cpus
         agent.free_ram = agent.ram = ram
         agent.state = state
         agent.ram_allocation = ram_allocation
         agent.cpu_allocation = cpu_allocation
         yield agent