I am writting some tests for our application and am not sure I am testing the correct thing here. This is my test.
def test_ReservationExtensionFalseWrongResource(self):
'does not create a reservation that is an extension if different resource'
try:
reservation1 = Reservation.objects.create(user=self.regularUser1, resource=self.resource1, modality=self.modality, timeFrom=datetime(2015, 6, 11, 20, tzinfo=pytz.utc), timeTo=datetime(2015, 6, 11, 21, tzinfo=pytz.utc), count=1, notes=None, extendedReservation=None)
reservation = create_reservation(self.regularUser2, self.regularUser2, None, self.resource2, self.modality, datetime(2015, 6, 11, 20, tzinfo=pytz.utc), datetime(2015, 6, 11, 21, tzinfo=pytz.utc), 1, reservation1.uuid)
self.assertTrue(False, "Should not create reservation")
except Exception, e:
self.assertTrue(True, "Not authorized")
I want to be sure that a reservation extension cannot be created if it is of a different resource, so this line should fail in the try block:
reservation = create_reservation(self.regularUser2, self.regularUser2, None, self.resource2, self.modality, datetime(2015, 6, 11, 20, tzinfo=pytz.utc), datetime(2015, 6, 11, 21, tzinfo=pytz.utc), 1, reservation1.uuid)
Does this:
self.assertTrue(False, "Should not create reservation")
Assert that the reservation creation resulted in a False value? Or am I understanding the assert matchers incorrectly. I have tried going over the documentation but I could not see any analogous example of something like this in a try catch block that was obvious to me.
Help is appreciated.
Aucun commentaire:
Enregistrer un commentaire