class BiiApiTest(TestWithMongo): _multiprocess_shared_ = True def setUp(self): self.store = MongoServerStore(self.conn, self.__class__.__name__) self.mother = ModelCreator(self.store) self.testUser = self.mother.make_test_user() self.service = BiiService(self.store, self.testUser.ID) def test_get_cells_snapshot_invalid_version(self): b = self.mother.make_block(self.testUser) version = BlockVersion(block=b.ID, time=1) self.assertRaises(NotFoundException, self.service.get_cells_snapshot, version) def testNotFoundExceptions(self): self.assertRaises(NotFoundException, self.service.get_cells_snapshot, BlockVersion('user/user/block/master', 3)) def test_get_version_by_tag(self): brl_block = BRLBlock('%s/%s/TestBlock/master' % (self.testUser.ID, self.testUser.ID)) publish_request = PublishRequest(BlockVersion(brl_block, -1)) publish_request.tag = STABLE publish_request.versiontag = 'mytag' publish_request.cells.append(SimpleCell(brl_block.block_name + 'r1.h')) publish_request.contents['r1.h'] = Content(id_=None, load=Blob('hola')) publish_request.deptable = BlockVersionTable() self.service.publish(publish_request) publish_request = PublishRequest(BlockVersion(brl_block, 0, 'mytag')) publish_request.tag = STABLE publish_request.versiontag = 'mytag' publish_request.cells.append(SimpleCell(brl_block.block_name + 'r12.h')) publish_request.contents['r2.h'] = Content(id_=None, load=Blob('hola')) publish_request.deptable = BlockVersionTable() self.service.publish(publish_request) block_version = self.service.get_version_by_tag(brl_block, 'mytag') self.assertEquals(1, block_version.time) def test_tag_nofound(self): brl_block = BRLBlock('%s/%s/TestBlock/master' % (self.testUser.ID, self.testUser.ID)) with self.assertRaises(NotFoundException): self.service.get_version_by_tag(brl_block, 'mytag')
class BaseDigraphTest(TestWithMongo): def _initUser(self): self.store = MongoServerStore(self.conn, self.__class__.__name__) self.mother = ModelCreator(self.store) self.testUser = self.mother.make_test_user() self.service = BiiService(self.store, self.testUser.ID) def _getBlockCellNames(self, dim): '''generates names from dim list''' bcns = [ BlockCellName(self.testUser.ID + '/module%s/cell%s' % (i, i)) for i in range(len(dim)) ] return bcns def _getBlockBRL(self, block_cell_name): return BRLBlock('{0}/{1}/master'.format(self.testUser.ID, block_cell_name.block_name)) def _publishIndependentCell(self, block_cell_name, nVersions=10, version_tag=None): '''publishes nVersions of each cell''' block_brl = self._getBlockBRL(block_cell_name) for v in range(0, nVersions): r = SimpleCell(block_cell_name) pack = PublishRequest(BlockVersion(block_brl, v - 1)) pack.tag = version_tag if version_tag is not None else STABLE pack.cells.append(r) pack.deptable = BlockVersionTable() pack.contents[r.name.cell_name] = Content( id_=None, load=Blob('hola {0}'.format(v))) self.service.publish(pack) def _unresolvedDependencyRequest(self, unresolved_deps): request = FinderRequest() unresolved = set() for dep in unresolved_deps: unresolved.add(CPPDeclaration(dep)) request.unresolved = unresolved request.policy = Policy.default() return request
class BaseDigraphTest(TestWithMongo): def _initUser(self): self.store = MongoServerStore(self.conn, self.__class__.__name__) self.mother = ModelCreator(self.store) self.testUser = self.mother.make_test_user() self.service = BiiService(self.store, self.testUser.ID) def _getBlockCellNames(self, dim): '''generates names from dim list''' bcns = [BlockCellName(self.testUser.ID + '/module%s/cell%s' % (i, i)) for i in range(len(dim))] return bcns def _getBlockBRL(self, block_cell_name): return BRLBlock('{0}/{1}/master' .format(self.testUser.ID, block_cell_name.block_name)) def _publishIndependentCell(self, block_cell_name, nVersions=10, version_tag=None): '''publishes nVersions of each cell''' block_brl = self._getBlockBRL(block_cell_name) for v in range(0, nVersions): r = SimpleCell(block_cell_name) pack = PublishRequest(BlockVersion(block_brl, v - 1)) pack.tag = version_tag if version_tag is not None else STABLE pack.cells.append(r) pack.deptable = BlockVersionTable() pack.contents[r.name.cell_name] = Content(id_=None, load=Blob('hola {0}'.format(v))) self.service.publish(pack) def _unresolvedDependencyRequest(self, unresolved_deps): request = FinderRequest() unresolved = set() for dep in unresolved_deps: unresolved.add(CPPDeclaration(dep)) request.unresolved = unresolved request.policy = Policy.default() return request
def setUp(self): self.store = MongoServerStore(self.conn, self.__class__.__name__) self.mother = ModelCreator(self.store) self.testUser = self.mother.make_test_user() self.service = BiiService(self.store, self.testUser.ID)