コード例 #1
0
 def test_find_mains(self):
     '''basic check that header is implemented by source'''
     resources = {
         'blink.h':
         Resource(
             SimpleCell('usr/block/blink.h', CPP),
             Content(id_=None, load=Blob(header), parser=DRLCPPParser())),
         'blink.cpp':
         Resource(
             SimpleCell('usr/block/blink.cpp', CPP),
             Content(id_=None,
                     load=Blob(implementation),
                     parser=DRLCPPParser())),
         'mainblink.cpp':
         Resource(SimpleCell('usr/block/mainblink.cpp', CPP),
                  Content(id_=None, load=Blob(main), parser=DRLCPPParser()))
     }
     block_holder = BlockHolder(BlockName('user/block'), resources)
     for r in resources.itervalues():
         r.content.parse()
         r.content.updated = False
     processor = ArduinoEntryPointProcesor()
     processor.do_process(block_holder, Mock())
     mainblink = block_holder['mainblink.cpp'].cell
     content = block_holder['mainblink.cpp'].content
     self.assertTrue(mainblink.hasMain)
     self.assertFalse(content.updated)
     self.assertFalse(content.blob_updated)
コード例 #2
0
    def test_delete_main(self):
        r1 = SimpleCell('user/block/r1.h', CPP)
        r2 = SimpleCell('user/block/r2.cpp', CPP)
        r3 = SimpleCell('user/block/r3.cpp', CPP)
        r4 = SimpleCell('user/block/' + BIICODE_FILE)

        res = {
            r1.name: Resource(r1, Content(None, Blob(''))),
            r2.name: Resource(r2, Content(None, Blob(''))),
            r3.name: Resource(r3, Content(None,
                                          Blob('int main(char* argv){}'))),
            r4.name: Resource(r4, Content(None, Blob('[mains]\n !r3.cpp')))
        }

        block_holder = BlockHolder(BlockName('user/block'), res)

        process_holder(block_holder, ParseProcessor())
        self.assertTrue(res['user/block/r3.cpp'].cell.hasMain)

        changes, _ = process_holder(block_holder, MainConfigProcessor())
        # Checks
        self.assertFalse(res['user/block/r1.h'].cell.hasMain)
        self.assertFalse(res['user/block/r2.cpp'].cell.hasMain)
        self.assertFalse(res['user/block/r3.cpp'].cell.hasMain)
        self.assertEqual(0, len(changes.upserted))
コード例 #3
0
ファイル: blob_test.py プロジェクト: MordodeMaru/common
    def testSysToNormalized(self):
        cl = Blob()
        cl.text = self.sys_text
        self.assertEqual(self.nor_text, cl.text)

        cl.text = self.win_text
        self.assertEqual(self.nor_text, cl.text)
コード例 #4
0
    def testSysToNormalized(self):
        cl = Blob()
        cl.text = self.sys_text
        self.assertEqual(self.nor_text, cl.text)

        cl.text = self.win_text
        self.assertEqual(self.nor_text, cl.text)
コード例 #5
0
 def obtain_types_blobs_test(self):
     files = {'afile1.c': 'Hello',
              'bii/file2.c': 'Bye'}
     result = obtain_types_blobs(files)
     self.assertEqual({'afile1.c': (CPP, Blob('Hello')),
                       'bii/file2.c': (CPP, Blob('Bye'))},
                      result)
コード例 #6
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())
コード例 #7
0
ファイル: blob_test.py プロジェクト: MordodeMaru/common
    def testNormSetter(self):
        cl = Blob()
        c2 = Blob()
        cl.text = self.nor_text
        c2.text = self.sys_text
        self.assertEqual(cl, c2)

        c2.compressedBin = self.compressed
        self.assertEqual(cl, c2)
コード例 #8
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))
コード例 #9
0
    def test_content(self):
        #Content with ContentID
        c = Content(ID((0, 1, 2)), load=Blob("Hello"))
        s = c.serialize()
        c2 = ContentDeserializer(ID).deserialize(s)
        self.assertEqual(c, c2)

        #Content with BlockCellName
        c = Content(BlockCellName("user/block/path/to/file.h"),
                    load=Blob("Bye"))
        s = c.serialize()
        c2 = ContentDeserializer(BlockCellName).deserialize(s)
        self.assertEqual(c, c2)
