def test_units_update(self): self.update() # Count how many units are in the table before update count = self.session.scalar("SELECT COUNT(*) FROM keemu.stratigraphic_unit") self.create() after_update_count = self.session.scalar("SELECT COUNT(*) FROM keemu.stratigraphic_unit") # Should be the same even though values have changed: unit names stay once entered self.assertEquals(count, after_update_count) obj = self.query().one() # Count all variations of unit types - we should have all of them count = 0 # We've remove Biostratigraphy for testing del STRATIGRAPHIC_UNIT_TYPES["Biostratigraphy"] for group in STRATIGRAPHIC_UNIT_TYPES.values(): for unit_type in group: for direction in ["To", "From"]: count += 1 self.assertEqual(len(obj.stratigraphic_unit), count) # Check we have the values correct (they were all generated to be type_direction: epoch_from for unit in obj.stratigraphic_unit: value = "{}_{}".format(unit.stratigraphic_type, unit.direction) self.assertEquals(unit.unit.name, value) self.delete()
def test_units(self): self.create() obj = self.query().one() # Count all variations of unit types - we should have all of them count = 0 for group in STRATIGRAPHIC_UNIT_TYPES.values(): for unit_type in group: for direction in ["To", "From"]: count += 1 self.assertEqual(len(obj.stratigraphic_unit), count) # Check we have the values correct (they were all generated to be type_direction: epoch_from for unit in obj.stratigraphic_unit: value = "{}_{}".format(unit.stratigraphic_type, unit.direction) self.assertEquals(unit.unit.name, value) self.delete()