def tests_commute_information_missing_max_commute_not_work_from_home(self): """ Tests that if max_commute is missing and the commute type is not work from home then the form returns False """ commute_types = [self.driving, self.transit, self.walking, self.bicycling] result = True for commute_type in commute_types: # Arrange form_data = { 'min_commute': self.min_commute, 'commute_weight': self.commute_weight, 'commute_type': commute_type.pk, 'street_address': "Test Address", 'city': 'test city', 'state': 'test state', 'zip_code': 'test zip_code', } commute_information_form = CommuteInformationForm(data=form_data) # Act result = commute_information_form.is_valid() and result # Assert self.assertFalse(result)
def tests_commute_information_max_commute_less_than_min_commute_not_work_from_home(self): """ Tests that if the max_commute is less than min_commute and the commute types is not work from home then valid is false """ commute_types = [self.driving, self.transit, self.walking, self.bicycling] result = True for commute_type in commute_types: # Arrange form_data = { 'max_commute': 1, 'desired_commute': 2, 'commute_weight': 1, 'commute_type': commute_type.pk, 'street_address': "Test Address", 'city': 'test city', 'state': 'test state', 'zip_code': 'test zip_code', } commute_information_form = CommuteInformationForm(data=form_data) # Act result = commute_information_form.is_valid() and result # Assert self.assertFalse(result)
def tests_commute_information_valid_not_work_from_home(self): """ Tests that given all the required fields the commute form validates for all the commute types besides work from home """ commute_types = [self.driving, self.transit, self.walking, self.bicycling] result = True for commute_type in commute_types: # Arrange form_data = { 'max_commute': self.max_commute, 'min_commute': self.min_commute, 'commute_weight': self.commute_weight, 'commute_type': commute_type.pk, 'street_address': "Test Address", 'city': 'test city', 'state': 'test state', 'zip_code': 'test zip_code', } commute_information_form = CommuteInformationForm(data=form_data) # Act result = commute_information_form.is_valid() and result # Assert self.assertTrue(result)
def tests_commute_information_valid_work_from_home(self): """ Tests that work from home doesn't need any other fields to validate """ # Arrange form_data = { 'commute_type': self.work_from_home.pk, } commute_information_form = CommuteInformationForm(data=form_data) # Act result = commute_information_form.is_valid() # Assert self.assertTrue(result)