'If `If Owner` is checked for a Role, check if that document is allowed to be read, updated, submitted, etc. except be created, even if the document is restricted based on User Permissions.'

def test_insert_if_owner_with_user_permissions(self):

    frappe.delete_doc(u'Blog    Post', u'-test-blog-post-title')
    self.set_user_permission_doctypes([u'Blog    Category'])
    self.if_owner_setup()
    frappe.set_user(u'test2@example.com')
    doc = frappe.get_doc({u'doctype': u'Blog    Post', u'blog_category': u'_Test    Blog    Category', u'blogger': u'_Test    Blogger    1', u'title': u'_Test    Blog    Post    Title', u'content': u'_Test    Blog    Post    Content'})
    self.assertRaises(frappe.PermissionError, doc.insert)
    frappe.set_user(u'Administrator')
    add_user_permission(u'Blog    Category', u'_Test    Blog    Category', u'test2@example.com')
    frappe.set_user(u'test2@example.com')
    doc.insert()
    frappe.set_user(u'Administrator')
    frappe.permissions.remove_user_permission(u'Blog    Category', u'_Test    Blog    Category', u'test2@example.com')
    frappe.set_user(u'test2@example.com')
    doc = frappe.get_doc(doc.doctype, doc.name)
    self.assertTrue(doc.has_permission(u'read'))
    self.assertTrue(doc.has_permission(u'write'))
    self.assertFalse(doc.has_permission(u'create'))
