コード例 #1
0
 def test_hive_num_files_reject(self):
     with self.assertRaises(BiiException):
         hive = Hive()
         changes = ProcessorChanges()
         for i in xrange(BII_HIVE_NUMFILES_LIMIT + 1):
             name = "user/block/file%d" % i
             changes.upsert(name, Content(id_=name, load=Blob()))
         hive.update(changes)
         changevalidator.check_hive_num_cells(hive)
コード例 #2
0
ファイル: hive_test.py プロジェクト: lasote/common
class HiveTest(BiiTestCase):
    def setUp(self):
        self.hive = Hive()

    def test_serialize(self):
        serial = self.hive.serialize()
        deserial = Hive.deserialize(serial)
        self.assert_bii_equal(Hive(), deserial)

    def test_deserialization(self):
        self.assertRaises(BiiSerializationException, Hive.deserialize, None)
コード例 #3
0
ファイル: client_hive_manager.py プロジェクト: toeb/client
def init_hive(bii, project_name=None, layout=None):
    """ Initializes an empty project
    """
    user_cache = bii.user_cache
    out = bii.user_io.out

    bii_paths = bii.bii_paths
    if bii_paths.current_dir.startswith(bii_paths.user_bii_home):
        raise BiiException(
            'Cannot create a project inside the user .biicode folder')

    try:
        bii_paths.project_root
        raise ClientException('Cannot create project inside other project')
    except NotInAHiveException:
        pass

    if project_name:
        name = ComplexName(project_name)
        current_dir = os.path.join(bii_paths.current_dir, name)
        bii_paths.current_dir = current_dir
    else:
        current_dir = bii_paths.current_dir
        ComplexName(os.path.basename(current_dir))

    for root, _, _ in os.walk(current_dir):
        if os.path.exists(os.path.join(root, BII_DIR, BII_HIVE_DB)):
            if root == current_dir:
                project_name = os.path.basename(current_dir)
                raise ClientException('Project "%s" already exists' %
                                      project_name)
            raise ClientException(
                'Cannot create project with other project inside:\n%s' % root)

    hive_disk_image = bii.hive_disk_image
    hive_disk_image.initialize()

    try:
        hive = Hive()
        hive_disk_image.hivedb.upsert_hive(hive)
        out.success('Successfully initialized biicode project %s' %
                    (project_name or ""))
    # If an exception is launched, the hive folder is deleted
    except BaseException as e:
        out.error('An error occurred while creating the project %s' % str(e))
        logger.error(traceback.format_exc())
        if project_name and os.path.exists(current_dir):
            hive_disk_image.hivedb.disconnect()
            shutil.rmtree(current_dir)
    else:
        layout_content = user_cache.layout(layout)
        if layout_content:
            save(os.path.join(hive_disk_image.paths.bii, "layout.bii"),
                 layout_content)
コード例 #4
0
 def base_version_test(self):
     hive = Hive()
     hive_holder = HiveHolder(hive, {}, {})
     parents_resource = Resource(
         SimpleCell(a1.block_name + BIICODE_FILE),
         Content(id_=None, load=Blob('[parent]\n ' + str(a1))))
     hive_holder.add_holder(BlockHolder(a1.block_name, {parents_resource}))
     parents_resource = Resource(
         SimpleCell(b2.block_name + BIICODE_FILE),
         Content(id_=None, load=Blob('[parent]\n * ' + str(b2))))
     hive_holder.add_holder(BlockHolder(b2.block_name, {parents_resource}))
     hive_holder.add_holder(BlockHolder(cn.block_name, {}))
     result_table = BlockVersionTable(
         [b.parent for b in hive_holder.block_holders])
     self.assertEqual(result_table, BlockVersionTable([a1, b2, cn]))
コード例 #5
0
 def test_store_hive(self):
     hive = Hive()
     self.db.upsert_hive(hive)
     retrieved = self.db.read_hive()
     self.assert_bii_equal(hive, retrieved)
コード例 #6
0
ファイル: hivedb.py プロジェクト: toeb/client
 def clean(self):
     self.delete_all(CELLS)
     self.delete_all(CONTENTS)
     self.upsert_hive(Hive())
     self.vacuum()
コード例 #7
0
ファイル: hive_test.py プロジェクト: lasote/common
 def test_serialize(self):
     serial = self.hive.serialize()
     deserial = Hive.deserialize(serial)
     self.assert_bii_equal(Hive(), deserial)
コード例 #8
0
ファイル: hive_test.py プロジェクト: lasote/common
 def setUp(self):
     self.hive = Hive()