def test_marshal_projects(self, projects): project_a, project_b, project_c, project_d = projects perms_css = 'canEdit canAnnotate canLink canDelete isOwned canChgrp' # Order is important to test desired HQL sorting semantics. expected = [{ 'id': project_a.id.val, 'name': 'Apple', 'datasets': list(), 'childCount': 0, 'permsCss': perms_css }, { 'id': project_c.id.val, 'name': 'atom', 'datasets': list(), 'childCount': 0, 'permsCss': perms_css }, { 'id': project_b.id.val, 'name': 'bat', 'datasets': list(), 'childCount': 0, 'permsCss': perms_css }, { 'id': project_d.id.val, 'name': 'Butter', 'datasets': list(), 'childCount': 0, 'permsCss': perms_css }] marshaled = marshal_projects(self.conn, self.conn.getUserId()) print marshaled assert marshaled == expected
def test_marshal_projects_datasets(self, projects_datasets): project_a, project_b, project_c, project_d = projects_datasets expected = list() perms_css = 'canEdit canAnnotate canLink canDelete isOwned canChgrp' # The underlying query explicitly orders the Projects list by # case-insensitive name. for project in sorted(projects_datasets, cmp_name_insensitive): expected.append({ 'id': project.id.val, 'name': project.name.val, 'childCount': 4, 'permsCss': perms_css }) # The underlying query explicitly orders the Datasets list by # case-insensitive name. source = project.linkedDatasetList() source.sort(cmp_name_insensitive) datasets = list() for dataset in source: datasets.append({ 'childCount': 0L, 'id': dataset.id.val, 'name': dataset.name.val, 'permsCss': perms_css }) expected[-1]['datasets'] = datasets marshaled = marshal_projects(self.conn, self.conn.getUserId()) assert marshaled == expected
def test_marshal_projects_datasetsew(self, conn, projects_datasets): project_a, project_b, project_c, project_d = projects_datasets expected = list() perms_css = 'canEdit canAnnotate canLink canDelete canChgrp' # The underlying query explicitly orders the Projects list by # case-insensitive name. for project in sorted(projects_datasets, cmp_name_insensitive): expected.append({ 'id': project.id.val, 'isOwned': True, 'name': project.name.val, 'childCount': 4, 'permsCss': perms_css }) # The underlying query explicitly orders the Datasets list by # case-insensitive name. source = project.linkedDatasetList() source.sort(cmp_name_insensitive) datasets = list() for dataset in source: datasets.append({ 'childCount': 0L, 'id': dataset.id.val, 'isOwned': True, 'name': dataset.name.val, 'permsCss': perms_css }) expected[-1]['datasets'] = datasets marshaled = marshal_projects(conn, conn.getUserId()) assert marshaled == expected
def test_marshal_projects_datasets_duplicates(self, projects_datasets): """ Test that same-named Projects are not duplicated in marshaled data. See https://trac.openmicroscopy.org/ome/ticket/12771 """ # Re-name projects with all the same name for p in projects_datasets: p.name = rstring("Test_Duplicates") projects_datasets = self.update.saveAndReturnArray(projects_datasets) marshaled = marshal_projects(self.conn, self.conn.getUserId()) assert len(marshaled) == len(projects_datasets)
def test_marshal_projects_different_users_as_other_user( self, projects_different_users): project_a, project_b = projects_different_users expected = list() perms_css = '' # The underlying query explicitly orders the Projects list by # case-insensitive name. for project in sorted(projects_different_users, cmp_name_insensitive): expected.append({ 'id': project.id.val, 'name': project.name.val, 'childCount': 0, 'permsCss': perms_css, 'datasets': list() }) self.conn.SERVICE_OPTS.setOmeroGroup(project_a.details.group.id.val) marshaled = marshal_projects(self.conn, None) assert marshaled == expected
def test_marshal_projects_different_users_as_other_user( self, conn, projects_different_users): project_a, project_b = projects_different_users expected = list() perms_css = '' # The underlying query explicitly orders the Projects list by # case-insensitive name. for project in sorted(projects_different_users, cmp_name_insensitive): expected.append({ 'id': project.id.val, 'isOwned': False, 'name': project.name.val, 'childCount': 0, 'permsCss': perms_css, 'datasets': list() }) conn.SERVICE_OPTS.setOmeroGroup(project_a.details.group.id.val) marshaled = marshal_projects(conn, None) assert marshaled == expected
def test_marshal_projects(self, conn, projects): project_a, project_b, project_c, project_d = projects perms_css = 'canEdit canAnnotate canLink canDelete canChgrp' # Order is important to test desired HQL sorting semantics. expected = [{ 'id': project_a.id.val, 'isOwned': True, 'name': 'Apple', 'datasets': list(), 'childCount': 0, 'permsCss': perms_css }, { 'id': project_c.id.val, 'isOwned': True, 'name': 'atom', 'datasets': list(), 'childCount': 0, 'permsCss': perms_css }, { 'id': project_b.id.val, 'isOwned': True, 'name': 'bat', 'datasets': list(), 'childCount': 0, 'permsCss': perms_css }, { 'id': project_d.id.val, 'isOwned': True, 'name': 'Butter', 'datasets': list(), 'childCount': 0, 'permsCss': perms_css }] marshaled = marshal_projects(conn, conn.getUserId()) assert marshaled == expected
def test_marshal_projects_no_results(self): assert marshal_projects(self.conn, -1) == []
dataset, = project_dataset.linkedDatasetList() perms_css = 'canEdit canAnnotate canLink canDelete isOwned canChgrp' expected = [{ 'id': project_id, 'childCount': 1L, 'name': project_dataset.name.val, 'datasets': [{ 'childCount': 0L, 'id': dataset.id.val, 'name': dataset.name.val, 'permsCss': perms_css }], 'permsCss': perms_css }] marshaled = marshal_projects(self.conn, self.conn.getUserId()) assert marshaled == expected def test_marshal_projects_datasets(self, projects_datasets): project_a, project_b, project_c, project_d = projects_datasets expected = list() perms_css = 'canEdit canAnnotate canLink canDelete isOwned canChgrp' # The underlying query explicitly orders the Projects list by # case-insensitive name. for project in sorted(projects_datasets, cmp_name_insensitive): expected.append({ 'id': project.id.val, 'name': project.name.val, 'childCount': 4, 'permsCss': perms_css })
def test_marshal_projects_no_results(self, conn): assert marshal_projects(conn, -1) == []
'name': project_dataset.name.val, 'isOwned': True, 'datasets': [{ 'childCount': 0L, 'id': dataset.id.val, 'isOwned': True, 'name': dataset.name.val, 'permsCss': perms_css }], 'permsCss': perms_css }] marshaled = marshal_projects(conn, conn.getUserId()) assert marshaled == expected def test_marshal_projects_datasetsew(self, conn, projects_datasets): project_a, project_b, project_c, project_d = projects_datasets expected = list() perms_css = 'canEdit canAnnotate canLink canDelete canChgrp' # The underlying query explicitly orders the Projects list by # case-insensitive name. for project in sorted(projects_datasets, cmp_name_insensitive): expected.append({ 'id': project.id.val, 'isOwned': True, 'name': project.name.val, 'childCount': 4, 'permsCss': perms_css
expected = [{ 'id': project_id, 'childCount': 1L, 'name': project_dataset.name.val, 'isOwned': True, 'datasets': [{ 'childCount': 0L, 'id': dataset.id.val, 'isOwned': True, 'name': dataset.name.val, 'permsCss': perms_css }], 'permsCss': perms_css }] marshaled = marshal_projects(conn, conn.getUserId()) assert marshaled == expected def test_marshal_projects_datasetsew(self, conn, projects_datasets): project_a, project_b, project_c, project_d = projects_datasets expected = list() perms_css = 'canEdit canAnnotate canLink canDelete canChgrp' # The underlying query explicitly orders the Projects list by # case-insensitive name. for project in sorted(projects_datasets, cmp_name_insensitive): expected.append({ 'id': project.id.val, 'isOwned': True, 'name': project.name.val, 'childCount': 4, 'permsCss': perms_css