Пример #1
0
    def test_marshal_screens_plates(self, screens_plates):
        screen_a, screen_b, screen_c, screen_d = screens_plates
        expected = list()
        perms_css = 'canEdit canAnnotate canLink canDelete isOwned canChgrp'
        # The underlying query explicitly orders the Screens list by
        # case-insensitive name.
        for screen in sorted(screens_plates, cmp_name_insensitive):
            expected.append({
                'id': screen.id.val,
                'name': screen.name.val,
                'childCount': 4,
                'permsCss': perms_css
            })
            # The underlying query explicitly orders the Plate list by
            # case-insensitive name.
            source = screen.linkedPlateList()
            source.sort(cmp_name_insensitive)
            plates = list()
            for plate in source:
                plates.append({
                    'id': plate.id.val,
                    'name': plate.name.val,
                    'permsCss': perms_css,
                    'plateAcquisitions': list(),
                    'plateAcquisitionCount': 0
                })
            expected[-1]['plates'] = plates

        marshaled = marshal_screens(self.conn, self.conn.getUserId())
        assert marshaled == expected
Пример #2
0
 def test_marshal_screens_plates_runs(self, screens_plates_runs):
     perms_css = 'canEdit canAnnotate canLink canDelete isOwned canChgrp'
     expected = []
     # The underlying query explicitly orders the Screens by name.
     for screen in sorted(screens_plates_runs, cmp_name):
         expected_screen = {
             'id': screen.id.val,
             'name': screen.name.val,
             'permsCss': perms_css,
             'childCount': 2,
             'plates': list()
         }
         # The underlying query explicitly orders the Plates by name.
         for plate in sorted(screen.linkedPlateList(), cmp_name):
             expected_plates = expected_screen['plates']
             expected_plates.append({
                 'id': plate.id.val,
                 'name': plate.name.val,
                 'plateAcquisitions': list(),
                 'plateAcquisitionCount': 2,
                 'permsCss': perms_css
             })
             # The underlying query explicitly orders the PlateAcquisitions
             # by id.
             plate_acquisitions = \
                 sorted(plate.copyPlateAcquisitions(), cmp_id)
             for plate_acquisition in plate_acquisitions:
                 expected_plates[-1]['plateAcquisitions'].append({
                     'id': plate_acquisition.id.val,
                     'name': 'Run %d' % plate_acquisition.id.val,
                     'permsCss': perms_css
                 })
         expected.append(expected_screen)
     marshaled = marshal_screens(self.conn, self.conn.getUserId())
     assert marshaled == expected
Пример #3
0
    def test_marshal_screens(self, screens):
        screen_a, screen_b, screen_c, screen_d = screens
        perms_css = 'canEdit canAnnotate canLink canDelete isOwned canChgrp'
        # Order is important to test desired HQL sorting semantics.
        expected = [{
            'id': screen_a.id.val,
            'name': 'Apple',
            'plates': list(),
            'childCount': 0,
            'permsCss': perms_css
        }, {
            'id': screen_c.id.val,
            'name': 'atom',
            'plates': list(),
            'childCount': 0,
            'permsCss': perms_css
        }, {
            'id': screen_b.id.val,
            'name': 'bat',
            'plates': list(),
            'childCount': 0,
            'permsCss': perms_css
        }, {
            'id': screen_d.id.val,
            'name': 'Butter',
            'plates': list(),
            'childCount': 0,
            'permsCss': perms_css
        }]

        marshaled = marshal_screens(self.conn, self.conn.getUserId())
        assert marshaled == expected
