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)
Example #2
0
 def blockname_test(self):
     m = BlockName("user/block")
     self.assertEquals("user/block", str(m))
     m = BlockName("user/bLOck")
     self.assertEquals("user/bLOck", str(m))
     self.assertEquals('bLOck', str(m.name))
     m = BlockName("uSer/bLOck")
     self.assertEquals("uSer/bLOck", str(m))
 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"])
Example #4
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"])
Example #5
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)
 def _cells_setup(self, block_name, cells_names, biitype):
     resources = []
     block_name = BlockName(block_name)
     for x in cells_names:
         cell = SimpleCell(block_name + x, BiiType(biitype))
         resources.append(Resource(cell, Mock()))
     return BlockHolder(block_name, resources)
    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())
Example #8
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())
Example #9
0
 def parse_dependencies(line):
     tokens = line.strip().split(':', 1)
     if len(tokens) != 2:
         raise ConfigurationFileError(
             'Every entry in layout should be NAME: RELATIVE PATH')
     name, value = tokens
     if name not in default_layout:
         raise ConfigurationFileError('Unknown layout entry %s' % name)
     # relative path between tmp and project with the project name as dest folder
     if "$TMP" in value:
         try:
             tmp_rel_folder = os.path.join(
                 os.path.relpath(tempfile.gettempdir(), project_root),
                 os.path.basename(project_root)).replace('\\', '/')
         except Exception:
             raise ConfigurationFileError(
                 "Unable to compute relative path to $TMP folder "
                 "in layout.bii\nYou are probably in another drive "
                 "to your tmp folder")
         value = value.replace("$TMP", tmp_rel_folder)
     value = value.strip()
     if value == "/" or value.lower() == "false":
         value = ""
     if name == ROOT_BLOCK:
         value = BlockName(value)
     current_layout[name] = value
Example #10
0
 def test_anonymous_block():
     bii_paths = BiiPathsMock(
         self.folder,
         'root-block: {}\nauto-root-block: True'.format(block_name),
         self.user_home)
     return walk_anonymous_block(bii_paths, bii_ignore, self.biiout,
                                 BlockName(block_name))
Example #11
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))
Example #12
0
 def testLowerCaseBackslashConversion(self):
     brl = BRLBlock("Drodri\Pedro/geOm\Mybranch")
     self.assertEqual(BRLUser('Drodri'), brl.owner)
     self.assertEqual('Drodri', brl.owner)
     self.assertEqual('Pedro/geOm', brl.block_name)
     self.assertEqual(BlockName('Pedro/geOm'), brl.block_name)
     self.assertEqual(ComplexName('mybranch'), brl.branch)
     self.assertEqual('mybranch', brl.branch)
Example #13
0
 def testParsing(self):
     brl = BRLBlock("drodri/pedro/geom/mybranch")
     self.assertEqual(BRLUser('drodri'), brl.owner)
     self.assertEqual('drodri', brl.owner)
     self.assertEqual('pedro/geom', brl.block_name)
     self.assertEqual(BlockName('pedro/geom'), brl.block_name)
     self.assertEqual(ComplexName('mybranch'), brl.branch)
     self.assertEqual('mybranch', brl.branch)
Example #14
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)
Example #15
0
        def check_file(file_, expected_content):
            key = BlockName(block_name) + file_
            self.assert_(key in collected_files.keys(),
                         '"{}" file not collected'.format(file_))

            content = collected_files[key]
            self.assertEqual(
                content, expected_content, '"{}" file content does not match:'
                ' "{}", expected "{}"'.format(file_, content,
                                              expected_content))
Example #16
0
    def testCycles2(self):
        g = DirectedGraph()
        for i in range(2):
            g.add_node(BlockName("user/mod%d" % i))

        g.add_edge(BlockName("user/mod0"), BlockName("user/mod1"))
        g.add_edge(BlockName("user/mod1"), BlockName("user/mod0"))
        self.assertEqual({BlockName("user/mod0"),
                          BlockName("user/mod1")}, set(g.get_cycles()))
Example #17
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)
Example #18
0
    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)
Example #19
0
 def update_root_block(self):
     if self._bii_paths.auto_root_block:
         bii_config_path = os.path.join(self._bii_paths.project_root,
                                        "biicode.conf")
         parent = (None if not os.path.exists(bii_config_path) else
                   BiiConfig(Blob(load(bii_config_path)).bytes).parent)
         if parent:
             project_block = parent.block_name
         else:  # Get the root block name from user + folder
             project_name = self._bii_paths.project_name
             user = self._user_cache.username or "user"
             project_block = BlockName("%s/%s" % (user, project_name))
         self._bii_paths.root_block = project_block
