コード例 #1
0
    def test_renames(self):
        publish_request = PublishRequest(BlockVersion(self.brl, -1))
        publish_request.cells.append(SimpleCell('user/block/r1.h'))
        publish_request.contents['r1.h'] = Content(id_=None, load=None)
        publish_request.cells.append(SimpleCell('user/block/r2.h'))
        publish_request.contents['r2.h'] = Content(id_=None, load=None)
        publish_request.cells.append(SimpleCell('user/block/r3.h'))
        publish_request.contents['r3.h'] = Content(id_=None, load=None)
        publish_request.tag = STABLE
        self.block.add_publication(publish_request)

        publish_request = PublishRequest(BlockVersion(self.brl, 0))
        publish_request.cells.append(SimpleCell('user/block/r11.h'))
        publish_request.deleted.append('r1.h')
        publish_request.renames = Renames(
            {CellName('r1.h'): CellName('r11.h')})
        publish_request.tag = STABLE
        self.block.add_publication(publish_request)

        publish_request = PublishRequest(BlockVersion(self.brl, 1))
        publish_request.cells.append(SimpleCell('user/block/r21.h'))
        publish_request.deleted.append('r2.h')
        publish_request.renames = Renames(
            {CellName('r2.h'): CellName('r21.h')})
        publish_request.tag = STABLE
        self.block.add_publication(publish_request)

        self.assertEquals({}, self.block.get_renames(0, 0))
        self.assertEquals({'r1.h': 'r11.h'}, self.block.get_renames(0, 1))
        self.assertEquals({
            'r2.h': 'r21.h',
            'r1.h': 'r11.h'
        }, self.block.get_renames(0, 2))
コード例 #2
0
    def test_add_delete_cell(self):
        publish_request = PublishRequest(BlockVersion(self.brl, -1))
        publish_request.tag = STABLE
        publish_request.cells.append(SimpleCell('user/block/r1.h'))
        publish_request.contents['r1.h'] = Content(id_=None, load=None)
        self.block.add_publication(publish_request)

        self.assertEqual({'r1.h': ID(self.block_id + 0)},
                         self.block.cells.get_all_ids(0))
        self.assertEqual({'r1.h': ID(self.block_id + 0)},
                         self.block.contents.get_all_ids(0))

        publish_request = PublishRequest(BlockVersion(self.brl, 0))
        publish_request.tag = STABLE
        publish_request.deleted.append('r1.h')
        self.block.add_publication(publish_request)

        self.assertEqual({'r1.h': self.block_id + 0},
                         self.block.cells.get_all_ids(0))
        self.assertEqual({'r1.h': self.block_id + 0},
                         self.block.contents.get_all_ids(0))

        self.assertEqual({}, self.block.cells.get_all_ids(1))
        self.assertEqual({}, self.block.contents.get_all_ids(1))
        self.assertEqual({}, self.block.last_version_cells())
コード例 #3
0
ファイル: bii_config_test.py プロジェクト: luckcc/bii-common
    def requirements_update_test(self):
        block_name = BlockName("user/block")
        text = "[requirements]\n # My comment\n"
        config = BiiConfig(text)
        self.assertEqual(config.dumps(), None)

        version = BlockVersion(block_name.default_block(), 0)
        config.requirements = BlockVersionTable([version])
        dumped = config.dumps()
        self.assertEqual(dumped, "[requirements]\n\t user/block: 0\n\n")
        # Dump again, no changes
        self.assertEqual(config.dumps(), None)
        config2 = BiiConfig(dumped)
        self.assertEqual(config2.requirements, config.requirements)

        block_name2 = BlockName("auser2/block2")
        version2 = BlockVersion(block_name2.default_block(), 2)
        config.requirements = BlockVersionTable([version, version2])
        dumped = config.dumps()
        self.assertEqual(
            dumped, "[requirements]\n"
            "\t auser2/block2: 2\n\t user/block: 0\n\n")
        # Dump again, no changes
        self.assertEqual(config.dumps(), None)
        config3 = BiiConfig(dumped)
        self.assertEqual(config3.requirements, config.requirements)
コード例 #4
0
def select_version(hive_holder, biiapi, biiout, block_name, track, time, version_tag):
    dependencies = hive_holder.hive_dependencies.dep_graph.nodes
    dep_block_versions = {x.block_name: x for x in dependencies}
    existing_version = dep_block_versions.get(block_name)
    if existing_version:
        brl_block = block_name + track if track is not None else existing_version.block
        if time is None:
            if version_tag is not None:
                block_version = biiapi.get_version_by_tag(brl_block, version_tag)
            else:
                block_version = BlockVersion(brl_block, existing_version.time)
        else:
            block_version = BlockVersion(brl_block, time)
        if block_version != existing_version:
            biiout.warn("You had in your dependencies %s, but opening %s instead"
                              % (existing_version.to_pretty(), block_version.to_pretty()))
    else:  # Not in dependencies
        brl_block = block_name + track if track is not None else block_name.default_block()
        if time is None:
            if version_tag is not None:
                block_version = biiapi.get_version_by_tag(brl_block, version_tag)
            else:
                # If its an unrelated block we get last version
                block_info = biiapi.get_block_info(brl_block)
                block_version = block_info.last_version
        else:
            block_version = BlockVersion(brl_block, time)

    return block_version
コード例 #5
0
    def _virtual_setup(self):
        ref_translator = Mock()
        depA = BlockVersion(BRLBlock('user/user/blockA/branch'), 4)
        depB = BlockVersion(BRLBlock('user/user/blockB/branch'), 2)
        baseC = BlockVersion(BRLBlock('user/user/blockC/branch'), 3)

        full_graph = BlockVersionGraph()
        full_graph.add_nodes([baseC, depA, depB])
        full_graph.add_edge(baseC, depA)
        full_graph.add_edge(baseC, depB)

        def res_method(*args):
            c_virtual_leaves = [BlockCellName('user/blockC/win/c.h'),
                                BlockCellName('user/blockC/nix/c.h')]
            c_win_deps = [BlockCellName('user/blockA/a.h')]
            c_nix_deps = [BlockCellName('user/blockB/b.h')]

            result = ReferencedResources()
            for ref in args[0].explode():
                result[ref.block_version][ref.ref] = \
                {Reference(depA, 'a.h'): ((0, 0), 0, []),
                 Reference(depB, 'b.h'): ((1, 1), 1, []),
                 Reference(baseC, 'c.h'): ((2, 2), 2, c_virtual_leaves),
                 Reference(baseC, 'win/c.h'): ((3, 3), 3, c_win_deps),
                 Reference(baseC, 'nix/c.h'): ((4, 4), 4, c_nix_deps)}[ref]
            return result

        ref_translator.get_published_min_refs.side_effect = res_method
        return ref_translator, depA, depB, baseC, full_graph
