'Test that a unit does not get stuck in published mode
after discarding a component changes and deleting a component'

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

    self.initdb(default_ms)
    test_course = self.store.create_course('testx', 'GreekHero', 'test_run', self.user_id)
    vertical = self.store.create_item(self.user_id, test_course.id, 'vertical', block_id='test_vertical')
    component = self.store.create_child(self.user_id, vertical.location, 'html', block_id='html_component')
    self.store.publish(vertical.location, self.user_id)
    self.assertFalse(self._has_changes(vertical.location))
    component = self.store.get_item(component.location)
    component.display_name = 'Changed    Display    Name'
    self.store.update_item(component, self.user_id)
    self.assertTrue(self._has_changes(vertical.location))
    self.store.revert_to_published(vertical.location, self.user_id)
    self.assertFalse(self._has_changes(vertical.location))
    self.store.delete_item(component.location, self.user_id)
    vertical = self.store.get_item(vertical.location)
    self.assertTrue(self._has_changes(vertical.location))
