def test_model_train_duplicate(self): train = Train(name='t1', from_city=self.city_A, to_city=self.city_B, travel_time=111) with self.assertRaises(ValidationError): train.full_clean()
def test_model_train_duplicate(self): '''Тестирование при возникновении ошибок при создании дупликата поезда''' train = Train(name='t165', from_city=self.city_A, to_city=self.city_B, travel_time=129) with self.assertRaises(ValidationError): train.full_clean()
def test_model_train_duplicate(self): '''Testing Trains for doppelgangers (testing for and to city parameters)''' train = Train(name='t1', from_city=self.city_A, to_city=self.city_B, travel_time=228) with self.assertRaises(ValidationError): train.full_clean()
def test_modul_train_dublicate(self): # Тестирование возникновения ошибки при создании дубля поезда train = Train(name='t1', from_city=self.city_A, to_city=self.city_B, travel_time=129) with self.assertRaises(ValidationError): train.full_clean()
def test_model_train_train_duplicate(self): train = Train(name='t1234', from_city=self.city_A, to_city=self.city_B, travel_time=9) with self.assertRaises(ValidationError): train.full_clean() try: train.full_clean() except ValidationError as e: self.assertEqual({'__all__': ['Change the travel time']}, e.message_dict) self.assertIn('Change the travel time', e.messages)
def test_model_train_train2_duplicate(self): '''Тестирование при возникновении ошибок при создании дупликата поезда''' train = Train(name='t15', from_city=self.city_A, to_city=self.city_B, travel_time=9) with self.assertRaises(ValidationError): train.full_clean() try: train.full_clean() except ValidationError as e: self.assertEqual({'__all__': ['Измените время в пути']}, e.message_dict) self.assertIn('Измените время в пути', e.message)
def test_modul_train_train_dublicate(self): # Тестирование возникновения ошибки при дублировании времени train = Train(name='t1234', from_city=self.city_A, to_city=self.city_B, travel_time=9) with self.assertRaises(ValidationError): train.full_clean() try: train.full_clean() except ValidationError as e: self.assertEqual({'__all__': ['Измените время в пути']}, e.message_dict) self.assertIn('Измените время в пути', e.messages)
def test_model_train_time(self): '''Тестирование возникновения ошибки времени в пути поезда''' train = Train(name='t153', from_city=self.city_A, to_city=self.city_B, travel_time=9) with self.assertRaises(ValidationError): train.full_clean() try: train.full_clean() except ValidationError as e: self.assertEqual({'__all__': ['Нужно изменить время в пути']}, e.message_dict) self.assertIn('Нужно изменить время в пути', e.messages)
def test_model_train_time_duplicate(self): '''Testing Trains for doppelgangers (testing travel time)''' train = Train(name='t1', from_city=self.city_A, to_city=self.city_B, travel_time=228) with self.assertRaises(ValidationError): train.full_clean() try: train.full_clean() except ValidationError as err: self.assertEqual( {'name': ['Train with this Train already exists.']}, err.message_dict) self.assertIn('Train with this Train already exists.', err.messages)
def index(request): error_messages = None if request.method == 'POST': try: train = Train(description = request.POST['description'], username = request.POST['username'], departure = request.POST['departure'], status = Status.objects.get(name = 'scheduled')) train.full_clean() if train.departure < datetime.now(): exception = ValidationError('Departure should be in future') raise exception train.save() return redirect(reverse('trains.views.view', kwargs = { 'train_id': train.pk })) except ValidationError, error: error_messages = error.messages
def test_model_train_duplicate(self): try: train = Train(name='t2', from_city=self.city_B, to_city=self.city_D, travel_time=4) train.full_clean() except ValidationError as e: self.assertEqual( {'name': ['Поезд with this Номер поезда already exists.']}, e.message_dict) try: train = Train(name='t12', from_city=self.city_B, to_city=self.city_D, travel_time=8) train.full_clean() except ValidationError as e: self.assertEqual({'__all__': ['Измените время в пути']}, e.message_dict)
def test_model_train_duplicate(self): try: train = Train(name='t2', from_city=self.city_B, to_city=self.city_D, travel_time=4) train.full_clean() except ValidationError as e: self.assertEqual( {'name': ['Потяг with this Номер потягу already exists.']}, e.message_dict) try: train = Train(name='t12', from_city=self.city_B, to_city=self.city_D, travel_time=8) train.full_clean() except ValidationError as e: self.assertEqual({'__all__': ['Виправте час в дорозі']}, e.message_dict)
def test_model_train_duplicate(self): # функция проверки дублирования номеров поездов try: train = Train(name='t2', from_city=self.city_B, to_city=self.city_D, travel_time=4) train.full_clean() except ValidationError as e: self.assertEqual( {'name': ['Поезд with this Номер поезда already exists.']}, e.message_dict) # функция проверки дублирования времени поездов при одоинаковых городах try: train = Train(name='t12', from_city=self.city_B, to_city=self.city_D, travel_time=8) train.full_clean() except ValidationError as e: self.assertEqual({'__all__': ['Измените время в пути']}, e.message_dict)