Example #20
0
    def prepare_context(self, config):
        r1 = SimpleCell('user/block/r1.h')
        r2 = SimpleCell('user/block/r2.cpp')
        r3 = SimpleCell('user/block2/r3.cpp')
        r4 = SimpleCell('user/block/' + BIICODE_FILE)

        self.res = {r1.name: Resource(r1, None),
                    r2.name: Resource(r2, None),
                    r3.name: Resource(r3, None),
                    r4.name: Resource(r4, Content(None, Blob("[mains]\n" + config)))}

        self.block_holder = BlockHolder(BlockName('user/block'), self.res)
        self.processor = MainConfigProcessor()
Example #21
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)
    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)
Example #23
0
    def test_add(self):
        mName = BlockName("user2/module2")
        m = mName + "path/to/file2.h"
        self.assertEqual('user2/module2/path/to/file2.h', m)
        self.assertEqual('user2/module2', m.block_name)
        self.assertEqual('user2', m.block_name.user)
        self.assertEqual('path/to/file2.h', m.cell_name)
        self.assertEqual('.h', m.extension)

        m = mName + CellName("path/to/file2.h")
        self.assertEqual('user2/module2/path/to/file2.h', m)
        self.assertEqual('user2/module2', m.block_name)
        self.assertEqual('user2', m.block_name.user)
        self.assertEqual('path/to/file2.h', m.cell_name)
        self.assertEqual('.h', m.extension)
Example #24
0
    def block(self):
        """Return block name as string.

        There are three kinds of NodeDeclaration:
        1. abspath fran/noderedis/client.js
        2. relpath with block fran/noderedis
        3. relpath without block ./

        """
        try:
            return BlockCellName(self.name).block_name
        except (InvalidNameException):
            try:
                return BlockName(self.name)
            except (InvalidNameException):
                return None
Example #25
0
 def __new__(cls, value, validate=True):
     if not validate:
         obj = str.__new__(cls, value)
     else:
         try:
             value = value.strip().replace('\\', '/')
             tokens = value.split('/', 2)
             cell = CellName(tokens[2])
             block = BlockName('/'.join(tokens[:2]))
             obj = str.__new__(cls, '%s/%s' % (block, cell))
             obj._block = block
             obj._cell = cell
         except IndexError:
             error_message = 'Invalid BlockCellName %s. '\
                             'It should be in the form usr/block/cellname' % value
             raise InvalidNameException(error_message)
     return obj
Example #26
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)
Example #27
0
def checkin_block_files(hive_holder, block_name, files, processor_changes, biiout):
    '''
    Params:
        hive_holder: HiveHolder
        block_name: BlockName
        files: {cell_name: content}
        processor_changes: ProcessorChanges
        biiout: biiout
    '''
    block_name = BlockName(block_name)
    types_blobs = obtain_types_blobs(files)  # {cell_name: (TYPE, Content/CellType/None)}
    # FIXME: What happens if merge result is larger than individual files, reject???
    changevalidator.remove_large_cells(types_blobs, biiout)
    try:
        block_holder = hive_holder[block_name]
    except KeyError:
        block_holder = BlockHolder(block_name, [])
        hive_holder.add_holder(block_holder)

    for cell_name, (biitype, blob) in types_blobs.iteritems():
        block_cell_name = block_name + cell_name
        cell = SimpleCell(block_cell_name, biitype)
        try:
            resource = block_holder[cell_name]
        except KeyError:
            content = Content(block_cell_name, load=blob)
            processor_changes.upsert(block_cell_name, content)
        else:
            content = resource.content
            if content is None or blob != content.load:
                content = Content(block_cell_name, load=blob)
                processor_changes.upsert(block_cell_name, content)

        resource = Resource(cell, content)
        block_holder.add_resource(resource)

    for cell_name, resource in block_holder.resources.items():
        if cell_name not in types_blobs:
            if resource.content is not None:
                processor_changes.delete(resource.name)
            block_holder.delete_resource(cell_name)
    hive_holder.hive.update(processor_changes)
Example #28
0
 def __new__(cls, name, validate=True):
     '''user/modname/branch
        ie: owner/[originalowner/name]/branch
     '''
     assert isinstance(name, basestring), '%s is not a string' % str(name)
     if not validate:
         obj = str.__new__(cls, name)
     else:
         name = name.strip().replace('\\', '/')
         tokens = name.split('/')
         if len(tokens) != 4:
             raise InvalidNameException(
                 "Invalid block name: %s, it should be in the form "
                 "owner/originalowner/name/branch" % name)
         user = tokens[0]
         block_name = '/'.join(tokens[1:3])
         obj = str.__new__(cls, '%s/%s/%s' % (user, block_name, tokens[3]))
         obj._user = BRLUser(user)
         obj._block_name = BlockName(block_name)
         obj._branch = ComplexName(tokens[3].lower())
     return obj