コード例 #6
0
    def test_compatible(self):
        c1 = CompatibilityClosure()
        c2 = CompatibilityClosure()

        brl0 = BRLBlock('user/user/block/master')
        brl1 = BRLBlock('user/user/block2/master')
        v0 = BlockVersion(brl0, 0)
        v1 = BlockVersion(brl0, 1)
        v2 = BlockVersion(brl1, 0)
        v3 = BlockVersion(brl1, 1)

        cell_id1 = ID((0, 0, 0))
        cell_id2 = ID((0, 0, 1))

        content_id1 = ID((0, 0, 0))
        content_id2 = ID((0, 0, 1))

        c1.add_item((cell_id1, content_id1),  cell_id1, v0, 'file1')
        c2.add_item((cell_id1, content_id1),  cell_id1, v1, 'file1')
        self.assertEqual(0, c1.conflicts(c2))
        self.assertEqual(0, c2.conflicts(c1))

        c1.add_item((cell_id2, content_id2),  cell_id2, v2, 'file2')
        c2.add_item((cell_id2, content_id2),  cell_id2, v3, 'file2')
        self.assertEqual(0, c1.conflicts(c2))
        self.assertEqual(0, c2.conflicts(c1))
コード例 #7
0
    def test_diamond_single_solution(self):
        brl_a = BRLBlock('%s/%s/%s/master' % (self.user, self.user, 'blocka'))
        brl_b = BRLBlock('%s/%s/%s/master' % (self.user, self.user, 'blockb'))
        brl_c = BRLBlock('%s/%s/%s/master' % (self.user, self.user, 'blockc'))
        name_a = BlockCellName(self.user + "/blocka/a.h")
        publisher = TestPublisher(self.user, self.store)
        for _ in range(20):
            publisher.publish(brl_a, {'a.h': ('a', [])})

        name_b = BlockCellName(self.user + "/blockb/b.h")
        name_c = BlockCellName(self.user + "/blockc/c.h")

        for i in range(0, 20):
            if i % 2 == 0:
                publisher.publish(brl_b, {'b.h': ('b', [name_a])},
                                  dep_versions=BlockVersion(brl_a, i))
            if (i % 2 == 1 or i == 10):
                publisher.publish(brl_c, {'c.h': ('c', [name_a])},
                                  dep_versions=BlockVersion(brl_a, i))

        request = self.build_unresolved_request([name_b, name_c])
        result = self.service.find(request, BiiResponse())
        self.check_result(result,
                          resolved=[(brl_b, 5, {name_b}),
                                    (brl_c, 5, {name_c})])
コード例 #8
0
    def test_empty(self):
        '''when one is empty, always compatible'''
        c1 = CompatibilityClosure()
        c2 = CompatibilityClosure()
        self.assertEqual(0, c1.conflicts(c2))
        self.assertEqual(0, c2.conflicts(c1))

        brl0 = BRLBlock('user/user/block/master')
        brl1 = BRLBlock('user/user/block2/master')
        v0 = BlockVersion(brl0, 0)
        v2 = BlockVersion(brl1, 0)

        cell_id1 = ID((0, 0, 0))
        cell_id2 = ID((0, 0, 1))

        content_id1 = ID((0, 0, 0))
        content_id2 = ID((0, 0, 1))

        c1.add_item((cell_id1, content_id1),  cell_id1, v0, 'file1')
        self.assertEqual(0, c1.conflicts(c2))
        self.assertEqual(0, c2.conflicts(c1))

        c1.add_item((cell_id2, content_id2),  cell_id2, v2, 'file2')
        self.assertEqual(0, c1.conflicts(c2))
        self.assertEqual(0, c2.conflicts(c1))
コード例 #9
0
    def test_interface(self):
        cell_id1 = ID((0, 0, 0))
        content_id1 = ID((0, 0, 0))
        cell_id2 = ID((0, 1, 0))
        content_id2 = ID((0, 1, 0))
        brl0 = BRLBlock('user/user/block/master')
        brl1 = BRLBlock('user/user/block2/master')
        v0 = BlockVersion(brl0, 0)
        v1 = BlockVersion(brl0, 1)
        v2 = BlockVersion(brl1, 0)

        c1 = CompatibilityClosure()
        c1.add_item((cell_id1, content_id1),  cell_id1, v0, 'file1')
        self.assertEqual("{0:0:0: ((0:0:0, 0:0:0), user/block: 0, 'file1')}", str(c1))

        # adding a compatible item is no problem
        c1.add_item((cell_id1, content_id1),  cell_id1, v1, 'file1')
        self.assertEqual("{0:0:0: ((0:0:0, 0:0:0), user/block: 1, 'file1')}", str(c1))

        c1.add_item((cell_id2, content_id2),  cell_id2, v2, 'file2')
        self.assertIn("0:0:0: ((0:0:0, 0:0:0), user/block: 1, 'file1')", str(c1))
        self.assertIn("0:1:0: ((0:1:0, 0:1:0), user/block2: 0, 'file2')", str(c1))

        self.assertEqual({v0.block_name + 'file1', v2.block_name + 'file2'}, c1.block_cell_names)

        refs = References()
        refs[v1].add('file1')
        refs[v2].add('file2')
        self.assertEqual(refs, c1.references)
コード例 #10
0
 def _publishDependentCell(self, block_id):
     low, high = self._biigraph._get_range_block(block_id)
     count = 0
     d = self.lbcn
     bcn = d[block_id]
     brl = self._getBlockBRL(bcn)
     for row in range(low, high + 1):
         r = SimpleCell(d[block_id])
         r.root = ID((0, bcn.block_name[-1:], 0))
         deps = DependencySet()
         dep_table = BlockVersionTable()
         for block in range(block_id):
             time = self._biigraph._get_dep_elem_offset(row, block)
             if time != -1:
                 deps.add_implicit(d[block])
                 dep_table[d[block].block_name] = \
                    BlockVersion(self._getBlockBRL(d[block]), time)
         r.dependencies = deps
         pack = PublishRequest(BlockVersion(brl, count - 1))
         pack.tag = STABLE
         count += 1
         pack.cells.append(r)
         pack.contents[r.name.cell_name] = Content(
             id_=None, load=Blob('hola {0}'.format(r.name.cell_name)))
         pack.deptable = dep_table
         self.service.publish(pack)