Пример #4
0
    def test_marshal_screens_plates(self, conn, screens_plates):
        screen_a, screen_b, screen_c, screen_d = screens_plates
        expected = list()
        perms_css = 'canEdit canAnnotate canLink canDelete canChgrp'
        # The underlying query explicitly orders the Screens list by
        # case-insensitive name.
        for screen in sorted(screens_plates, cmp_name_insensitive):
            expected.append({
                'id': screen.id.val,
                'isOwned': True,
                'name': screen.name.val,
                'childCount': 4,
                'permsCss': perms_css
            })
            # The underlying query explicitly orders the Plate list by
            # case-insensitive name.
            source = screen.linkedPlateList()
            source.sort(cmp_name_insensitive)
            plates = list()
            for plate in source:
                plates.append({
                    'id': plate.id.val,
                    'isOwned': True,
                    'name': plate.name.val,
                    'permsCss': perms_css,
                    'plateAcquisitions': list(),
                    'plateAcquisitionCount': 0
                })
            expected[-1]['plates'] = plates

        marshaled = marshal_screens(conn, conn.getUserId())
        assert marshaled == expected
Пример #5
0
    def test_marshal_screen_plate_run(self, screen_plate_run):
        screen_id = screen_plate_run.id.val
        plate, = screen_plate_run.linkedPlateList()
        plate_acquisition, = plate.copyPlateAcquisitions()
        perms_css = 'canEdit canAnnotate canLink canDelete isOwned canChgrp'
        expected = [{
            'id': screen_id,
            'childCount': 1,
            'name': screen_plate_run.name.val,
            'permsCss': perms_css,
            'plates': [{
                'id': plate.id.val,
                'name': plate.name.val,
                'plateAcquisitions': [{
                    'id': plate_acquisition.id.val,
                    'name': 'Run %d' % plate_acquisition.id.val,
                    'permsCss': perms_css
                    }],
                'plateAcquisitionCount': 1,
                'permsCss': perms_css
            }],
        }]

        marshaled = marshal_screens(self.conn, self.conn.getUserId())
        assert marshaled == expected
Пример #6
0
    def test_marshal_screen_plate(self, conn, screen_plate):
        plate, = screen_plate.linkedPlateList()
        perms_css = 'canEdit canAnnotate canLink canDelete canChgrp'
        expected = [{
            'id':
            screen_plate.id.val,
            'name':
            screen_plate.name.val,
            'isOwned':
            True,
            'permsCss':
            perms_css,
            'childCount':
            1,
            'plates': [{
                'id': plate.id.val,
                'isOwned': True,
                'name': plate.name.val,
                'plateAcquisitions': list(),
                'plateAcquisitionCount': 0,
                'permsCss': perms_css
            }],
        }]

        marshaled = marshal_screens(conn, conn.getUserId())
        assert marshaled == expected
Пример #7
0
    def test_marshal_screens_different_users_as_other_user(
            self, screens_different_users):
        screen_a, screen_b = screens_different_users
        expected = list()
        perms_css = ''
        # The underlying query explicitly orders the Screens list by
        # case-insensitive name.
        for screen in sorted(screens_different_users, cmp_name_insensitive):
            expected.append({
                'id': screen.id.val,
                'name': screen.name.val,
                'childCount': 0,
                'permsCss': perms_css,
                'plates': list()
            })

        self.conn.SERVICE_OPTS.setOmeroGroup(screen_a.details.group.id.val)
        marshaled = marshal_screens(self.conn, None)
        assert marshaled == expected
Пример #8
0
 def test_marshal_screens_plates_runs(self, conn, screens_plates_runs):
     perms_css = 'canEdit canAnnotate canLink canDelete canChgrp'
     expected = []
     # The underlying query explicitly orders the Screens by name.
     for screen in sorted(screens_plates_runs, cmp_name):
         expected_screen = {
             'id': screen.id.val,
             'name': screen.name.val,
             'isOwned': True,
             'permsCss': perms_css,
             'childCount': 2,
             'plates': list()
         }
         # The underlying query explicitly orders the Plates by name.
         for plate in sorted(screen.linkedPlateList(), cmp_name):
             expected_plates = expected_screen['plates']
             expected_plates.append({
                 'id': plate.id.val,
                 'isOwned': True,
                 'name': plate.name.val,
                 'plateAcquisitions': list(),
                 'plateAcquisitionCount': 2,
                 'permsCss': perms_css
             })
             # The underlying query explicitly orders the PlateAcquisitions
             # by id.
             plate_acquisitions = \
                 sorted(plate.copyPlateAcquisitions(), cmp_id)
             for plate_acquisition in plate_acquisitions:
                 expected_plates[-1]['plateAcquisitions'].append({
                     'id':
                     plate_acquisition.id.val,
                     'name':
                     'Run %d' % plate_acquisition.id.val,
                     'isOwned':
                     True,
                     'permsCss':
                     perms_css
                 })
         expected.append(expected_screen)
     marshaled = marshal_screens(conn, conn.getUserId())
     assert marshaled == expected
