'Test \'force_publish\' command'

def test_force_publish(self):

    chapter = ItemFactory.create(category='chapter', parent_location=self.course.location)
    self.store.create_child(self.test_user_id, chapter.location, 'html', block_id='html_component')
    self.assertTrue(self.store.has_changes(self.store.get_item(self.course.location)))
    versions = get_course_versions(unicode(self.course.id))
    draft_version = versions['draft-branch']
    published_version = versions['published-branch']
    self.assertNotEqual(draft_version, published_version)
    with mock.patch('contentstore.management.commands.force_publish.query_yes_no') as patched_yes_no:
        patched_yes_no.return_value = True
        call_command('force_publish', unicode(self.course.id), '--commit')
        self.assertFalse(self.store.has_changes(self.store.get_item(self.course.location)))
        versions = get_course_versions(unicode(self.course.id))
        new_draft_version = versions['draft-branch']
        new_published_version = versions['published-branch']
        self.assertEqual(draft_version, new_draft_version)
        self.assertNotEqual(published_version, new_published_version)
        self.assertEqual(new_draft_version, new_published_version)
