'Test the read-only role (LibraryUserRole and its org-level equivalent)'

@ddt.data(True, False)
def test_read_only_role(self, use_org_level_role):

    block = self._add_simple_content_block()
    self._login_as_non_staff_user()
    self.assertFalse(self._can_access_library(self.library))
    block_url = reverse_usage_url('xblock_handler', block.location)
    def can_read_block():
        '    Check    if    studio    lets    us    view    the    XBlock    in    the    library    '
        response = self.client.get_json(block_url)
        self.assertIn(response.status_code, (200, 403))
        return (response.status_code == 200)
    def can_edit_block():
        '    Check    if    studio    lets    us    edit    the    XBlock    in    the    library    '
        response = self.client.ajax_post(block_url)
        self.assertIn(response.status_code, (200, 403))
        return (response.status_code == 200)
    def can_delete_block():
        '    Check    if    studio    lets    us    delete    the    XBlock    in    the    library    '
        response = self.client.delete(block_url)
        self.assertIn(response.status_code, (200, 403))
        return (response.status_code == 200)
    def can_copy_block():
        '    Check    if    studio    lets    us    duplicate    the    XBlock    in    the    library    '
        response = self.client.ajax_post(reverse_url('xblock_handler'), {'parent_locator': unicode(self.library.location), 'duplicate_source_locator': unicode(block.location)})
        self.assertIn(response.status_code, (200, 403))
        return (response.status_code == 200)
    def can_create_block():
        '    Check    if    studio    lets    us    make    a    new    XBlock    in    the    library    '
        response = self.client.ajax_post(reverse_url('xblock_handler'), {'parent_locator': unicode(self.library.location), 'category': 'html'})
        self.assertIn(response.status_code, (200, 403))
        return (response.status_code == 200)
    self.assertFalse(can_read_block())
    self.assertFalse(can_edit_block())
    self.assertFalse(can_delete_block())
    self.assertFalse(can_copy_block())
    self.assertFalse(can_create_block())
    if use_org_level_role:
        OrgLibraryUserRole(self.lib_key.org).add_users(self.non_staff_user)
    else:
        LibraryUserRole(self.lib_key).add_users(self.non_staff_user)
    self.assertTrue(self._can_access_library(self.library))
    self.assertTrue(can_read_block())
    self.assertFalse(can_edit_block())
    self.assertFalse(can_delete_block())
    self.assertFalse(can_copy_block())
    self.assertFalse(can_create_block())
