'Tests that edited_on, edited_by, subtree_edited_on, and subtree_edited_by are set correctly during update'

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

    self.initdb(default_ms)
    test_course = self.store.create_course('testx', 'GreekHero', 'test_run', self.user_id)
    def check_node(location_key, after, before, edited_by, subtree_after, subtree_before, subtree_by):
        '\n                                                Checks    that    the    node    given    by    location_key    matches    the    given    edit_info    constraints.\n                                                '
        node = self.store.get_item(location_key)
        if after:
            self.assertLess(after, node.edited_on)
        self.assertLess(node.edited_on, before)
        self.assertEqual(node.edited_by, edited_by)
        if subtree_after:
            self.assertLess(subtree_after, node.subtree_edited_on)
        self.assertLess(node.subtree_edited_on, subtree_before)
        self.assertEqual(node.subtree_edited_by, subtree_by)
    with self.store.bulk_operations(test_course.id):
        component = self.store.create_child(self.user_id, test_course.location, 'vertical', block_id='test_vertical')
        child = self.store.create_child(self.user_id, component.location, 'html', block_id='test_html')
        sibling = self.store.create_child(self.user_id, component.location, 'html', block_id='test_html_no_change')
    after_create = datetime.datetime.now(UTC)
    for block in [component, child, sibling]:
        check_node(block.location, None, after_create, self.user_id, None, after_create, self.user_id)
    component.display_name = 'Changed    Display    Name'
    editing_user = (self.user_id - 2)
    with self.store.bulk_operations(test_course.id):
        component = self.store.update_item(component, editing_user)
    after_edit = datetime.datetime.now(UTC)
    check_node(component.location, after_create, after_edit, editing_user, after_create, after_edit, editing_user)
    check_node(child.location, None, after_create, self.user_id, None, after_create, self.user_id)
    child = self.store.get_item(child.location)
    child.display_name = 'Changed    Display    Name'
    self.store.update_item(child, user_id=editing_user)
    after_edit = datetime.datetime.now(UTC)
    check_node(child.location, after_create, after_edit, editing_user, after_create, after_edit, editing_user)
    check_node(test_course.location, None, after_create, self.user_id, after_create, after_edit, editing_user)
    check_node(sibling.location, None, after_create, self.user_id, None, after_create, self.user_id)