コード例 #10
0
    def test_mains_with_filter(self):
        r1 = SimpleCell('user/block/r1.h', CPP)
        r2 = SimpleCell('user/block/r2.cpp', CPP)
        r3 = SimpleCell('user/block/no_mains/r3.cpp', CPP)
        r4 = SimpleCell('user/block/no_mains/r4.cpp', CPP)
        r5 = SimpleCell('user/block/' + BIICODE_FILE)
        r6 = SimpleCell('user/block/new_mains/r6.cpp', CPP)
        r7 = SimpleCell('user/block/new_mains/r7.cpp', CPP)
        r8 = SimpleCell('user/block/exe_file1.hh', CPP)
        r9 = SimpleCell('user/block/exe_file2.hh', CPP)

        res = {
            r1.name:
            Resource(r1, Content(None, Blob(''))),
            r2.name:
            Resource(r2, Content(None, Blob(''))),
            r3.name:
            Resource(r3, Content(None, Blob('int main(char* argv){}'))),
            r4.name:
            Resource(r4, Content(None, Blob('int main(char* argv){}'))),
            r5.name:
            Resource(
                r5,
                Content(None,
                        Blob('[mains]\n!no_mains/*\nnew_mains/*\n*.hh'))),
            r6.name:
            Resource(r6, Content(None, Blob(''))),
            r7.name:
            Resource(r7, Content(None, Blob(''))),
            r8.name:
            Resource(r8, Content(None, Blob(''))),
            r9.name:
            Resource(r9, Content(None, Blob('')))
        }

        block_holder = BlockHolder(BlockName('user/block'), res)

        process_holder(block_holder, ParseProcessor())
        self.assertTrue(res['user/block/no_mains/r3.cpp'].cell.hasMain)
        self.assertTrue(res['user/block/no_mains/r4.cpp'].cell.hasMain)
        self.assertFalse(res['user/block/new_mains/r6.cpp'].cell.hasMain)
        self.assertFalse(res['user/block/new_mains/r7.cpp'].cell.hasMain)
        self.assertFalse(res['user/block/exe_file1.hh'].cell.hasMain)
        self.assertFalse(res['user/block/exe_file2.hh'].cell.hasMain)

        process_holder(block_holder, MainConfigProcessor())

        # Checks
        self.assertFalse(res['user/block/r1.h'].cell.hasMain)
        self.assertFalse(res['user/block/r2.cpp'].cell.hasMain)
        self.assertFalse(res['user/block/no_mains/r3.cpp'].cell.hasMain)
        self.assertFalse(res['user/block/no_mains/r4.cpp'].cell.hasMain)
        self.assertTrue(res['user/block/new_mains/r6.cpp'].cell.hasMain)
        self.assertTrue(res['user/block/new_mains/r7.cpp'].cell.hasMain)
        self.assertTrue(res['user/block/exe_file1.hh'].cell.hasMain)
        self.assertTrue(res['user/block/exe_file2.hh'].cell.hasMain)
コード例 #11
0
ファイル: hive_holder_test.py プロジェクト: luckcc/bii-common
 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]))
コード例 #12
0
    def test_size_reject_accept(self):
        self.load.binary = bytearray(BII_FILE_SIZE_LIMIT)
        load2 = Blob()
        load2.binary = bytearray(BII_FILE_SIZE_LIMIT - 1)
        files = {"user/block/filelarge":  (None, self.load),
                 "user/block/filesmall": (None, load2)}

        biiout = OutputStream()
        changevalidator.remove_large_cells(files, biiout)
        self.assertEquals(1, len(files))
        self.assertEquals("WARN: File user/block/filelarge is "
                          "bigger than %s: discarded\n" % BII_FILE_SIZE_LIMIT_STR,
                          str(biiout))
        self.assertIn("user/block/filesmall", files)
