def test_cache_set_on_course_publish(self): """ Tests that the last published cache is set on course publish """ course_key = CourseKey.from_string('course-v1:org+course+run') last_published_cache = CourseLastPublishedCache() self.assertIsNone(last_published_cache.get(course_key)) _listen_for_course_publish(None, course_key) self.assertIsNotNone(last_published_cache.get(course_key))
def test_dump_to_neo4j_published(self): """ Tests that we only dump those courses that have been published after the last time the command was been run. """ mock_graph = mock.Mock() # run once to warm the cache successful, unsuccessful = self.mss.dump_courses_to_neo4j(mock_graph) self.assertEqual(len(successful + unsuccessful), len(self.course_strings)) # simulate one of the courses being published _listen_for_course_publish(None, self.course.id) # make sure only the published course was dumped successful, unsuccessful = self.mss.dump_courses_to_neo4j(mock_graph) self.assertEqual(len(unsuccessful), 0) self.assertEqual(len(successful), 1) self.assertEqual(successful[0], unicode(self.course.id))