def test_common(self): """Verify that the common() function returns the correct values.""" cfg.read() # initialize config settings request = HttpRequest() request.path = '/aaa/bbb/ccc/' request.user = Mock() request.user.groups.filter().exists = Mock(return_value=True) response = cp.common(request) self.assertIsNotNone(response) config = response['cfg'] self.assertIsNotNone(config) self.assertEqual('FreedomBox', config.box_name) self.assertEqual('FreedomBox', response['box_name']) submenu = response['submenu'] self.assertIsNone(submenu) urls = response['active_menu_urls'] self.assertIsNotNone(urls) self.assertEqual(['/', '/aaa/', '/aaa/bbb/', '/aaa/bbb/ccc/'], urls) self.assertTrue(response['user_is_admin']) request.user.groups.filter().exists = Mock(return_value=False) response = cp.common(request) self.assertFalse(response['user_is_admin'])
def test_common_border_conditions(self): """Verify that the common() function works for border conditions.""" request = HttpRequest() request.path = '' response = cp.common(request) self.assertEqual([], response['active_menu_urls']) request.path = '/' response = cp.common(request) self.assertEqual(['/'], response['active_menu_urls']) request.path = '/aaa/bbb' response = cp.common(request) self.assertEqual(['/', '/aaa/'], response['active_menu_urls'])
def test_common(Notification, load_cfg): """Verify that the common() function returns the correct values.""" request = HttpRequest() request.path = '/aaa/bbb/ccc/' request.user = Mock() request.user.groups.filter().exists = Mock(return_value=True) request.session = MagicMock() response = cp.common(request) assert response is not None config = response['cfg'] assert config is not None assert config.box_name == 'FreedomBox' assert response['box_name'] == 'FreedomBox' submenu = response['submenu'] assert submenu is None urls = response['active_menu_urls'] assert urls is not None assert ['/', '/aaa/', '/aaa/bbb/', '/aaa/bbb/ccc/'] == urls assert response['user_is_admin']
def test_common_border_conditions(self): """Verify that the common() function works for border conditions.""" request = HttpRequest() request.path = '' request.user = Mock() request.user.groups.filter().exists = Mock(return_value=True) response = cp.common(request) self.assertEqual([], response['active_menu_urls']) request.path = '/' response = cp.common(request) self.assertEqual(['/'], response['active_menu_urls']) request.path = '/aaa/bbb' response = cp.common(request) self.assertEqual(['/', '/aaa/'], response['active_menu_urls'])
def test_common(self): """Verify that the common() function returns the correct values.""" cfg.read() # initialize config settings request = HttpRequest() request.path = '/aaa/bbb/ccc/' request.user = Mock() request.user.groups.filter().exists = Mock(return_value=True) request.session = MagicMock() response = cp.common(request) self.assertIsNotNone(response) config = response['cfg'] self.assertIsNotNone(config) self.assertEqual('FreedomBox', config.box_name) self.assertEqual('FreedomBox', response['box_name']) submenu = response['submenu'] self.assertIsNone(submenu) urls = response['active_menu_urls'] self.assertIsNotNone(urls) self.assertEqual(['/', '/aaa/', '/aaa/bbb/', '/aaa/bbb/ccc/'], urls) self.assertTrue(response['user_is_admin'])
def test_common_border_conditions(Notification): """Verify that the common() function works for border conditions.""" request = HttpRequest() request.path = '' request.user = Mock() request.user.groups.filter().exists = Mock(return_value=True) request.session = MagicMock() response = cp.common(request) assert response['active_menu_urls'] == [] request.path = '/' response = cp.common(request) assert response['active_menu_urls'] == ['/'] request.path = '/aaa/bbb' response = cp.common(request) assert response['active_menu_urls'] == ['/', '/aaa/']
def test_common_border_conditions(self): """Verify that the common() function works for border conditions.""" request = HttpRequest() request.path = '' request.user = Mock() request.user.groups.filter().exists = Mock(return_value=True) request.session = MagicMock() response = cp.common(request) self.assertEqual([], response['active_menu_urls']) request.path = '/' response = cp.common(request) self.assertEqual(['/'], response['active_menu_urls']) request.path = '/aaa/bbb' response = cp.common(request) self.assertEqual(['/', '/aaa/'], response['active_menu_urls'])
def test_common(self): """Verify that the 'common' function returns the correct values.""" request = HttpRequest() request.path = '/aaa/bbb/ccc/' response = cp.common(request) self.assertIsNotNone(response) config = response['cfg'] self.assertIsNotNone(config) self.assertEqual('Plinth', config.product_name) self.assertEqual('FreedomBox', config.box_name) submenu = response['submenu'] self.assertIsNone(submenu) urls = response['active_menu_urls'] self.assertIsNotNone(urls) self.assertEqual(['/', '/aaa/', '/aaa/bbb/', '/aaa/bbb/ccc/'], urls)
def test_common(self): """Verify that the common() function returns the correct values.""" cfg.read() # initialize config settings request = HttpRequest() request.path = '/aaa/bbb/ccc/' response = cp.common(request) self.assertIsNotNone(response) config = response['cfg'] self.assertIsNotNone(config) self.assertEqual('FreedomBox', config.box_name) self.assertEqual('FreedomBox', response['box_name']) submenu = response['submenu'] self.assertIsNone(submenu) urls = response['active_menu_urls'] self.assertIsNotNone(urls) self.assertEqual(['/', '/aaa/', '/aaa/bbb/', '/aaa/bbb/ccc/'], urls)