def test_get_set_course_tag(self): # get a tag that doesn't exist tag = course_tag_api.get_course_tag(self.user, self.course_id, self.test_key) self.assertIsNone(tag) # test setting a new key test_value = 'value' course_tag_api.set_course_tag(self.user, self.course_id, self.test_key, test_value) tag = course_tag_api.get_course_tag(self.user, self.course_id, self.test_key) self.assertEqual(tag, test_value) #test overwriting an existing key test_value = 'value2' course_tag_api.set_course_tag(self.user, self.course_id, self.test_key, test_value) tag = course_tag_api.get_course_tag(self.user, self.course_id, self.test_key) self.assertEqual(tag, test_value)
def get_tag(self, scope, key): """ Get a user tag for the current course and the current user for a given key scope: the current scope of the runtime key: the key for the value we want """ if scope != user_course_tag_api.COURSE_SCOPE: raise ValueError("unexpected scope {0}".format(scope)) return user_course_tag_api.get_course_tag(self._get_current_user(), self.runtime.course_id, key)
def get_tag(self, scope, key): """ Get a user tag for the current course and the current user for a given key scope: the current scope of the runtime key: the key for the value we want """ if scope != user_course_tag_api.COURSE_SCOPE: raise ValueError("unexpected scope {0}".format(scope)) return user_course_tag_api.get_course_tag( self._get_current_user(), self.runtime.course_id, key )