コード例 #13
0
 def _changes():
     changes = Changes()
     changes.deleted['deleted'] = Resource(None, 'old_content')
     changes.deleted['renamed'] = Resource(
         SimpleCell('usr/block/renamed'),
         Content(ID((1234, )), load=Blob('old_content2')))
     changes.created['created'] = Resource(
         SimpleCell('usr/block/created'),
         Content(id_=None, load=Blob('created')))
     changes.created['renamed2'] = Resource(
         SimpleCell('usr/block/renamed2'),
         Content(id_=None, load=Blob('old_content2')))
     changes.modified['modified_cont'] = Modification(
         Resource(SimpleCell('usr/block/modified_cont'),
                  Content(id_=None, load=Blob('mod_content'))),
         Resource(SimpleCell('usr/block/modified_cont'),
                  Content(id_=None, load=Blob('mod_content2'))))
     changes.modified['modified_cell'] = Modification(
         Resource(SimpleCell('usr/block/modified_cell'),
                  Content(id_=None, load=Blob('mod_cell'))),
         Resource(SimpleCell('usr/block/modified_cell', CPP),
                  Content(id_=None, load=Blob('mod_cell'))))
     changes.modified['modified_both'] = Modification(
         Resource(SimpleCell('usr/block/modified_both'),
                  Content(id_=None, load='mod_both')),
         Resource(SimpleCell('usr/block/modified_both', CPP),
                  Content(id_=None, load=Blob('mod_both2'))))
     changes.renames = Renames({'renamed': 'renamed2'})
     return changes
コード例 #14
0
    def testEqualsSameSetter(self):
        cl = Blob()
        c2 = Blob()
        cl.text = self.sys_text
        c2.text = self.nor_text
        self.assertEqual(cl, c2)

        cl.normalizedText = self.nor_text
        c2.normalizedText = self.nor_text
        self.assertEqual(cl, c2)

        cl.compressedBin = self.compressed
        c2.compressedBin = self.compressed
        self.assertEqual(cl, c2)
コード例 #15
0
    def test_normalize(self, text):
        blob = Blob(text)
        self.assertEqual(blob.bytes, unix_text)
        self.assertEqual(blob.sha, "ac517966fd59bb4bd3731273b8fbc96414866eda")
        self.assertEqual(blob, Blob(win_text))
        self.assertNotEqual(blob, Blob("Hello"))
        self.assertEqual(blob.load, sys_text)

        s = blob.serialize()
        self.assertEqual(s['c'], compressed)

        blob3 = Blob.deserialize(s)
        self.assertEqual(blob, blob3)
        self.assertEqual(blob3.bytes, unix_text)
コード例 #16
0
def publish_pack_add(pack, block_cell_name, content_text):
    name = BlockCellName(block_cell_name)
    cell1 = SimpleCell(name)
    pack.cells.add(cell1)
    pack.contents[name.cell_name] = Content(
        load=Blob(content_text))  # it MUST have a content to be deleted
    return cell1
コード例 #17
0
def make_content(brl, lang=BiiType(UNKNOWN), read_file=True):
    '''Reads a test file as binary or systext depending on lang
    Parameters:
        brl: BlockCellName or ID
    '''
    if isinstance(lang, int):
        lang = BiiType(lang)
    binary = lang.is_binary()
    if isinstance(brl, basestring):
        name = '/'.join(brl.split('/')[1:])
        parser = parser_factory(lang, brl.split('/')[-1])
    if read_file:
        blob = Blob(path=testfileutils.file_path(name), is_binary=binary)
    else:
        blob = Blob("Blob example content", is_binary=binary)
    return Content(brl, blob, parser)