コード例 #11
0
def _get_action_label(action_name, kwargs):
    """For use a third dimension in Ga"""
    try:
        block_version_from_kwargs = lambda kwargs: str(BlockVersion(
                                                       BRLBlock("%s/%s/%s" % (kwargs["owner_name"],
                                                                kwargs["block_name"],
                                                                kwargs["branch_name"])),
                                                                kwargs["version"]))
        if action_name == "get_block_info":
            return str(BRLBlock("%s/%s/%s" % (kwargs["owner_name"],
                                              kwargs["block_name"],
                                              kwargs["branch_name"])))
        elif action_name == "get_version_delta_info":
            return block_version_from_kwargs(kwargs)
        elif action_name == "get_cells_snapshot":
            return str(BlockVersion.deserialize(kwargs["bson_data"]["data"]))
        elif action_name == "get_dep_table":
            return block_version_from_kwargs(kwargs)
        elif action_name == "get_published_resources":
            return ",".join([str(BlockVersion.deserialize(elem[0]))
                             for elem in kwargs["bson_data"]["data"]])
        elif action_name == "publish":
            return str(BlockVersion.deserialize(kwargs["bson_data"]["data"]
                                                [PublishRequest.SERIAL_TRACKED_KEY]))
        elif action_name == "get_renames":
            return ", ".join([str(BlockVersion.deserialize(elem))
                             for elem in kwargs["bson_data"]["data"]])
        else:
            return ""
    except Exception as e:
        logger.error("Error getting label for GA in bii_user_trace %s" % str(e))
        return ""
コード例 #12
0
ファイル: localdb_test.py プロジェクト: MordodeMaru/client
 def test_delete_dep_table(self):
     original_deptable = BlockVersionTable()
     brl_block = BRLBlock('dummy/dummy/block/master')
     block_version = BlockVersion(brl_block, 0)
     self.db.set_dep_table(block_version, original_deptable)
     ID = encode_serialized_value(block_version.serialize())
     self.db.delete(ID, DEP_TABLES)
     self.assertRaises(NotInStoreException, self.db.get_dep_table, block_version)
コード例 #13
0
ファイル: localdb_test.py プロジェクト: toeb/client
 def test_delete_dep_table(self):
     original_deptable = BlockVersionTable()
     brl_block = BRLBlock('dummy/dummy/block/master')
     block_version = BlockVersion(brl_block, 0)
     self.db.set_dep_table(block_version, original_deptable)
     ID = encode_serialized_value(block_version.serialize())
     self.db.delete(ID, DEP_TABLES)
     self.assertRaises(NotInStoreException, self.db.get_dep_table,
                       block_version)
コード例 #14
0
    def test_block_version_table(self):
        mv = BlockVersionTable()
        mv.add_version(BlockVersion('user/user/block/master', 1))
        mv.add_version(BlockVersion('user/user/block/master', 1))
        mv.add_version(BlockVersion('user/user/block/master', 1))

        s = mv.serialize()
        mv2 = BlockVersionTable.deserialize(s)
        self.assertEqual(mv, mv2)
コード例 #15
0
 def test_equals(self):
     brl = BRLBlock("user/user2/module/branch")
     v1 = BlockVersion(brl, 1)
     v2 = BlockVersion(brl, 2)
     self.assertNotEqual(v1, v2)
     self.assertEqual(brl, v1.block)
     self.assertEqual(1, v1.time)
     v3 = BlockVersion(brl, 2)
     self.assertEqual(v2, v3)
     v4 = BlockVersion(brl, 2, '1.2.3')
     self.assertEqual(v3, v4)
コード例 #16
0
 def test_references(self):
     r = References()
     bv3 = BlockVersion(BRLBlock('user/user/block/master'), 3)
     bv4 = BlockVersion(BRLBlock('user/user/block/master'), 4)
     cn0 = CellName('foo.h')
     cn1 = CellName('foo1.h')
     r[bv3].add(cn0)
     r[bv3].add(cn1)
     r[bv4].add(cn0)
     l = r.explode()
     self.assertEqual({(bv3, cn0), (bv3, cn1), (bv4, cn0)}, set(l))
