コード例 #1
0
 def testStringApplies(self):
     expected_value = 'Expected'
     value_field = String(name='comp_field', value='applies')
     condition = self.cls(field=value_field, comp_value='applies')
     c = Container(name='container',
                   fields=[
                       Meta(value_field),
                       If(condition=condition, fields=[Static('Expected')])
                   ])
     rendered = c.render().tobytes()
     self.assertEqual(rendered, expected_value)
コード例 #2
0
 def testNotApplies(self):
     expected_value = ''
     value_field = self._get_not_applies_field()
     condition = self._get_condition(value_field)
     c = Container(name='container',
                   fields=[
                       Meta(value_field),
                       If(condition=condition,
                          fields=[Static('Should not appear')])
                   ])
     rendered = c.render().tobytes()
     self.assertEqual(rendered, expected_value)
コード例 #3
0
 def testApplies(self):
     expected_value = 'Expected'
     value_field = self._get_applies_field()
     condition = self._get_condition(value_field)
     c = Container(name='container',
                   fields=[
                       Meta(value_field),
                       If(condition=condition,
                          fields=[Static(expected_value)])
                   ])
     rendered = c.render().tobytes()
     self.assertEqual(rendered, expected_value.encode())
コード例 #4
0
ファイル: fuzz_engine.py プロジェクト: webstorage119/umap2
def add_stage(g, stage, template, count):
    '''
    Add a stage to the session graph

    :param g: the GraphModel object
    :param stage: stage name
    :param template: the actual template
    :param count: the stage count

    :example:

        for the call add_stage(g, 'X', x, 4) we will create the following
        graph:

        ::

            x
            p1 -> x
            p1 -> p2 -> x
            p1 -> p2 -> p3 -> x
    '''
    g.connect(template)
    pseudos = [
        # workaround for a PseudoTemplate bug in kitty 0.6.9
        # TODO: move to PseudoTemplate in next kitty version
        Template(
            name=stage,
            fields=Meta(fields=[
                String(value=stage),
                UInt32(value=i)
            ]),
            fuzzable=False
        ) for i in range(count - 1)
    ]
    if pseudos:
        g.connect(pseudos[0])
        for i in range(len(pseudos) - 1):
            g.connect(pseudos[i], pseudos[i + 1])
            g.connect(pseudos[i], template)
        g.connect(pseudos[-1], template)