Ejemplo n.º 1
0
 def test_position_conversion(self):
     """
     Tests that a position becomes the correct address
     """
     pos1 = (3, 4, 1, 2, 81)
     addr1 = getaddress(pos1)
     self.assertEqual(addr1, 0x0304010251)
Ejemplo n.º 2
0
 def save(self, *args, **kwargs):
     """
     Override save such that creation of a freezer generates samplelocation
     entries corresponding to the freezer.
     """
     self.occupied = 0
     self.unoccupied = (self.shelf_capacity *
                        self.rack_capacity *
                        self.drawer_capacity *
                        self.box_capacity *
                        self.cell_capacity)
     self.percent_free = 0.0
     super(Freezer, self).save(*args, **kwargs)
     cur = connection.cursor()
     t = [(False, self.id, getaddress((s, r, d, b, c)),
           self.box_width, self.cell_capacity)
          for s in xrange(1, self.shelf_capacity + 1)
          for r in xrange(1, self.rack_capacity + 1)
          for d in xrange(1, self.drawer_capacity + 1)
          for b in xrange(1, self.box_capacity + 1)
          for c in xrange(1, self.cell_capacity + 1)]
     cur.executemany("""INSERT INTO freezers_samplelocation (occupied,
         freezer_id, address, box_width, cell_capacity)
         values (%s, %s, %s, %s, %s)""", t)
     transaction.commit()