Exemplo n.º 1
0
    def test__variable__variable_does_not_exist__fail(self):
        self.suite.keywords.append(Keyword(name='Set service context to node_1', type='setup'))

        tests = [
            Keyword(name=u'Variable PTH: contains /usr/bin'),
        ]
        with patch('VnfValidator.orchestrator.DockerController.get_env', return_value=["PATH=/usr/bin"]):
            run_keyword_tests(test_instance=self, tests=tests, expected_result=Result.FAIL)
Exemplo n.º 2
0
    def test__port__invalid_value__fail(self):
        self.suite.keywords.append(Keyword(name='Set network context to node_1', type='setup'))

        tests = [
            Keyword(name=u'Port 80: state is openedd'),
        ]
        with patch('ValidationTargets.port.exc.SetupError.ROBOT_EXIT_ON_FAILURE', False):
            run_keyword_tests(test_instance=self, setup=None, tests=tests, expected_result=Result.FAIL,
                              expected_message=u'ValidationError: Value')
Exemplo n.º 3
0
    def test__variable__invalid_value__fail(self):
        self.suite.keywords.append(Keyword(name='Set service context to node_1', type='setup'))

        tests = [
            Keyword(name=u'Variable ABC: is ""'),
        ]
        with patch('ValidationTargets.variable.exc.SetupError.ROBOT_EXIT_ON_FAILURE', False):
            run_keyword_tests(test_instance=self, setup=None, tests=tests, expected_result=Result.FAIL,
                              expected_message=u'ValidationError: Value')
Exemplo n.º 4
0
    def test__port__pass(self):
        self.suite.keywords.append(Keyword(name='Set network context to node_1', type='setup'))

        tests = [
            Keyword(name=u'Port 80: state is open'),
            Keyword(name=u'Port 80/TCP: state is open'),
            Keyword(name=u'Port 80/UDP: state is open'),
            Keyword(name=u'Port 80/UDP: state is closed'),
        ]
        run_keyword_tests(test_instance=self, tests=tests, expected_result=Result.PASS)
Exemplo n.º 5
0
 def run_keyword(self,name,*args):
     """
     because the name of the keyword to execute is given as an argument
     is can be a vairbale and thus set dynamically,e.g.form a return value
     of another keyword or the command line
     """
     if not isinstance(name,basestring):
         raise RuntimeError('Keyword name must be a string')
     kw = Keyword(name,list(args))
     return kw.run(self._context)
Exemplo n.º 6
0
    def test__set_context__pass(self):
        tests = [
            Keyword(name=u'Set application context to node_1'),
            Keyword(name=u'Set network context to node_1'),
            Keyword(name=u'Set node context to node_1'),
            Keyword(name=u'Set service context to node_1'),
        ]

        with patch('DockerController.DockerController') as mock_controller:
            mock_controller = MagicMock(DockerController)
            run_keyword_tests(test_instance=self, tests=tests, expected_result=Result.PASS)
Exemplo n.º 7
0
 def call_p4p(self, p1, p2):
     kw = Keyword(p1, args=[])
     words = kw.run(EXECUTION_CONTEXTS.current)
     pw = "%s check" % p2
     kw = Keyword(pw, args=[words])
     result = kw.run(EXECUTION_CONTEXTS.current)
     kw = Keyword("Should be equal", args=["OK", result])
     return kw.run(EXECUTION_CONTEXTS.current)
Exemplo n.º 8
0
 def run_keyword(self, name, *args):
     """, """
     import robot.output as output
     from robot.running import Keyword, NAMESPACES
     kw = Keyword(name, args)
     def get_name(handler_name, variables):
         return "RDB.%s" % handler_name
     kw._get_name = get_name
     
     if self._exit_code > 0:
         sys.exit(self._exit_code)
     
     return kw.run(output.OUTPUT, NAMESPACES.current)
Exemplo n.º 9
0
    def test__set_context__wrong_context_type__fail(self):
        test = self.suite.tests.create(name=u'Test context')

        test.keywords.append(Keyword(name=u'Set app context to bla'))
        result = self.suite.run()

        self.assertIn("Invalid context given", result.suite.tests[0].message)
Exemplo n.º 10
0
 def wrapped_f(q, *args, **kwargs):
     ''' Calls the decorated function and puts the result in a queue '''
     try:
         context = EXECUTION_CONTEXTS.current
         runner = context.get_runner(keyword)
         ret = runner.run(Keyword(name=keyword, args=args), context)
         q.put(ret)
     except Exception as ex:
         print(ex)
Exemplo n.º 11
0
    def test__variable__pass(self):
        self.suite.keywords.append(Keyword(name='Set service context to node_1', type='setup'))

        tests = [
            Keyword(name=u'Variable PATH: contains /usr/bin'),
            Keyword(name=u'Variable PATH: is /usr/bin'),
            Keyword(name=u'Variable PATH: is "/usr/bin"'),
            Keyword(name=u'Variable PATH: is \'/usr/bin\''),
            Keyword(name=u'Variable NGINX_VERSION: contains 2.0.0beta1'),
            Keyword(name=u'Variable NGINX_VERSION: is 2.0.0beta1'),
        ]

        with patch('VnfValidator.orchestrator._get_controller') as mock:
            mock.return_value = MagicMock(DockerController)
            mock.return_value.get_env.return_value = ["PATH=/usr/bin", "NGINX_VERSION=2.0.0beta1"]
            run_keyword_tests(test_instance=self, tests=tests, expected_result=Result.PASS)
Exemplo n.º 12
0
 def call_p3p(self, p1, p2):
     kw = Keyword(p1, args=[])
     user, passwd = kw.run(EXECUTION_CONTEXTS.current)
     pw = "Enter Credentials"
     kw = Keyword(pw, args=[user, passwd])
     return kw.run(EXECUTION_CONTEXTS.current)
Exemplo n.º 13
0
 def call_p6(self, p1):
     pw = "%s teardown" % p1
     kw = Keyword(pw, args=[])
     return kw.run(EXECUTION_CONTEXTS.current)
Exemplo n.º 14
0
 def call_p2(self, p1):
     pw = "%s setup" % p1
     kw = Keyword(pw, args=[])
     return kw.run(EXECUTION_CONTEXTS.current)
Exemplo n.º 15
0
 def call_p1(self, p1):
     kw = Keyword(p1, args=[])
     return kw.run(EXECUTION_CONTEXTS.current)