def test_capacity_construction_exceptions(self):

        dp = DropPoint(1, lat=0, lng=0, level=1)

        with self.assertRaisesRegexp(ValueError, "drop point"):
            Capacity("foo")

        time_in_future = datetime.today() + timedelta(hours=1)

        with self.assertRaisesRegexp(ValueError, "future"):
            Capacity(dp, time_in_future)

        with self.assertRaisesRegexp(ValueError, "not a datetime"):
            Capacity(dp, "foo")

        start_time = datetime.today()

        with self.assertRaisesRegexp(ValueError, "older than current"):
            Capacity(dp, time=start_time)
            db.session.commit()
            Capacity(dp, time=start_time - timedelta(hours=1))

        invalid_crate_counts = (-1, "some")

        for count in invalid_crate_counts:
            with self.assertRaisesRegexp(ValueError, "count"):
                Capacity(dp, crates=count)
dataset/ETHPy150Open der-michik/c3bottles/test_model.py/C3bottlesModelTestCase.test_capacity_construction_exceptions/original