def test_items(self, mock_find_active_allocations): request0 = AllocationRequest(project_name="Project X", status="E") request1 = AllocationRequest(project_name="Project Y", status="X") expected_items = [request0, request1] mock_find_active_allocations.return_value = expected_items site_map = AllocationsSitemap() actual_items = site_map.items() self.assertListEqual(expected_items, actual_items)
def test_location(self): request0 = AllocationRequest(project_name="Project X", status="E") request0.id = 12345 site_map = AllocationsSitemap() actual_location = site_map.location(request0) expected_location = '/allocations/applications/12345/approved' self.assertEquals(expected_location, actual_location)
def test_lastmod(self): expected_datetime = datetime(2014, 10, 13) request0 = AllocationRequest(project_name="Project X", status="E") request0.modified_time = expected_datetime site_map = AllocationsSitemap() actual_modification_datetime = site_map.lastmod(request0) self.assertEquals(expected_datetime, actual_modification_datetime)
def test_find_active_allocations_excluding_3_null_fors(self): request0 = AllocationRequest(project_name='Project0', status='A') request0.field_of_research_1 = None request0.field_of_research_2 = None request0.field_of_research_3 = None request0.save() allocations = AllocationRequest.find_active_allocations() self.assertEquals(2, len(allocations))
def test_find_active_allocations_including_new_requests(self): request0 = AllocationRequest(project_name='Project0', status='A') request0.field_of_research_1 = '11' request0.field_of_research_2 = '22' request0.field_of_research_3 = '33' request0.save() allocations = AllocationRequest.find_active_allocations() self.assertEquals(3, len(allocations))
def setUp(self): self.request0 = AllocationRequest(project_name="Project X", status="E") self.request1 = AllocationRequest(project_name="Project Y", status="X") self.old_organise_allocations_tree = \ AllocationRequest.organise_allocations_tree AllocationRequest.organise_allocations_tree = organise_allocations_tree