コード例 #17
0
    def test_cell_modify(self):
        '''check between time 1 and 2, a BiiType change'''
        version1 = BlockVersion(self.block, 1)
        version2 = BlockVersion(self.block, 2)
        changes = compare_remote_versions(self.service, version1, version2)

        self.assertEqual(0, len(changes.deleted))
        self.assertEqual(0, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(1, len(changes.modified))
        self.assertEqual(UNKNOWN, changes.modified['r1.h'].old.cell.type)
        self.assertEqual(CPP, changes.modified['r1.h'].new.cell.type)
コード例 #18
0
 def test_content_modify(self):
     '''check between time 0 and 1, just a content edit'''
     version0 = BlockVersion(self.block, 0)
     version1 = BlockVersion(self.block, 1)
     changes = compare_remote_versions(self.service, version0, version1)
     self.assertEqual(0, len(changes.deleted))
     self.assertEqual(0, len(changes.created))
     self.assertEqual(0, len(changes.renames))
     self.assertEqual(1, len(changes.modified))
     diff = compute_diff(changes, resource_diff_function)
     self.assertEqual((None, '--- base\n\n+++ other\n\n@@ -1 +1 @@\n\n'
                       '-hello\n+hello2'), diff.modified['r1.h'])
コード例 #19
0
 def test_hasheable(self):
     brl = BRLBlock("user/user2/module/branch")
     v1 = BlockVersion(brl, 1)
     v2 = BlockVersion(brl, 2)
     v3 = BlockVersion(brl, 2)
     self.assertNotEquals(hash(v1), hash(v2))
     self.assertEquals(hash(v3), hash(v2))
     s = set()
     s.add(v1)
     s.add(v2)
     s.add(v3)
     self.assertEqual(2, len(s))
コード例 #20
0
    def test_basic(self):
        brl1 = BRLBlock("user/user2/block/branch")
        v1 = BlockVersion(brl1, 1)
        brl2 = BRLBlock("user2/user3/block2/branch3")
        v2 = BlockVersion(brl2, 2)

        table = BlockVersionTable()
        table.add_version(v1)
        table.add_version(v2)

        self.assertEqual(v1, table['user2/block'])
        self.assertEqual(v2, table['user3/block2'])
        self.assertEqual(2, len(table))
コード例 #21
0
 def general_load_test(self):
     block_name = BlockName("user/block")
     version = BlockVersion(block_name.default_block(), 0)
     config = BiiConfig(general)
     self.assertEqual(config.parent, version)
     v1 = BlockVersion.loads("user2/depblock2(track): 3 @tag")
     v2 = BlockVersion.loads("user/depblock1(master): 3")
     self.assertEqual(config.requirements, BlockVersionTable([v1, v2]))
     self.assert_bii_equal(config.mains, [EntryPointConfiguration("main.cpp", False),
                                          EntryPointConfiguration("main2.cpp", True),
                                          ])
     self.assert_bii_equal(config.tests, ["test.cpp", "test1.cpp"])
     self.assertEqual(config.paths, ["/", "include"])
コード例 #22
0
ファイル: bii_config_test.py プロジェクト: luckcc/bii-common
 def general_load_test(self):
     block_name = BlockName("user/block")
     version = BlockVersion(block_name.default_block(), 0)
     config = BiiConfig(general)
     self.assertEqual(config.parent, version)
     v1 = BlockVersion.loads("user2/depblock2(track): 3 @tag")
     v2 = BlockVersion.loads("user/depblock1(master): 3")
     self.assertEqual(config.requirements, BlockVersionTable([v1, v2]))
     self.assert_bii_equal(config.mains, [
         EntryPointConfiguration("main.cpp", False),
         EntryPointConfiguration("main2.cpp", True),
     ])
     self.assert_bii_equal(config.tests, ["test.cpp", "test1.cpp"])
     self.assertEqual(config.paths, ["/", "include"])
コード例 #23
0
    def simple_collisions_test(self):
        g1 = BlockVersionGraph()
        g2 = BlockVersionGraph()

        brl0 = BRLBlock('user/user/block/master')
        v0 = BlockVersion(brl0, 0)
        v1 = BlockVersion(brl0, 1)

        g1.add_node(v0)
        g2.add_node(v1)
        expected = BlockVersionGraph()
        expected.add_nodes([v0, v1])
        self.assertEqual(expected, g1.collision(g2))
        self.assertEqual(expected, g2.collision(g1))
コード例 #24
0
    def test_delete(self):
        '''4 => 5 r2.h is deleted'''
        version4 = BlockVersion(self.block, 4)
        version5 = BlockVersion(self.block, 5)
        changes = compare_remote_versions(self.service, version4, version5)

        self.assertEqual(1, len(changes.deleted))
        self.assertEqual(0, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(0, len(changes.modified))
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual('--- base\n\n+++ other\n\n@@ -1 +0,0 @@\n\n-bye',
                         diff.deleted['r2.h'].content)
        self.assertIsNotNone(diff.deleted['r2.h'].cell)
コード例 #25
0
    def test_resource_created(self):
        ''' 3 => 4 cell creation'''
        version3 = BlockVersion(self.block, 3)
        version4 = BlockVersion(self.block, 4)
        changes = compare_remote_versions(self.service, version3, version4)

        self.assertEqual(0, len(changes.deleted))
        self.assertEqual(1, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(0, len(changes.modified))
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual('--- base\n\n+++ other\n\n@@ -0,0 +1 @@\n\n+bye',
                         diff.created['r2.h'].content)
        #TODO: Implement and check diff of cell
        self.assertIsNotNone(diff.created['r2.h'].cell)
コード例 #26
0
ファイル: closure_test.py プロジェクト: luckcc/bii-common
    def test_add_item(self):
        c1 = Closure()
        r1 = Cell('user/block/name1')
        version = BlockVersion(BRLBlock('owner/user/block/branch'), 13)
        biiout = OutputStream()
        resource = Resource(r1, None)
        c1.add_item(resource, version, biiout)
        r2 = Cell('user/block/name1')
        r2.hasMain = True
        resource2 = Resource(r2, None)
        version2 = BlockVersion(BRLBlock('owner/user/block/branch'), 14)
        c1.add_item(resource2, version2, biiout)

        self.assertEqual(ClosureItem(resource, version), c1['user/block/name1'])
        self.assertIn('Incompatible dependency', str(biiout))
コード例 #27
0
    def disjoints_graphs_no_collisions_test(self):
        g1 = BlockVersionGraph()
        g2 = BlockVersionGraph()
        self.assertEqual(BlockVersionGraph(), g1.collision(g2))
        self.assertEqual(BlockVersionGraph(), g2.collision(g1))

        brl0 = BRLBlock('user/user/block/master')
        brl1 = BRLBlock('user/user/block2/master')
        v0 = BlockVersion(brl0, 0)
        v1 = BlockVersion(brl1, 1)

        g1.add_node(v0)
        g2.add_node(v1)
        self.assertEqual(BlockVersionGraph(), g1.collision(g2))
        self.assertEqual(BlockVersionGraph(), g2.collision(g1))
コード例 #28
0
ファイル: publish_request.py プロジェクト: lasote/common
 def deserialize(data):
     '''From dictionary to object Publish Pack'''
     pp = PublishRequest()
     pp.parent = BlockVersion.deserialize(
         data[PublishRequest.SERIAL_TRACKED_KEY])
     pp.parent_time = data[PublishRequest.SERIAL_PARENT_DATETIME]
     pp.tag = VersionTag.deserialize(data[PublishRequest.SERIAL_TAG_KEY])
     pp.msg = data[PublishRequest.SERIAL_MSG_KEY]
     # Backward client compatibility
     pp.versiontag = data.get(PublishRequest.SERIAL_VTAG_KEY, None)
     pp.deptable = BlockVersionTable.deserialize(
         data[PublishRequest.SERIAL_DEP_TABLE])
     pp.cells = ListDeserializer(CellDeserializer(BlockCellName)).\
                         deserialize(data[PublishRequest.SERIAL_CELLS_KEY])
     pp.deleted = ListDeserializer(CellName).\
                         deserialize(data[PublishRequest.SERIAL_DELETED_KEY])
     pp.renames = Renames.deserialize(
         data[PublishRequest.SERIAL_RENAMES_KEY])
     pp.contents = DictDeserializer(CellName, ContentDeserializer(BlockCellName)).\
                     deserialize(data[PublishRequest.SERIAL_CONTENTS_KEY])
     pp.contents_ids = DictDeserializer(CellName, ID).\
                         deserialize(data[PublishRequest.SERIAL_CONTENTS_ID_KEY])
     # Backward client compatibility
     pp.origin = OriginInfo.deserialize(
         data.get(PublishRequest.SERIAL_ORIGIN_INFO, None))
     return pp
コード例 #29
0
 def dumps(self, text=""):
     """ dumps the contents to a text string (with \n LF), if optional param text is passed
     it tries to maintain the comments and structure of such text
     return: text translation of self
     """
     if text:
         result = []
     else:
         result = ['# This file contains your block external dependencies references']
     replaced_versions = []
     for line in text.splitlines():
         line = line.strip()
         if not line or line.startswith('#'):  # Blank and comment lines
             result.append(line)
             continue
         try:
             current_version = BlockVersion.loads(line)
             version = self.get(current_version.block_name)
             if version:
                 result.append(str(version))
                 replaced_versions.append(version)
         except:
             result.append(line)
             continue
     for version in self.itervalues():
         if version not in replaced_versions:
             result.append(str(version))
     result.append('')
     return '\n'.join(result)
コード例 #30
0
ファイル: biiapi_proxy_test.py プロジェクト: toeb/client
    def setUp(self):
        self.folder = self.new_tmp_folder()

        brl_block = BRLBlock('dummy/dummy/block/master')
        self.block_version = BlockVersion(brl_block, 0)

        alf = Resource(SimpleCell("dummy/block/alf.c"),
                       Content(ID((0, 1, 2)), Blob("Hello Alf")))
        alf.cell.ID = ID((0, 1, 2))
        willy = Resource(SimpleCell("dummy/block/willy.c"),
                         Content(ID((0, 1, 3)), Blob("Hello Willy")))
        willy.cell.ID = ID((0, 1, 45))

        self.referenced_resources = ReferencedResources()
        self.referenced_resources[self.block_version].update({
            CellName("alf.c"):
            alf,
            CellName("willy.c"):
            willy
        })
        self.cells_snapshot = [CellName("alf.c"), CellName("willy.c")]
        self.dep_table = BlockVersionTable()

        self.restapi = Mock(BiiAPI)
        self.restapi.get_published_resources.return_value = self.referenced_resources
        self.restapi.get_cells_snapshot.return_value = self.cells_snapshot
        self.restapi.get_dep_table.return_value = self.dep_table
        self.restapi.get_version_delta_info.return_value = BlockDelta(
            '', DEV, None)
        self.localdb = LocalDB(os.path.join(self.folder, 'bii.db'))
        self.proxy = BiiAPIProxy(self.localdb, self.restapi, Mock())
コード例 #31
0
    def test_basic(self):
        store = TestingMemServerStore()
        brl_user = '******'
        store.create_user(User(brl_user))
        brl_block = BRLBlock('user/user/block/master')
        publisher = TestPublisher(brl_user, store)
        publisher.publish(
            brl_block, {
                'r1.h': ('r1', ['user/block/r2.h']),
                'r2.h': ('r2', []),
                'r3.h': ('r3', [])
            })

        store = MemServerStore(store)
        translator = ReferenceTranslatorService(store, brl_user)
        ver = BlockVersion(brl_block, 0)
        missing = References()
        missing[ver].add('r1.h')
        closure = CompatibilityClosure(missing)
        full_graph = BlockVersionGraph()
        full_graph.add_nodes([ver])
        build_compatibility_closure(translator, closure, {ver}, full_graph)
        self.assertEqual(References(), closure.broken)

        expected = set()
        expected.add('user/block/r1.h')
        expected.add('user/block/r2.h')
        self.assertEqual(expected, closure.block_cell_names)
コード例 #32
0
    def test_find_two_files_at_a_time(self):
        """Starts with one include, finds it, then two more includes, finish when all are found.
        Found items are taken into account in FindRequest.existing
        """

        NUM_FILES = 10
        brl_a = BRLBlock('%s/%s/%s/master' % (self.user, self.user, 'blocka'))
        names_a = [
            BlockCellName(self.user + "/blocka/a%d.h" % i)
            for i in range(NUM_FILES)
        ]
        resources_info = {"a%d.h" % i: ("a", []) for i in range(NUM_FILES)}
        publisher = TestPublisher(self.user, self.store)
        publisher.publish(brl_a, resources_info)
        # Use the same request object, to accumulate existing (already found) files
        request = FinderRequest()
        request.policy = Policy.default()
        version = BlockVersion(brl_a, 0)  # The version is always the same
        for i in range(0, NUM_FILES, 2):
            declaration1 = CPPDeclaration(names_a[i])
            declaration2 = CPPDeclaration(names_a[i + 1])
            request.unresolved = {declaration1, declaration2}
            result = self.service.find(request, BiiResponse())
            self.check_result(result,
                              resolved=[(brl_a, 0,
                                         {names_a[i], names_a[i + 1]})])
            # The found one is added to the existing, for next iteration
            request.existing[version][declaration1] = {names_a[i]}
            request.existing[version][declaration2] = {names_a[i + 1]}
            self.assertEqual(len(request.existing[version]), i + 2)
コード例 #33
0
    def dep_overwriten_in_blocks_test(self):
        """ Blocks: C, B (None version)
        Deps: A
        C -> A -> B
        """
        references = References()
        references[va].add('a.h')
        vbn = BlockVersion(vb.block, None)

        b = Resource(SimpleCell('user/blockb/b.h'))
        a = Resource(SimpleCell('user/blocka/a.h'))
        a2 = Resource(SimpleCell('user/blocka/a2.h'))
        a.cell.dependencies.explicit.add(a2.name)
        a2.cell.dependencies.explicit.add(b.name)

        tables = {va: [vb], vb: []}
        api = FakeApi(zip([va, va, vb], [a, a2, b]), tables)
        base_table = BlockVersionTable([vc, vbn])
        biiout = OutputStream()
        graph, closure, _ = build_closure(api,
                                          references,
                                          base_table,
                                          biiout=biiout)
        expected_graph = BlockVersionGraph()
        expected_graph.add_nodes([va])
        expected_graph.add_edge(va, vbn)
        self.assertEqual(expected_graph, graph)
        expected_closure = Closure({
            a.name: ClosureItem(a, va),
            a2.name: ClosureItem(a2, va)
        })
        self.assertEqual(expected_closure, closure)
        self.assertEqual("", str(biiout))
コード例 #34
0
    def test_cell_content_modify(self):
        '''between time 0 and 2 there is content and biitype change'''
        version0 = BlockVersion(self.block, 0)
        version2 = BlockVersion(self.block, 2)
        changes = compare_remote_versions(self.service, version0, version2)

        self.assertEqual(0, len(changes.deleted))
        self.assertEqual(0, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(1, len(changes.modified))
        self.assertEqual(UNKNOWN, changes.modified['r1.h'].old.cell.type)
        self.assertEqual(CPP, changes.modified['r1.h'].new.cell.type)
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual(
            '--- base\n\n+++ other\n\n@@ -1 +1 @@\n\n'
            '-hello\n+hello2', diff.modified['r1.h'].content)
コード例 #35
0
    def test_rename(self):
        version5 = BlockVersion(self.block, 5)
        version6 = BlockVersion(self.block, 6)
        changes = compare_remote_versions(self.service, version5, version6)

        self.assertEqual(1, len(changes.deleted))
        self.assertEqual(1, len(changes.created))
        self.assertEqual(1, len(changes.renames))
        self.assertEqual(0, len(changes.modified))
        self.assertEqual('r3.h', changes.renames['r1.h'])
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual(0, len(diff.deleted))
        self.assertEqual(0, len(diff.created))
        self.assertEqual('', diff.modified['r1.h'].content)
        self.assertIsNotNone(diff.modified['r1.h'].cell)
        self.assertEqual('r3.h', diff.renames['r1.h'])
コード例 #36
0
ファイル: parent.py プロジェクト: Manu343726/biicode-common
    def parents_line_parser(line):
        if line.startswith('*'):
            line = line[1:]

        version = BlockVersion.loads(line)
        if result:
            raise BiiException('Impossible to have two main parents')

        result.append(version)
コード例 #37
0
def _trace_achievement_action(action_name, description, username, async_process):
    try:
        if username:
            if action_name == "publish":  # Uses publish
                register_publish(username, BlockVersion.loads(description),
                                 async_process=async_process)
            elif action_name == "get_version_delta_info":  # User uses biicode
                register_get_version_delta_info(username, async_process=async_process)
    except Exception as e:
        logger.warning("Error sending to action to achievement: %s" % e)
コード例 #38
0
    def test_time_base_map(self):
        t = TimeBaseMap()
        mvt = BlockVersionTable([BlockVersion.loads("user/block: 3")])
        t.append(0, mvt)
        t.append(1, mvt)

        s = serialize(t)
        # print "TIME BASE:"+str(s)
        t2 = TimeBaseMapDeserializer(BlockVersionTable).deserialize(s)
        self.assertEqual(t, t2)
コード例 #39
0
 def test_nonzero_one_file_content(self):
     changes = Changes()
     changes.modified['modified_cont'] = Modification(
                                                 Resource(SimpleCell('usr/block/pretty.js'),
                                                          Content(id_=None, load=Blob('mod_content'))),
                                                 Resource(SimpleCell('usr/block/pretty.js'),
                                                          Content(id_=None, load=Blob('mod_content2'))))
     p = PublishRequest(BlockVersion.loads('usr/block: 3'))
     p.msg = "Test Msg"
     p.changes = changes
     self.assertTrue(bool(p))
コード例 #40
0
    def setUp(self):
        self.store = MongoServerStore(self.conn, self.__class__.__name__)
        self.store = ReverseDependencyMongoStore(self.store)
        bver = BlockVersion.loads("creator/block(owner/branch):2")
        self.bv2 = BlockVersion.loads("creator2/block(owner2/branch):2")
        self.bv3 = BlockVersion.loads("creator3/block(owner3/branch):3")

        self.reverse = ReverseDependency(bver)
        self.reverse.add_dependant_version(self.bv2)
        self.reverse.add_dependant_version(self.bv3)

        self.store.upsert_reverse_dependencies(self.reverse)

        # Other version of same block
        bver2 = BlockVersion.loads("creator/block(owner/branch):3")
        self.reverse2 = ReverseDependency(bver2)
        self.reverse2.add_dependant_version(self.bv2)
        self.reverse2.add_dependant_version(self.bv3)

        self.store.upsert_reverse_dependencies(self.reverse2)
コード例 #41
0
ファイル: migrations.py プロジェクト: gavioto/client
 def migrate(self, *args, **kwargs):
     bii = args[0]
     disk = bii.hive_disk_image
     disk.clean()
     for root, _, _ in os.walk(disk._bii_paths.blocks):
         relative_root = root.replace(disk._bii_paths.blocks + os.sep, "")
         if len(relative_root.split(os.sep)) == 2:
             block = BlockVersion.loads(relative_root.replace(os.sep, "/")).block
             version = bii.biiapi.get_block_info(block).last_version
             if version.time > -1:
                 file_path = os.path.join(root, BII_DIR, "parents.bii")
                 save(file_path, "*%s" % version.to_pretty())
コード例 #42
0
 def test_serialize(self):
     p = PublishRequest(BlockVersion.loads('usr/block: 3'))
     p.msg = "Test Msg"
     p.changes = self._changes()
     serial = p.serialize()
     p2 = PublishRequest.deserialize(serial)
     self.assertEqual(p.parent, p2.parent)
     self.assertEqual(p.tag, p2.tag)
     self.assertEqual(p.msg, p2.msg)
     self.assert_bii_equal(p.cells, p2.cells)
     self.assertEqual(p.contents, p2.contents)
     self.assertEqual(p.contents_ids, p2.contents_ids)
     self.assertEqual(p.deleted, p2.deleted)
     self.assertEqual(p.renames, p2.renames)
コード例 #43
0
    def test_read_and_upsert_reverse_dependencies(self):

        reverse_readed = self.store.read_direct_reverse_dependencies(self.reverse.version)

        self.assertEquals(self.reverse, reverse_readed)

        # Now add directly to mongo a new dependency
        new_ver = BlockVersion.loads("creator3/block3(owner3/branch3):3")
        self.store.add_reverse_dependency_to(self.reverse.version, new_ver)

        reverse_readed = self.store.read_direct_reverse_dependencies(self.reverse.version)

        self.reverse.add_dependant_version(new_ver)
        self.assertEquals(self.reverse, reverse_readed)
コード例 #44
0
    def test_serialize(self):
        bv = BlockVersion("user/user/math/master", 3, '2.7.1')
        s = bv.serialize()
        d = BlockVersion.deserialize(s)
        self.assertEquals(bv, d)

        bv = BlockVersion("user/user/math/master", 3)
        s = bv.serialize()
        d = BlockVersion.deserialize(s)
        self.assertEquals(bv, d)
コード例 #45
0
    def parent_test(self):
        block_name = BlockName("user/block")
        version = BlockVersion(block_name.default_block(), 0)
        for text in (parent1, parent2):
            config = BiiConfig(text)
            self.assertEqual(config.parent, version)
            self.assertEqual(None, config.dumps())

        config = BiiConfig(parent3)
        self.assertEqual(config.parent, None)
        self.assertEqual(None, config.dumps())

        version = BlockVersion.loads("user/block(track): -1")
        config = BiiConfig(parent4)
        self.assertEqual(config.parent, version)
        self.assertEqual(None, config.dumps())
コード例 #46
0
ファイル: publish_request.py プロジェクト: MordodeMaru/common
 def deserialize(data):
     '''From dictionary to object Publish Pack'''
     pp = PublishRequest()
     pp.parent = BlockVersion.deserialize(data[PublishRequest.SERIAL_TRACKED_KEY])
     pp.parent_time = data[PublishRequest.SERIAL_PARENT_DATETIME]
     pp.tag = VersionTag.deserialize(data[PublishRequest.SERIAL_TAG_KEY])
     pp.msg = data[PublishRequest.SERIAL_MSG_KEY]
     # Backward client compatibility
     pp.versiontag = data.get(PublishRequest.SERIAL_VTAG_KEY, None)
     pp.deptable = BlockVersionTable.deserialize(data[PublishRequest.SERIAL_DEP_TABLE])
     pp.cells = ListDeserializer(CellDeserializer(BlockCellName)).\
                         deserialize(data[PublishRequest.SERIAL_CELLS_KEY])
     pp.deleted = ListDeserializer(CellName).\
                         deserialize(data[PublishRequest.SERIAL_DELETED_KEY])
     pp.renames = Renames.deserialize(data[PublishRequest.SERIAL_RENAMES_KEY])
     pp.contents = DictDeserializer(CellName, ContentDeserializer(BlockCellName)).\
                     deserialize(data[PublishRequest.SERIAL_CONTENTS_KEY])
     pp.contents_ids = DictDeserializer(CellName, ID).\
                         deserialize(data[PublishRequest.SERIAL_CONTENTS_ID_KEY])
     # Backward client compatibility
     pp.origin = OriginInfo.deserialize(data.get(PublishRequest.SERIAL_ORIGIN_INFO, None))
     return pp
コード例 #47
0
    def parent_update_test(self):
        block_name = BlockName("user/block")
        text = "[parent]\n # My comment\n"
        config = BiiConfig(text)
        self.assertEqual(config.dumps(), None)

        version = BlockVersion(block_name.default_block(), 0)
        config.parent = version
        dumped = config.dumps()
        self.assertEqual(dumped, "[parent]\n\tuser/block: 0\n")
        # Dump again, no changes
        self.assertEqual(config.dumps(), None)
        config2 = BiiConfig(dumped)
        self.assertEqual(config2.parent, config.parent)

        version2 = BlockVersion.loads("user/block(track): 2")
        config.parent = version2
        dumped = config.dumps()
        self.assertEqual(dumped, "[parent]\n\tuser/block(track): 2\n")
        # Dump again, no changes
        self.assertEqual(config.dumps(), None)
        config3 = BiiConfig(dumped)
        self.assertEqual(config3.parent, config.parent)
コード例 #48
0
 def deserialize(doc):
     return BlockInfo(doc[0], BlockVersion.deserialize(doc[1]), doc[2])
コード例 #49
0
 def deserialize(data):
     return Reference(BlockVersion.deserialize(data[0]), CellName.deserialize(data[1]))
コード例 #50
0
from biicode.common.model.symbolic.block_version import BlockVersion

a1 = BlockVersion.loads('user0/blocka: 1')
a2 = BlockVersion.loads('user0/blocka: 2')
an = BlockVersion.loads('user0/blocka')
b1 = BlockVersion.loads('user0/blockb: 1')
b2 = BlockVersion.loads('user0/blockb: 2')
bn = BlockVersion.loads('user0/blockb')
c1 = BlockVersion.loads('user0/blockc: 1')
cn = BlockVersion.loads('user0/blockc')
c2 = BlockVersion.loads('user0/blockc: 2')
c3 = BlockVersion.loads('user0/blockc: 3')
d1 = BlockVersion.loads('user0/blockd: 1')
dn = BlockVersion.loads('user0/blockd')
e1 = BlockVersion.loads('user0/blocke(user1/branch): 1')
en = BlockVersion.loads('user0/blocke(user1/branch)')
コード例 #51
0
 def test_block_version(self):
     mv = BlockVersion('user/user/block/master', 1)
     s = mv.serialize()
     mv2 = BlockVersion.deserialize(s)
     self.assertEqual(mv, mv2)
コード例 #52
0
 def table_line_parser(line):
     version = BlockVersion.loads(line)
     if version.block_name in result:
         raise BiiException('Duplicate dependency "%s"' % version.to_pretty())
     result.add_version(version)
コード例 #53
0
    def test_loads(self):
        v1 = BlockVersion("user/user/math/master", 3)
        self.assertEqual(v1, BlockVersion.loads('user/math: 3'))
        self.assertEqual(v1, BlockVersion.loads('user/math: 3  # This is a comment'))
        self.assertEqual(v1, BlockVersion.loads('user/math : 3'))
        self.assertEqual(v1, BlockVersion.loads(' user/math(master): 3 '))
        self.assertEqual(v1, BlockVersion.loads('user/math (master) : 3 '))
        self.assertEqual(v1, BlockVersion.loads('user/math (user/master) : 3 '))
        self.assertEqual('user/math: 3', str(v1))

        v1 = BlockVersion("user/user/math/branch", 3)
        self.assertEqual(v1, BlockVersion.loads('user/math(branch): 3'))
        self.assertEqual(v1, BlockVersion.loads('user/math (user/branch) : 3'))
        self.assertEqual('user/math(branch): 3', str(v1))

        v1 = BlockVersion("user2/user/math/branch", 3)
        self.assertEqual(v1, BlockVersion.loads('user/math (user2/branch) : 3'))
        self.assertEqual('user/math(user2/branch): 3', str(v1))

        v1 = BlockVersion("user/user/math/master", None)
        self.assertEqual(v1, BlockVersion.loads(' user/math '))
        self.assertEqual(v1, BlockVersion.loads(' user/math(master) '))
        self.assertEqual(v1, BlockVersion.loads('user/math (user/master) '))
        self.assertEqual('user/math', str(v1))

        v1 = BlockVersion("user/user/math/branch", None)
        self.assertEqual(v1, BlockVersion.loads('user/math(branch) '))
        self.assertEqual(v1, BlockVersion.loads('user/math (user/branch)'))
        self.assertEqual('user/math(branch)', str(v1))

        v1 = BlockVersion("user2/user/math/branch", None)
        self.assertEqual(v1, BlockVersion.loads('user/math (user2/branch) '))
        self.assertEqual('user/math(user2/branch)', str(v1))

        v1 = BlockVersion("user/user/math/master", 30, '2.7.1')
        self.assertEqual(v1, BlockVersion.loads('user/math : 30 @2.7.1'))
        self.assertEqual(v1, BlockVersion.loads('user/math : 30 @2.7.1# This is a comment'))
        self.assertEqual(v1, BlockVersion.loads('user/math : 30 @2.7.1  # This is a comment'))
        self.assertEqual('user/math: 30 @2.7.1', str(v1))

        v1 = BlockVersion("dummy/dummy/myblock/master", -1)
        self.assertEquals(v1, BlockVersion.loads('dummy/myblock: -1'))

        v1 = BlockVersion("dummy/dummy/my-block/master", 2)
        self.assertEquals(v1, BlockVersion.loads('dummy/my-block: 2'))

        v1 = BlockVersion("user0/user0/hello-.__--1/master", 0)
        self.assertEquals(v1, BlockVersion.loads('user0/hello-.__--1: 0'))

        with self.assertRaisesRegexp(BiiException, "Bad block version format"):
            BlockVersion.loads('laso/block:invalidversion')

        v1 = BlockVersion("dummy/dummy/first/master", None, "1.12")
        self.assertEquals(v1, BlockVersion.loads('dummy/first @1.12'))

        v1 = BlockVersion.loads("user/math: @DEV ")
        self.assertEqual(v1.block, "user/user/math/master")
        self.assertEqual(v1.time, None)
        self.assertEqual(v1.tag, "DEV")

        v1 = BlockVersion.loads("user/math: 1 @1.2   # My comment")
        self.assertEqual(v1.block, "user/user/math/master")
        self.assertEqual(v1.time, 1)
コード例 #54
0
import unittest

from biicode.common.model.symbolic.block_version import BlockVersion
from biicode.common.deps.block_version_graph import BlockVersionGraph
from biicode.common.deps.block_version_graph_builder import \
    compute_effective, block_version_graph_build
from biicode.common.test.deps.deps_api import DepsApiFake
from biicode.common.model.symbolic.block_version_table import BlockVersionTable


a1 = BlockVersion.loads('user0/blocka: 1')
a2 = BlockVersion.loads('user0/blocka: 2')
an = BlockVersion.loads('user0/blocka')
b1 = BlockVersion.loads('user0/blockb: 1')
b2 = BlockVersion.loads('user0/blockb: 2')
bn = BlockVersion.loads('user0/blockb')
c1 = BlockVersion.loads('user0/blockc: 1')
c2 = BlockVersion.loads('user0/blockc: 1')
c3 = BlockVersion.loads('user0/blockc: 3')
cn = BlockVersion.loads('user0/blockc')
d1 = BlockVersion.loads('user0/blockd: 1')


class BlockVersionGraphBuilderTest(unittest.TestCase):

    def test_compose(self):
        t1 = BlockVersionTable([a1])
        t2 = BlockVersionTable([b1])
        effective, propagate, overwrites = compute_effective(t1, t2, 'user0/blocka')
        self.assertEqual(effective, BlockVersionTable([b1]))
        self.assertEqual(propagate, BlockVersionTable([b1]))
コード例 #55
0
ファイル: api_v1.py プロジェクト: biicode/bii-server
def get_cells_snapshot(auth_user, bson_data):
    """Get all cell names from a specific BlockVersion"""
    service = BiiService(app.store, auth_user)
    blockversion = BlockVersion.deserialize(bson_data["data"])
    return service.get_cells_snapshot(blockversion)
コード例 #56
0
import unittest
from biicode.common.edition.hive_holder import HiveHolder
from biicode.common.model.symbolic.block_version import BlockVersion
from biicode.common.model.symbolic.block_version_table import BlockVersionTable
from biicode.common.model.resource import Resource
from biicode.common.model.cells import SimpleCell
from biicode.common.model.content import Content
from biicode.common.model.blob import Blob
from biicode.common.edition.block_holder import BlockHolder, BIICODE_FILE

a1 = BlockVersion.loads('user0/blocka: 1')
an = BlockVersion.loads('user0/blocka')
b2 = BlockVersion.loads('user0/blockb(branch): 2')
bn = BlockVersion.loads('user0/blockb(branch)')
cn = BlockVersion.loads('user0/blockc: -1')


class HiveHolderTest(unittest.TestCase):

    def base_version_test(self):
        hive_holder = HiveHolder({}, {})
        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]))
コード例 #57
0
ファイル: api_v1.py プロジェクト: biicode/bii-server
def diff(auth_user, bson_data):
    service = BiiService(app.store, auth_user)
    baseVersion = BlockVersion.deserialize(bson_data["base"])
    otherVersion = BlockVersion.deserialize(bson_data["other"])
    return service.compute_diff(baseVersion, otherVersion)
コード例 #58
0
ファイル: biicommand.py プロジェクト: MordodeMaru/client
def block_version(argument):
    return argument if isinstance(argument, BlockVersion) else BlockVersion.loads(argument)