コード例 #18
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)
コード例 #19
0
ファイル: localdb_test.py プロジェクト: toeb/client
    def test_store_published_resources(self):
        s = References()
        brl_block = BRLBlock('dummy/dummy/block/master')
        block_version = BlockVersion(brl_block, 0)
        s[block_version] = [
            CellName("alf.c"),
            CellName("willy.c"),
            CellName('maya.h'),
            CellName('win/maya.h'),
            CellName('nix/maya.h')
        ]

        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))
        maya_v = Resource(VirtualCell("dummy/block/maya.h"), None)
        maya_v.cell.ID = ID((0, 1, 3))
        maya_win = Resource(SimpleCell("dummy/block/win/maya.h"),
                            Content(ID((0, 1, 4)), Blob("Hello Maya")))
        maya_win.cell.ID = ID((0, 1, 4))
        maya_nix = Resource(SimpleCell("dummy/block/nix/maya.h"),
                            Content(ID((0, 1, 5)), Blob("Hello Maya")))
        maya_nix.cell.ID = ID((0, 1, 5))

        # Expected return
        referenced_resources = ReferencedResources()
        referenced_resources[block_version].update({
            CellName("alf.c"):
            alf,
            CellName("willy.c"):
            willy,
            CellName('maya.h'):
            maya_v,
            CellName('win/maya.h'):
            maya_win,
            CellName('nix/maya.h'):
            maya_nix,
        })

        self.db.create_published_resources(referenced_resources)
        retrieved = self.db.get_published_resources(s)

        self.assertEquals(referenced_resources, retrieved)
コード例 #20
0
 def setUp(self):
     testUser = BRLUser('compareUser')
     self.brl_block = BRLBlock('%s/%s/%s/master' %
                               (testUser, testUser, 'modulea'))
     r1 = SimpleCell(self.brl_block.block_name + 'r1.h')
     content = Content(id_=None, load=Blob('hello'))
     self.r1 = r1
     self.c1 = content
     self.last_version_resources = {'r1.h': Resource(r1, content)}
コード例 #21
0
ファイル: cmaketool.py プロジェクト: toeb/client
 def _create_vars_cmake_files(self, block_targets):
     b = False
     for block_target in block_targets.itervalues():
         bii_vars_path = os.path.join(self.bii_paths.cmake,
                                      block_target.filename)
         modified = save_blob_if_modified(bii_vars_path,
                                          Blob(block_target.dumps()))
         b = b or modified
     return b
コード例 #22
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)
コード例 #23
0
def get_block_holder(block_name, resources_defs):
    resources = {}
    for cell_name, (typ, text) in resources_defs.iteritems():
        if typ is None:
            typ = UNKNOWN
        cell = SimpleCell(block_name + cell_name, typ)
        resources[cell_name] = Resource(
            cell, Content(block_name + cell_name, load=Blob(text)))
    return BlockHolder(block_name, resources)
コード例 #24
0
    def _prepare_context(self, my_conf):
        if my_conf:
            my_conf = "[dependencies]\n " + my_conf
        self.processor = DependenciesConfigurationProcessor()
        self.r1 = BlockCellName('user/block/r1.h')
        self.r2 = BlockCellName('user/block/r2.cpp')
        self.r3 = BlockCellName('user/block/r3.cpp')
        r1 = SimpleCell(self.r1, CPP)
        r2 = SimpleCell(self.r2, CPP)
        r3 = SimpleCell('user/block/r3.cpp', CPP)

        r4 = SimpleCell('user/block/' + BIICODE_FILE)
        res = {
            r1.name: Resource(r1, Content(None, Blob("hi"))),
            r2.name: Resource(r2, Content(None, Blob("hi"))),
            r3.name: Resource(r3, Content(None, Blob("hi"))),
            r4.name: Resource(r4, Content(None, Blob(my_conf)))
        }
        return BlockHolder(BlockName('user/block'), res)
コード例 #25
0
    def test_large_cell_reject(self):
        load = Blob("x" * (BII_FILE_SIZE_LIMIT))
        files = {"user/block/file": (None, load)}

        biiout = OutputStream()
        changevalidator.remove_large_cells(files, biiout)
        self.assertEquals(0, len(files))
        self.assertEquals(
            "WARN: File user/block/file is bigger "
            "than %s: discarded\n" % BII_FILE_SIZE_LIMIT_STR, str(biiout))
コード例 #26
0
ファイル: content.py プロジェクト: luckcc/bii-common
 def update_content_declaration(self, decl, new_decl):
     # Now it is only used for version upgrades that involve a rename
     assert isinstance(decl, Declaration)
     assert isinstance(new_decl, Declaration)
     #if self._parser and new_decl:
     new_text = self._parser.updateDeclaration(self._load.bytes, decl, new_decl)
     if new_text:
         self._load = Blob(new_text)
         self._blob_updated = True
         self._parser_updated = True
