def get_all_topic_assignments_for_skill(skill_id): """Returns a list containing all the topics to which the given skill is assigned along with topic details. Args: skill_id: str. ID of the skill. Returns: list(TopicAssignment). A list of TopicAssignment domain objects. """ topic_assignments = [] topics = topic_fetchers.get_all_topics() for topic in topics: if skill_id in topic.get_all_skill_ids(): subtopic_id = None for subtopic in topic.subtopics: if skill_id in subtopic.skill_ids: subtopic_id = subtopic.id break topic_assignments.append( skill_domain.TopicAssignment(topic.id, topic.name, topic.version, subtopic_id)) return topic_assignments
def setUp(self): super(TopicAssignmentTests, self).setUp() self.topic_assignments = skill_domain.TopicAssignment( 'topic_id1', 'Topic1', 2, 1)