def get_block_info(self, brl_block): '''Check if auth_user can publish a block version specified by parameter block_version Returns: BlockInfo ''' try: self.security.check_read_block(brl_block) except NotInStoreException: # In this case, the block doesnt exist, but return information of -1 and permissions return self._get_new_block_info(brl_block) block_info = BlockInfo() try: self.security.check_write_block(brl_block) block_info.can_write = True except ForbiddenException: block_info.can_write = False try: block = self._store.read_block(brl_block) block_info.last_version = block.last_version() block_info.private = self.security.is_private(brl_block) except Exception as e: tb = traceback.format_exc() logger.debug(tb) logger.error("Something went wrong with %s" % e) raise BiiServiceException('Something went wrong') return block_info
def get_block_info(self, brl_block): '''Check if auth_user can publish a block version specified by parameter block_version Returns: BlockInfo ''' try: self.security.check_read_block(brl_block) except NotInStoreException: # In this case, the block doesnt exist, but return information of -1 and permissions return self._get_new_block_info(brl_block) block_info = BlockInfo() try: self.security.check_write_block(brl_block) block_info.can_write = True except ForbiddenException: block_info.can_write = False try: block = self._store.read_block(brl_block) block_info.last_version = block.last_version() block_info.private = self.security.is_private(brl_block) except Exception as e: tb = traceback.format_exc() logger.debug(tb) logger.error("Something went wrong with %s" % e) raise BiiServiceException('Something went wrong') return block_info
def test_equals(self): bversion = BlockVersion("phil/phil/super_block/master", "0") bversion2 = BlockVersion("fenix/fenix/slight_block/master", "0") block_info = BlockInfo(True, bversion, False) block_info2 = BlockInfo(True, bversion, False) self.assertEquals(block_info, block_info2) block_info2.last_version = bversion2 self.assertNotEquals(block_info, block_info2) block_info2.last_version = bversion block_info.can_write = False self.assertNotEquals(block_info, block_info2) block_info.can_write = True block_info.private = True self.assertNotEquals(block_info, block_info2)
def test_equals(self): bversion = BlockVersion("phil/phil/super_block/master", "0") bversion2 = BlockVersion("fenix/fenix/slight_block/master", "0") block_info = BlockInfo(True, bversion, False) block_info2 = BlockInfo(True, bversion, False) self.assertEquals(block_info, block_info2) block_info2.last_version = bversion2 self.assertNotEquals(block_info, block_info2) block_info2.last_version = bversion block_info.can_write = False self.assertNotEquals(block_info, block_info2) block_info.can_write = True block_info.private = True self.assertNotEquals(block_info, block_info2)