コード例 #27
0
    def _create_py_file(self, py_adapter_file_content, main):
        """Write python file content to src block root if content has changed.
        :param
            py_adapter_file_content: str with python adapter file content.
            main: BlockCellName of main target.
        """
        py_adapter_file_path = os.path.join(self.paths.src, main.block_name,
                                            main.cell_name.path,
                                            self.ADAPTER_FILE_NAME)
        file_content = Blob(py_adapter_file_content)

        try:
            old_content = Blob(file_utils.load(py_adapter_file_path))
        except:
            old_content = None

        if file_content != old_content:
            logger.debug("biipyc has changed or was created.")
            file_utils.save(py_adapter_file_path, file_content.load)
コード例 #28
0
    def test_create_resource(self):

        r1 = SimpleCell(self.brl_block.block_name + 'r1.h')
        content = Content(id_=None, load=Blob('hello'))

        r2 = SimpleCell(self.brl_block.block_name + 'r2.h')
        content2 = Content(id_=None, load=Blob('bye'))

        edition_resources = {
            'r1.h': Resource(r1, content),
            'r2.h': Resource(r2, content2)
        }
        changes = compare(self.last_version_resources, edition_resources)

        self.assertEqual(0, len(changes.deleted))
        self.assertEqual(1, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(0, len(changes.modified))
        self.assertEqual(Resource(r2, content2), changes.created['r2.h'])
コード例 #29
0
    def testSysSetter(self):
        cl = Blob()
        c2 = Blob()
        cl.text = self.sys_text
        c2.text = self.nor_text
        self.assertEqual(cl, c2)

        c2.compressedBin = self.compressed
        self.assertEqual(cl, c2)
コード例 #30
0
ファイル: biiapi_test.py プロジェクト: pombredanne/bii-server
    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)
コード例 #31
0
ファイル: cmaketool.py プロジェクト: toeb/client
    def _create_cmakelists(self, block_targets):
        '''creates 3 files:
        CMakeLists.txt, only if not existing, including the other two files
        bii_targets.cmake, the file containing the ADD_LIBRARY and ADD_EXECUTABLES, with the
                        configuration of flags per target and files
        bii_vars.cmake, is a file with variables declarations that are afterwards used in
                        bii_targets.cmake'''
        cmakelists_path = os.path.join(self.bii_paths.cmake, "CMakeLists.txt")
        bii_macros_path = os.path.join(self.bii_paths.cmake, 'biicode.cmake')
        bii_macros_content = load_resource(DEV_CPP_DIR, "cmake/biicode.cmake")

        self._create_default_blocks_cmakelists(block_targets)
        # following is a virtual call, may call child class method
        cmakelists_content = self._get_project_cmakelists(block_targets)

        a = save_blob_if_modified(cmakelists_path, Blob(cmakelists_content))
        b = self._create_vars_cmake_files(block_targets)
        c = save_blob_if_modified(bii_macros_path, Blob(bii_macros_content))

        return a or b or c
コード例 #32
0
ファイル: content.py プロジェクト: MordodeMaru/common
 def deserialize(self, data):
     '''From dictionary to object Content'''
     if data is None:
         return None
     try:
         return Content(id_=self.id_type.deserialize(data[Content.SERIAL_ID_KEY]),
                        load=Blob.deserialize(data[Content.SERIAL_LOAD_KEY]),
                        parser=Parser.deserialize(data[Content.SERIAL_PARSER_KEY]),
                        is_parsed=data[Content.SERIAL_IS_PARSED_KEY],
                        )
     except Exception as e:
         raise BiiSerializationException('Could not deserialize Content: %s' % str(e))
コード例 #33
0
 def test_set_changes(self):
     p = PublishRequest()
     changes = self._changes()
     p.changes = changes
     self.assertTrue(bool(p))
     self.assertItemsEqual(['deleted', 'renamed'], p.deleted)
     self.assertEqual(changes.renames, p.renames)
     self.assertEqual(
         {
             SimpleCell('usr/block/created'),
             SimpleCell('usr/block/renamed2'),
             SimpleCell('usr/block/modified_cell', CPP),
             SimpleCell('usr/block/modified_both', CPP)
         }, set(p.cells))
     self.assertEqual(
         {
             'created': Content(id_=None, load=Blob('created')),
             'modified_cont': Content(id_=None, load=Blob('mod_content2')),
             'modified_both': Content(id_=None, load=Blob('mod_both2'))
         }, p.contents)
     self.assertEqual({'renamed2': ID((1234, ))}, p.contents_ids)
