'Tests various combinations of a flag being set in waffle and overridden
for a course.'

@ddt.data({'course_override': WaffleFlagCourseOverrideModel.ALL_CHOICES.on, 'waffle_enabled': False, 'result': True}, {'course_override': WaffleFlagCourseOverrideModel.ALL_CHOICES.off, 'waffle_enabled': True, 'result': False}, {'course_override': WaffleFlagCourseOverrideModel.ALL_CHOICES.unset, 'waffle_enabled': True, 'result': True}, {'course_override': WaffleFlagCourseOverrideModel.ALL_CHOICES.unset, 'waffle_enabled': False, 'result': False})
def test_course_waffle_flag(self, data):

    RequestCache.clear_request_cache()
    with patch.object(WaffleFlagCourseOverrideModel, 'override_value', return_value=data['course_override']):
        with override_flag(self.NAMESPACED_FLAG_NAME, active=data['waffle_enabled']):
            self.assertEqual(self.TEST_COURSE_FLAG.is_enabled(self.TEST_COURSE_KEY), data['result'])
            self.assertEqual(self.TEST_COURSE_FLAG.is_enabled(self.TEST_COURSE_KEY), data['result'])
            WaffleFlagCourseOverrideModel.override_value.assert_called_once_with(self.NAMESPACED_FLAG_NAME, self.TEST_COURSE_KEY)
    if (data['course_override'] == WaffleFlagCourseOverrideModel.ALL_CHOICES.unset):
        self.assertEqual(self.TEST_COURSE_FLAG.is_enabled(self.TEST_COURSE_2_KEY), data['waffle_enabled'])
    else:
        self.assertEqual(self.TEST_COURSE_FLAG.is_enabled(self.TEST_COURSE_2_KEY), False)