Пример #9
0
    def test_marshal_screens_different_users_as_other_user(
            self, conn, screens_different_users):
        screen_a, screen_b = screens_different_users
        expected = list()
        perms_css = ''
        # The underlying query explicitly orders the Screens list by
        # case-insensitive name.
        for screen in sorted(screens_different_users, cmp_name_insensitive):
            expected.append({
                'id': screen.id.val,
                'isOwned': False,
                'name': screen.name.val,
                'childCount': 0,
                'permsCss': perms_css,
                'plates': list()
            })

        conn.SERVICE_OPTS.setOmeroGroup(screen_a.details.group.id.val)
        marshaled = marshal_screens(conn, None)
        assert marshaled == expected
Пример #10
0
    def test_marshal_screen_plate(self, screen_plate):
        plate, = screen_plate.linkedPlateList()
        perms_css = 'canEdit canAnnotate canLink canDelete isOwned canChgrp'
        expected = [
            {
                'id': screen_plate.id.val,
                'name': screen_plate.name.val,
                'permsCss': perms_css,
                'childCount': 1,
                'plates': [{
                    'id': plate.id.val,
                    'name': plate.name.val,
                    'plateAcquisitions': list(),
                    'plateAcquisitionCount': 0,
                    'permsCss': perms_css
                }],
            }
        ]

        marshaled = marshal_screens(self.conn, self.conn.getUserId())
        assert marshaled == expected
Пример #11
0
    def test_marshal_screen_plate_run(self, conn, screen_plate_run):
        screen_id = screen_plate_run.id.val
        plate, = screen_plate_run.linkedPlateList()
        plate_acquisition, = plate.copyPlateAcquisitions()
        perms_css = 'canEdit canAnnotate canLink canDelete canChgrp'
        expected = [{
            'id':
            screen_id,
            'childCount':
            1,
            'isOwned':
            True,
            'name':
            screen_plate_run.name.val,
            'permsCss':
            perms_css,
            'plates': [{
                'id':
                plate.id.val,
                'isOwned':
                True,
                'name':
                plate.name.val,
                'plateAcquisitions': [{
                    'id': plate_acquisition.id.val,
                    'name': 'Run %d' % plate_acquisition.id.val,
                    'isOwned': True,
                    'permsCss': perms_css
                }],
                'plateAcquisitionCount':
                1,
                'permsCss':
                perms_css
            }],
        }]

        marshaled = marshal_screens(conn, conn.getUserId())
        assert marshaled == expected
Пример #12
0
    def test_marshal_screens(self, conn, screens):
        screen_a, screen_b, screen_c, screen_d = screens
        perms_css = 'canEdit canAnnotate canLink canDelete canChgrp'
        # Order is important to test desired HQL sorting semantics.
        expected = [{
            'id': screen_a.id.val,
            'isOwned': True,
            'name': 'Apple',
            'plates': list(),
            'childCount': 0,
            'permsCss': perms_css
        }, {
            'id': screen_c.id.val,
            'isOwned': True,
            'name': 'atom',
            'plates': list(),
            'childCount': 0,
            'permsCss': perms_css
        }, {
            'id': screen_b.id.val,
            'isOwned': True,
            'name': 'bat',
            'plates': list(),
            'childCount': 0,
            'permsCss': perms_css
        }, {
            'id': screen_d.id.val,
            'isOwned': True,
            'name': 'Butter',
            'plates': list(),
            'childCount': 0,
            'permsCss': perms_css
        }]

        marshaled = marshal_screens(conn, conn.getUserId())
        assert marshaled == expected
Пример #13
0
 def test_marshal_screens_no_results(self):
     assert marshal_screens(self.conn, -1L) == []