Example #29
0
def parse_block_version_expression(text):
    '''Parse text and returns the components of a BlockVersion

    Valid text input examples:
        lasote/myblock
        lasote/myblock(master)
        lasote/myblock(master):1
        lasote/myblock(pepe/branch):33 @My cool version # Comment at the end
    '''

    text = text.strip().replace('\\', '/')
    group_values = [m.groupdict() for m in block_version_re.finditer(text)]
    if len(group_values) == 0:  # Not Match
        raise ValueError()

    group_values = group_values[0]

    # Get block_name
    block_name = BlockName(group_values["block_name"])

    # Get complete branch_name
    if group_values.get("branch", None) is None:  # If none => owner/master
        branch_user = block_name.user
        branch_name = "master"
    elif "/" in group_values["branch"]:
        branch_user, branch_name = group_values["branch"].split("/")
    else:  # Only branch_name, so owner/branch_name
        branch_user = block_name.user
        branch_name = group_values["branch"]
    branch = BranchName('%s/%s' % (branch_user, branch_name))
    brl_block = BRLBlock(
        '%s/%s/%s/%s' %
        (branch.user, block_name.user, block_name.name, branch.name))
    # Get time
    version = group_values.get("time", None)
    time = int(version) if version else None
    version_tag = group_values.get("tag", None)

    return brl_block, time, version_tag
Example #30
0
 def disk_blocks(self):
     """Get the blocks based on disk, not in processed hive"""
     result = {}
     root_block = self._bii_paths.root_block
     if os.path.exists(self._bii_paths.blocks):
         for username in os.listdir(self._bii_paths.blocks):
             for name in os.listdir(
                     os.path.join(self._bii_paths.blocks, username)):
                 tmp_path = os.path.join(self._bii_paths.blocks, username,
                                         name)
                 if (os.path.isdir(tmp_path)):
                     block_name = BlockName("%s/%s" % (username, name))
                     if root_block == block_name:
                         self._biiout.warn(
                             "Skipping %s, it exists as root block" %
                             root_block)
                     elif (os.listdir(tmp_path)
                           ):  # If there is any file inside
                         result[block_name] = os.path.join(
                             self._bii_paths.blocks, block_name)
     if root_block:
         result[root_block] = self._bii_paths.project_root
     return result
Example #31
0
    def testComputeLevels(self):
        g = DirectedGraph()
        for i in range(13):
            g.add_node(BlockName("user/mod%d" % i))

        g.add_edge(BlockName("user/mod0"), BlockName("user/mod2"))
        g.add_edge(BlockName("user/mod0"), BlockName("user/mod3"))
        g.add_edge(BlockName("user/mod0"), BlockName("user/mod4"))
        g.add_edge(BlockName("user/mod3"), BlockName("user/mod6"))
        g.add_edge(BlockName("user/mod4"), BlockName("user/mod7"))
        g.add_edge(BlockName("user/mod6"), BlockName("user/mod9"))
        g.add_edge(BlockName("user/mod7"), BlockName("user/mod9"))
        g.add_edge(BlockName("user/mod9"), BlockName("user/mod12"))

        g.add_edge(BlockName("user/mod1"), BlockName("user/mod5"))
        g.add_edge(BlockName("user/mod5"), BlockName("user/mod8"))
        g.add_edge(BlockName("user/mod8"), BlockName("user/mod10"))
        g.add_edge(BlockName("user/mod8"), BlockName("user/mod11"))

        g.add_edge(BlockName("user/mod10"), BlockName("user/mod12"))
        g.add_edge(BlockName("user/mod7"), BlockName("user/mod10"))

        result = g.get_levels()

        self.assertEquals(5, len(result))
        self.assertEquals(
            result[0],
            set([
                BlockName("user/mod12"),
                BlockName("user/mod11"),
                BlockName("user/mod2")
            ]))

        self.assertEquals(
            result[1], set([BlockName("user/mod9"),
                            BlockName("user/mod10")]))

        self.assertEquals(
            result[2],
            set([
                BlockName("user/mod6"),
                BlockName("user/mod7"),
                BlockName("user/mod8")
            ]))

        self.assertEquals(
            result[3],
            set([
                BlockName("user/mod3"),
                BlockName("user/mod4"),
                BlockName("user/mod5")
            ]))

        self.assertEquals(
            result[4], set([BlockName("user/mod0"),
                            BlockName("user/mod1")]))
Example #32
0
 def blockname_underscore_test(self):
     bn = BlockName("user_1/block_1")
Example #33
0
 def long_blockname_test(self):
     wrong_bn = "dummy/dummy/block/master"
     with self.assertRaisesRegexp(InvalidNameException,
                                  '%s is not a valid BlockName.' % wrong_bn):
         BlockName(wrong_bn)
 def block_test(self):
     self.assertEquals(self.sut.block(), BlockName("user/wizard"))