Ejemplo n.º 1
0
 def test_parse_permissions_css(
         self, mock_conn):
     restrictions = ('canEdit', 'canAnnotate', 'canLink', 'canDelete')
     # Iterate through every combination of the restrictions' flags,
     # checking each with and without expected canChgrp
     for i in range(2**len(restrictions)):
         expected = []
         permissions_dict = {'perm': '------'}
         for j in range(len(restrictions)):
             if i & 2**j != 0:
                 expected.append(restrictions[j])
                 permissions_dict[restrictions[j]] = True
             else:
                 permissions_dict[restrictions[j]] = False
         expected.sort()
         owner_id = mock_conn.getUserId()
         # Test with different owner_ids, which means canChgrp is False
         received = parse_permissions_css(permissions_dict,
                                          owner_id+1,
                                          mock_conn)
         received = filter(None, received.split(' '))
         received.sort()
         assert expected == received
         # Test with matching owner_ids, which means
         # isOwned and canChgrp is True
         expected.append('isOwned')
         expected.append('canChgrp')
         expected.sort()
         received = parse_permissions_css(permissions_dict,
                                          owner_id,
                                          mock_conn)
         received = filter(None, received.split(' '))
         received.sort()
         assert expected == received
Ejemplo n.º 2
0
 def test_parse_permissions_css(self, mock_conn):
     restrictions = ("canEdit", "canAnnotate", "canLink", "canDelete",
                     "canChgrp")
     # Iterate through every combination of the restrictions' flags,
     # checking each with and without expected canChgrp
     for i in range(2**len(restrictions)):
         expected = []
         permissions_dict = {"perm": "------"}
         for j in range(len(restrictions)):
             if i & 2**j != 0:
                 expected.append(restrictions[j])
                 permissions_dict[restrictions[j]] = True
             else:
                 permissions_dict[restrictions[j]] = False
         expected.sort()
         owner_id = mock_conn.getUserId()
         # Test with different owner_ids, which means canChgrp is False
         received = parse_permissions_css(permissions_dict, owner_id + 1,
                                          mock_conn)
         received = list(filter(None, received.split(" ")))
         received.sort()
         assert expected == received
         # Test with matching owner_ids, which means
         # isOwned and canChgrp is True
         expected.append("isOwned")
         expected.sort()
         received = parse_permissions_css(permissions_dict, owner_id,
                                          mock_conn)
         received = list(filter(None, received.split(" ")))
         received.sort()
         assert expected == received
Ejemplo n.º 3
0
def _marshal_map(conn, row):
    ''' Given a Map row (list) marshals it into a dictionary.  Order
        and type of columns in row is:
          * id (rlong)
          * value (rstring)
          * description (rstring)
          * details.owner.id (rlong)
          * details.permissions (dict)
          * namespace (rstring)

        @param conn OMERO gateway.
        @type conn L{omero.gateway.BlitzGateway}
        @param row The Tag row to marshal
        @type row L{list}

    '''
    map_id, value, description, owner_id, permissions, namespace, \
        child_count = row

    mapann = dict()
    mapann['id'] = unwrap(map_id)
    mapann['name'] = unwrap(value)
    desc = unwrap(description)
    if desc:
        mapann['description'] = desc
    mapann['ownerId'] = unwrap(owner_id)
    mapann['permsCss'] = parse_permissions_css(permissions, unwrap(owner_id),
                                               conn)

    mapann['childCount'] = unwrap(child_count)

    return mapann
Ejemplo n.º 4
0
def _marshal_map(conn, row):
    ''' Given a Map row (list) marshals it into a dictionary.  Order
        and type of columns in row is:
          * id (rlong)
          * value (rstring)
          * description (rstring)
          * details.owner.id (rlong)
          * details.permissions (dict)
          * namespace (rstring)

        @param conn OMERO gateway.
        @type conn L{omero.gateway.BlitzGateway}
        @param row The Tag row to marshal
        @type row L{list}

    '''
    map_id, value, description, owner_id, permissions, namespace, \
        child_count = row

    mapann = dict()
    mapann['id'] = unwrap(map_id)
    mapann['name'] = unwrap(value)
    desc = unwrap(description)
    if desc:
        mapann['description'] = desc
    mapann['ownerId'] = unwrap(owner_id)
    mapann['permsCss'] = parse_permissions_css(permissions,
                                               unwrap(owner_id), conn)

    mapann['childCount'] = unwrap(child_count)

    return mapann