コード例 #34
0
    def test_create_missing_simple_resources(self):
        resources = {'bii/virtual.bii': Resource(SimpleCell('user/block/bii/virtual.bii'),
                                                  Content(None, Blob(myConf1)))}
        self.block_holder = BlockHolder(BlockName('user/block'), resources)

        VirtualConfigurationProcessor().do_process(self.block_holder, OutputStream())

        self._sphere_os_checks('sphere.h')
        self._sphere_os_checks('sphere.cpp')

        self.assertEqual(None, self.block_holder['sphere.h'].content)
        self.assertEqual(None, self.block_holder['sphere.cpp'].content)
コード例 #35
0
ファイル: blob_test.py プロジェクト: MordodeMaru/common
    def testEqualsSameSetter(self):
        cl = Blob()
        c2 = Blob()
        cl.text = self.sys_text
        c2.text = self.nor_text
        self.assertEqual(cl, c2)

        cl.normalizedText = self.nor_text
        c2.normalizedText = self.nor_text
        self.assertEqual(cl, c2)

        cl.compressedBin = self.compressed
        c2.compressedBin = self.compressed
        self.assertEqual(cl, c2)
コード例 #36
0
 def test_similarity(self):
     cl = Blob(win_text)
     c2 = Blob(unix_text)
     self.assertEquals(cl.similarity(c2), 1.0)
コード例 #37
0
 def test_similarity_binary_distinct(self):
     cl = Blob("Hello", True)
     cl2 = Blob("Hello1", True)
     self.assertEquals(cl.similarity(cl2), 0.0)
コード例 #38
0
ファイル: blob_test.py プロジェクト: MordodeMaru/common
 def test_similarity(self):
     cl = Blob()
     c2 = Blob()
     cl.text = self.nor_text
     c2.text = self.nor_text
     self.assertEquals(cl.similarity(c2), 1.0)
コード例 #39
0
ファイル: blob_test.py プロジェクト: MordodeMaru/common
 def test_similarity_binary(self):
     cl = Blob(self.compressed, True)
     cl2 = Blob(self.compressed, True)
     self.assertEquals(cl.similarity(cl2), 1.0)
コード例 #40
0
 def test_blob(self):
     c = Blob('hello')
     s = c.serialize()
     c2 = Blob.deserialize(s)
     self.assertEqual(c, c2)
コード例 #41
0
ファイル: blob_test.py プロジェクト: MordodeMaru/common
 def test_similarity_binary_distinct(self):
     cl = Blob(self.nor_text, True)
     cl2 = Blob(self.compressed, True)
     self.assertEquals(cl.similarity(cl2), 0.0)
コード例 #42
0
ファイル: blob_test.py プロジェクト: MordodeMaru/common
 def testCompress(self):
     cl = Blob()
     cl.text = self.nor_text
     self.compressedBin = cl._compressed()
     self.assertEqual(self.nor_text, cl.text)
コード例 #43
0
ファイル: blob_test.py プロジェクト: MordodeMaru/common
 def testEncodeAndDecode(self):
     cl = Blob()
     cl.text = self.nor_text
     self.binary = cl.binary
     self.assertEqual(self.nor_text, cl.text)
コード例 #44
0
ファイル: blob_test.py プロジェクト: MordodeMaru/common
 def testSysTextNotModified(self):
     cl = Blob()
     cl.text = self.sys_text
     self.assertEqual(BlobUnitTest.sys_text, cl.load)
コード例 #45
0
ファイル: blob_test.py プロジェクト: MordodeMaru/common
 def testNormalizedTextNotModified(self):
     cl = Blob()
     cl.normalizedText = self.nor_text
     self.assertEqual(self.nor_text, cl.normalizedText)