'Test that the correct things have been published automatically
Assumptions:
* we auto-publish courses, chapters, sequentials
* we don\'t auto-publish problems'

@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
def test_auto_publish(self, default_ms):

    self.initdb(default_ms)
    test_course = self.store.create_course('testx', 'GreekHero', 'test_run', self.user_id)
    self.assertTrue(self.store.has_published_version(test_course))
    test_course_key = test_course.id
    chapter = self.store.create_child(self.user_id, test_course.location, 'chapter', 'Overview')
    with self.store.branch_setting(ModuleStoreEnum.Branch.published_only):
        self.assertIn(chapter.location, self.store.get_item(test_course.location).children)
    self.assertTrue(self.store.has_published_version(chapter))
    chapter_location = chapter.location
    sequential = self.store.create_child(self.user_id, chapter_location, 'sequential', 'Sequence')
    with self.store.branch_setting(ModuleStoreEnum.Branch.published_only):
        self.assertIn(sequential.location, self.store.get_item(chapter_location).children)
    self.assertTrue(self.store.has_published_version(sequential))
    sequential.display_name = 'sequential1'
    sequential = self.store.update_item(sequential, self.user_id)
    self.assertTrue(self.store.has_published_version(sequential))
    self.store.delete_item(sequential.location, self.user_id, revision=ModuleStoreEnum.RevisionOption.all)
    with self.store.branch_setting(ModuleStoreEnum.Branch.published_only):
        self.assertNotIn(sequential.location, self.store.get_item(chapter_location).children)
    chapter = self.store.get_item(chapter.location.for_branch(None))
    self.assertTrue(self.store.has_published_version(chapter))
    problem_child = self.store.create_child(self.user_id, chapter_location, 'problem', 'Problem_Child')
    self.assertFalse(self.store.has_published_version(problem_child))
    problem_item = self.store.create_item(self.user_id, test_course_key, 'problem', 'Problem_Item')
    self.assertFalse(self.store.has_published_version(problem_item))
    problem_item.display_name = 'Problem_Item1'
    problem_item = self.store.update_item(problem_item, self.user_id)
    self.assertFalse(self.store.has_published_version(problem_item))
    self.store.delete_item(problem_child.location, self.user_id)
    chapter = self.store.get_item(chapter.location.for_branch(None))
    self.assertTrue(self.store.has_published_version(chapter))
