Ejemplo n.º 1
0
 def test_set_permissions(self):
     sb = SbSession('beta').login(self.TEST_USER, self.TEST_PASSWORD)
     item = sb.create_item({'title': "ACL Test", 'parentId': sb.get_my_items_id()})
     acls = sb.get_permissions(item['id'])
     self.assertFalse('USER:spongebob@bikini_bottom.net' in acls['read']['acl'])
     acls['read']['acl'].append('USER:spongebob@bikini_bottom.net')
     sb.set_permissions(item['id'], acls)
     self.assertTrue('USER:spongebob@bikini_bottom.net' in acls['read']['acl'])
     
     sb.delete_item(item)
Ejemplo n.º 2
0
    def test_upload_shapefile_no_scrape(self):
        sb = SbSession('beta').login(self.TEST_USER, self.TEST_PASSWORD)
        file_dir = 'test/data/FHP_Great_Lakes_Basin_boundary'
        files = ["%s/%s" % (file_dir, f) for f in listdir(file_dir) if isfile(join(file_dir, f))]

        my_items_id = sb.get_my_items_id()
        # Creating new item from shapefile upload
        item = sb.upload_files_and_upsert_item({'parentId': my_items_id}, files, scrape_file=False)
        # Delete the item before the assertions to make sure it gets deleted
        sb.delete_item(item)
        self.assertIsNotNone(item)
        self.assertIsNotNone(item['files'])
        self.assertFalse('facets' in item)
Ejemplo n.º 3
0
    def test_relationships(self):
        sb = SbSession('beta').login(self.TEST_USER, self.TEST_PASSWORD)
        item1 = sb.create_item({'title': "Project", 'parentId': sb.get_my_items_id()})
        item2 = sb.create_item({'title': "Product", 'parentId': sb.get_my_items_id()})
        result = sb.create_related_item_link(item1['id'], item2['id'])
        self.assertTrue(result['itemId'] == item1['id'])
        self.assertTrue(result['relatedItemId'] == item2['id'])

        results = sb.get_item_links(item1['id'])
        self.assertEqual(len(results), 1)

        sb.delete_item(item1)
        sb.delete_item(item2)
Ejemplo n.º 4
0
    def test_upload_shapefile_individual_no_scrape(self):
        sb = SbSession('beta').login(self.TEST_USER, self.TEST_PASSWORD)
        file_dir = 'test/data/FHP_Great_Lakes_Basin_boundary'
        files = ["%s/%s" % (file_dir, f) for f in listdir(file_dir) if isfile(join(file_dir, f))]

        # Updating existing item with shapefile, uploading files individually

        item = sb.create_item({'parentId': sb.get_my_items_id(), 'title':'sciencebasepy Shapefile Upload Test'})
        for f in files:
            item = sb.upload_file_to_item(item, f, scrape_file=False)
        # Delete the item before the assertions to make sure it gets deleted
        sb.delete_item(item)
        self.assertIsNotNone(item)
        self.assertIsNotNone(item['files'])
        self.assertFalse('facets' in item)
Ejemplo n.º 5
0
    def test_add_delete_role_acl(self):
        sb = SbSession('beta').login(self.TEST_USER, self.TEST_PASSWORD)
        item = sb.create_item({'title': "ACL Test", 'parentId': sb.get_my_items_id()})
        acls = sb.get_permissions(item['id'])
        self.assertFalse('ROLE:ScienceBase_DataAdmin' in acls['read']['acl'])
        self.assertFalse('ROLE:ScienceBase_DataAdmin' in acls['write']['acl'])

        sb.add_acl_role_read("ScienceBase_DataAdmin", item['id'])
        acls = sb.add_acl_role_write("ScienceBase_DataAdmin", item['id'])
        self.assertTrue('ROLE:ScienceBase_DataAdmin' in acls['read']['acl'])
        self.assertTrue('ROLE:ScienceBase_DataAdmin' in acls['write']['acl'])
    
        sb.remove_acl_role_read("ScienceBase_DataAdmin", item['id'])
        acls = sb.remove_acl_role_write("ScienceBase_DataAdmin", item['id'])
        self.assertFalse('ROLE:ScienceBase_DataAdmin' in acls['read']['acl'])
        self.assertFalse('ROLE:ScienceBase_DataAdmin' in acls['write']['acl'])

        sb.delete_item(item)
Ejemplo n.º 6
0
    def test_add_delete_user_acl(self):
        sb = SbSession('beta').login(self.TEST_USER, self.TEST_PASSWORD)
        item = sb.create_item({'title': "ACL Test", 'parentId': sb.get_my_items_id()})
        acls = sb.get_permissions(item['id'])
        self.assertFalse('USER:[email protected]' in acls['read']['acl'])
        self.assertFalse('USER:[email protected]' in acls['write']['acl'])

        sb.add_acl_user_read("*****@*****.**", item['id'])
        acls = sb.add_acl_user_write("*****@*****.**", item['id'])
        self.assertTrue('USER:[email protected]' in acls['read']['acl'])
        self.assertTrue('USER:[email protected]' in acls['write']['acl'])

        sb.remove_acl_user_read("*****@*****.**", item['id'])
        acls = sb.remove_acl_user_write("*****@*****.**", item['id'])
        self.assertFalse('USER:[email protected]' in acls['read']['acl'])
        self.assertFalse('USER:[email protected]' in acls['write']['acl'])

        sb.delete_item(item)