def test_is_feature_enabled(self): request = RequestFactory().get('/') request.user = AnonymousUser() # Return True if no switch or flag are provided self.assertTrue( utils.is_feature_enabled({ 'switch': None, 'flag': None }, request)) name = 'test-waffle' item = {'switch': 'test-waffle'} # Return False if switch inactive with override_switch(name, active=False): self.assertFalse(utils.is_feature_enabled(item, request)) # Return True if switch active with override_switch(name, active=True): self.assertTrue(utils.is_feature_enabled(item, request)) item = {'flag': 'test-waffle'} # Return False if flag inactive with override_flag(name, active=False): self.assertFalse(utils.is_feature_enabled(item, request)) # Return True if flag active with override_flag(name, active=True): self.assertTrue(utils.is_feature_enabled(item, request))
def test_is_feature_enabled(self): request = RequestFactory().get('/') request.user = AnonymousUser() # Return True if no switch or flag are provided self.assertTrue(utils.is_feature_enabled({'switch': None, 'flag': None}, request)) name = 'test-waffle' item = {'switch': 'test-waffle'} # Return False if switch inactive with override_switch(name, active=False): self.assertFalse(utils.is_feature_enabled(item, request)) # Return True if switch active with override_switch(name, active=True): self.assertTrue(utils.is_feature_enabled(item, request)) item = {'flag': 'test-waffle'} # Return False if flag inactive with override_flag(name, active=False): self.assertFalse(utils.is_feature_enabled(item, request)) # Return True if flag active with override_flag(name, active=True): self.assertTrue(utils.is_feature_enabled(item, request))
def test_is_feature_enabled(self): name = 'test-switch' item = {'switch': name} # Return True if no switch provided self.assertTrue(utils.is_feature_enabled({'switch': None})) # Return False if switch inactive switch = Switch.objects.create(name=name, active=False) self.assertFalse(utils.is_feature_enabled(item)) # Return True if switch active switch.active = True switch.save() self.assertTrue(utils.is_feature_enabled(item))
def test_is_feature_enabled(self): name = 'test-switch' item = {'switch': name} # Return True if no switch provided self.assertTrue(utils.is_feature_enabled({'switch': None})) # Return False if switch inactive switch = Switch.objects.create(name=name, active=False) self.assertFalse(utils.is_feature_enabled(item)) # Return True if switch active switch.active = True switch.save() self.assertTrue(utils.is_feature_enabled(item))
def get_primary_nav_items(self, request): """ Return the primary nav items. """ items = [{ 'name': 'enrollment', 'text': ugettext_noop('Enrollment'), 'view': 'courses:enrollment:activity', 'icon': 'fa-child', 'fragment': '', 'scope': 'course', 'lens': 'enrollment', 'report': 'activity', 'depth': '' }, { 'name': 'engagement', 'text': ugettext_noop('Engagement'), 'view': 'courses:engagement:content', 'icon': 'fa-bar-chart', 'fragment': '', 'scope': 'course', 'lens': 'engagement', 'report': 'content', 'depth': '' }, { 'name': 'performance', 'text': ugettext_noop('Performance'), 'view': 'courses:performance:graded_content', 'icon': 'fa-check-square-o', 'switch': 'enable_course_api', 'fragment': '', 'scope': 'course', 'lens': 'performance', 'report': 'graded', 'depth': '' }, { 'name': 'learners', 'text': ugettext_noop('Learners'), 'view': 'courses:learners:learners', 'icon': 'fa-users', 'flag': 'display_learner_analytics', 'fragment': '#?ignore_segments=inactive', 'scope': 'course', 'lens': 'learners', 'report': 'roster', 'depth': '' }] translate_dict_values(items, ('text', )) # Remove disabled items items = [item for item in items if is_feature_enabled(item, request)] # Clean each item map(self.clean_item, items) return items
def _build_nav_items(self, nav_items, active_item, request): # Deep copy the list since it is a list of dictionaries items = copy.deepcopy(nav_items) # Process only the nav items that are enabled items = [item for item in items if is_feature_enabled(item, request)] for item in items: item['active'] = active_item == item['name'] self.clean_item(item) return items
def _build_nav_items(self, nav_items, active_item, request): # Deep copy the list since it is a list of dictionaries items = copy.deepcopy(nav_items) # Process only the nav items that are enabled items = [item for item in items if is_feature_enabled(item, request)] for item in items: item['active'] = active_item == item['name'] self.clean_item(item) return items
def get_primary_nav_items(self, request): """ Return the primary nav items. """ items = [{ 'name': 'enrollment', 'label': _('Enrollment'), 'view': 'courses:enrollment:activity', 'icon': 'fa-child', 'fragment': '' }, { 'name': 'engagement', 'label': _('Engagement'), 'view': 'courses:engagement:content', 'icon': 'fa-bar-chart', 'fragment': '' }, { 'name': 'performance', 'label': _('Performance'), 'view': 'courses:performance:graded_content', 'icon': 'fa-check-square-o', 'switch': 'enable_course_api', 'fragment': '' }, { 'name': 'learners', 'label': _('Learners'), 'view': 'courses:learners:learners', 'icon': 'fa-users', 'flag': 'display_learner_analytics', 'fragment': '#?ignore_segments=inactive' }] # Remove disabled items items = [item for item in items if is_feature_enabled(item, request)] # Clean each item map(self.clean_item, items) return items
def get_primary_nav_items(self, request): """ Return the primary nav items. """ items = [ { 'name': 'enrollment', 'text': ugettext_noop('Enrollment'), 'view': 'courses:enrollment:activity', 'icon': 'fa-child', 'fragment': '', 'scope': 'course', 'lens': 'enrollment', 'report': 'activity', 'depth': '' }, { 'name': 'engagement', 'text': ugettext_noop('Engagement'), 'view': 'courses:engagement:content', 'icon': 'fa-bar-chart', 'fragment': '', 'scope': 'course', 'lens': 'engagement', 'report': 'content', 'depth': '' }, { 'name': 'performance', 'text': ugettext_noop('Performance'), 'view': 'courses:performance:graded_content', 'icon': 'fa-check-square-o', 'switch': 'enable_course_api', 'fragment': '', 'scope': 'course', 'lens': 'performance', 'report': 'graded', 'depth': '' }, { 'name': 'learners', 'text': ugettext_noop('Learners'), 'view': 'courses:learners:learners', 'icon': 'fa-users', 'flag': 'display_learner_analytics', 'fragment': '#?ignore_segments=inactive', 'scope': 'course', 'lens': 'learners', 'report': 'roster', 'depth': '' } ] translate_dict_values(items, ('text',)) # Remove disabled items items = [item for item in items if is_feature_enabled(item, request)] # Clean each item map(self.clean_item, items) return items