def test_has_sub_sections_should_return_false_if_backend_has_no_sections( self): backend = Backend() for s in backend.sections: s.sections = [] backend_view = BackendView(backend, backend.sections, None, None) self.assertFalse(backend_view.has_sub_sections)
def test_get_url_for_model_should_return_none_if_model_not_found(self): backend_view = BackendView(self.backend, self.backend.sections, None, None) self.assertIsNone(backend_view.get_url_for_model(User))
def test_get_url_for_model_should_return_backend_url_for_given_model(self): backend_view = BackendView(self.backend, self.backend.sections, None, None) self.assertEqual('/admin/test-models/', backend_view.get_url_for_model(TestModel))
def test_title_should_return_title_of_current_section_if_no_sub_section_is_available( self): section = self.backend.get_section_by_class(AccountBackendSection) backend_view = BackendView(self.backend, self.backend.sections, section, None) self.assertEqual(section.title, backend_view.title)
def test_title_should_return_title_of_current_sub_section(self): section = self.backend.get_section_by_class(AccountBackendSection) subsection = section.get_section_by_class(AccountBackendSubSection) backend_view = BackendView(self.backend, self.backend.sections, section, subsection) self.assertEqual(subsection.title, backend_view.title)
def test_current_sub_section_should_return_current_section_none(self): backend_view = BackendView(self.backend, self.backend.sections, None, None) self.assertIsNone(backend_view.current_sub_section)
def test_current_section_should_return_current_section(self): section = self.backend.get_section_by_class(AccountBackendSection) backend_view = BackendView(self.backend, self.backend.sections, section, None) self.assertEqual(section, backend_view.current_section)
def test_has_sub_sections_should_return_true_if_backend_has_sections(self): backend_view = BackendView(self.backend, self.backend.sections, None, None) self.assertTrue(backend_view.has_sub_sections)
def test_sections_property_should_return_backend_sections(self): backend = Backend() backend_view = BackendView(backend, backend.sections, None, None) self.assertEqual(backend._sections, backend_view.sections) backend._sections = [] self.assertEqual([], backend_view.sections)
def test_default_map_location_json_should_return_default_map_location_from_settings( self): backend_view = BackendView(self.backend, self.backend.sections, None, None) self.assertEqual(to_json(settings.DEFAULT_MAP_LOCATION), backend_view.default_map_location_json)
def test_url_property_should_return_backend_url(self): backend_view = BackendView(self.backend, self.backend.sections, None, None) self.assertEqual('/admin/', backend_view.url)
def test_site_property_should_return_backend(self): backend_view = BackendView(self.backend, self.backend.sections, None, None) self.assertEqual(self.backend, backend_view.site)