Пример #1
0
    def test_can_make_conditional_statement(self):
        g = Gremlin()
        c = Conditional()
        cond = '1 == 2'
        body = 'nope'
        else_c = 'one doesnt equal two'

        c.set_if(cond, body)
        c.set_else(else_c)
        g.apply_statement(c)

        string = str(g)
        params = g.bound_params
        expected = 'if(%s){%s}else{%s}' % (cond, body, else_c)

        self.assertTrue(string == expected)
        self.assertTrue(len(params) == 0)
Пример #2
0
 def test_can_make_conditional_statement(self):
     g      = Gremlin()
     c      = Conditional()
     cond   = '1 == 2'
     body   = 'nope'
     else_c = 'one doesnt equal two'
     
     c.set_if(cond, body)
     c.set_else(else_c)
     g.apply_statement(c)
     
     string   = str(g)
     params   = g.bound_params
     expected = 'if(%s){%s}else{%s}' % (cond, body, else_c)
     
     self.assertTrue(string == expected)
     self.assertTrue(len(params) == 0)
Пример #3
0
 def test_can_make_conditional_statement_with_two_elseif(self):
     g       = Gremlin()
     c       = Conditional()
     cond    = '1 == 2'
     body    = 'nope'
     else_i  = '2 == 2'
     else_b  = 'two does equal 2'
     else_i2 = '20 == 20'
     else_b2 = 'already caught above'
     else_c  = 'one doesnt equal two'
     
     c.set_if(cond, body)
     c.set_elif(else_i, else_b)
     c.set_elif(else_i2, else_b2)
     c.set_else(else_c)
     g.apply_statement(c)
     
     string   = str(g)
     params   = g.bound_params
     expected = 'if(%s){%s}elseif(%s){%s}elseif(%s){%s}else{%s}' % (cond, body, else_i, else_b, else_i2, else_b2, else_c)
     
     self.assertTrue(string == expected)
     self.assertTrue(len(params) == 0) 
Пример #4
0
    def test_can_make_conditional_statement_with_two_elseif(self):
        g = Gremlin()
        c = Conditional()
        cond = '1 == 2'
        body = 'nope'
        else_i = '2 == 2'
        else_b = 'two does equal 2'
        else_i2 = '20 == 20'
        else_b2 = 'already caught above'
        else_c = 'one doesnt equal two'

        c.set_if(cond, body)
        c.set_elif(else_i, else_b)
        c.set_elif(else_i2, else_b2)
        c.set_else(else_c)
        g.apply_statement(c)

        string = str(g)
        params = g.bound_params
        expected = 'if(%s){%s}elseif(%s){%s}elseif(%s){%s}else{%s}' % (
            cond, body, else_i, else_b, else_i2, else_b2, else_c)

        self.assertTrue(string == expected)
        self.assertTrue(len(params) == 0)