Revision: a4dcd031a131
Branch: default
Author: Robot Framework Developers (robotframew...@gmail.com)
Date: Wed Dec 11 12:33:17 2013 UTC
Log: started moving Remote tests from remoteserver tests to normal
atests
http://code.google.com/p/robotframework/source/detail?r=a4dcd031a131
Added:
/atest/robot/standard_libraries/remote/argument_counts.txt
/atest/robot/standard_libraries/remote/simple_server.txt
/atest/testdata/standard_libraries/remote/argcounts.py
/atest/testdata/standard_libraries/remote/argument_counts.txt
/atest/testdata/standard_libraries/remote/resource.txt
/atest/testdata/standard_libraries/remote/simple_server.txt
/atest/testdata/standard_libraries/remote/simpleserver.py
=======================================
--- /dev/null
+++ /atest/robot/standard_libraries/remote/argument_counts.txt Wed Dec 11
12:33:17 2013 UTC
@@ -0,0 +1,38 @@
+*** Settings ***
+Suite Setup Run Tests ${EMPTY}
standard_libraries/remote/argument_counts.txt
+Force Tags regression pybot jybot
+Resource atest_resource.txt
+
+*** Test Cases ***
+No Arguments
+ Check Test Case ${TESTNAME}
+
+Required Arguments
+ Check Test Case ${TESTNAME}
+
+Arguments With Default Values
+ Check Test Case ${TESTNAME}
+
+Variable Number Of Arguments
+ Check Test Case ${TESTNAME}
+
+Required Arguments, Default Values and Varargs
+ Check Test Case ${TESTNAME}
+
+Using Arguments When No Accepted
+ Check Test Case ${TESTNAME}
+
+Too Few Arguments When Using Only Required Args
+ Check Test Case ${TESTNAME}
+
+Too Many Arguments When Using Only Required Args
+ Check Test Case ${TESTNAME}
+
+Too Few Arguments When Using Default Values
+ Check Test Case ${TESTNAME}
+
+Too Many Arguments When Using Default Values
+ Check Test Case ${TESTNAME}
+
+Too Few Arguments When Using Varargs
+ Check Test Case ${TESTNAME}
=======================================
--- /dev/null
+++ /atest/robot/standard_libraries/remote/simple_server.txt Wed Dec 11
12:33:17 2013 UTC
@@ -0,0 +1,20 @@
+*** Settings ***
+Suite Setup Run Tests ${EMPTY}
standard_libraries/remote/simple_server.txt
+Force Tags regression pybot jybot
+Resource atest_resource.txt
+
+*** Test Cases ***
+Passing
+ Check Test Case ${TESTNAME}
+
+Failing
+ Check Test Case ${TESTNAME}
+
+Failing with traceback
+ Check Test Case ${TESTNAME}
+
+Returning
+ Check Test Case ${TESTNAME}
+
+Logging
+ Check Test Case ${TESTNAME}
=======================================
--- /dev/null
+++ /atest/testdata/standard_libraries/remote/argcounts.py Wed Dec 11
12:33:17 2013 UTC
@@ -0,0 +1,85 @@
+import sys
+import inspect
+from SimpleXMLRPCServer import SimpleXMLRPCServer
+
+
+class RemoteServer(SimpleXMLRPCServer):
+
+ def __init__(self, library, port=8270):
+ SimpleXMLRPCServer.__init__(self, ('localhost', int(port)))
+ self.library = library
+ self.register_function(self.get_keyword_names)
+ self.register_function(self.get_keyword_arguments)
+ self.register_function(self.run_keyword)
+ self.serve_forever()
+
+ def get_keyword_names(self):
+ return [attr for attr in dir(self.library) if attr[0] != '_']
+
+ def get_keyword_arguments(self, name):
+ kw = getattr(self.library, name)
+ args, varargs, kwargs, defaults = inspect.getargspec(kw)
+ args = args[1:] # drop 'self'
+ if defaults:
+ args, names = args[:-len(defaults)], args[-len(defaults):]
+ args += ['%s=%s' % (n, d) for n, d in zip(names, defaults)]
+ if varargs:
+ args.append('*%s' % varargs)
+ if kwargs:
+ args.append('**%s' % kwargs)
+ return args
+
+ def run_keyword(self, name, args, kwargs=None):
+ result = getattr(self.library, name)(*args, **(kwargs or {}))
+ return {'status': 'PASS', 'return': result}
+
+
+class ArgumentCounts(object):
+
+ def no_arguments(self):
+ return self._format_args()
+
+ def one_argument(self, arg):
+ return self._format_args(arg)
+
+ def two_arguments(self, arg1, arg2):
+ return self._format_args(arg1, arg2)
+
+ def five_arguments(self, arg1, arg2, arg3, arg4, arg5):
+ return self._format_args(arg1, arg2, arg3, arg4, arg5)
+
+ def arguments_with_default_values(self, arg1, arg2=2, arg3='3'):
+ return self._format_args(arg1, arg2, arg3)
+
+ def varargs(self, *args):
+ return self._format_args(*args)
+
+ def required_defaults_and_varargs(self, req, default='world',
*varargs):
+ return self._format_args(req, default, *varargs)
+
+ def kwargs(self, **kwargs):
+ return self._format_args(**kwargs)
+
+ def args_and_kwargs(self, arg1='default1', arg2='default2', **kwargs):
+ return self._format_args(arg1, arg2, **kwargs)
+
+ def varargs_and_kwargs(self, *varargs, **kwargs):
+ return self._format_args(*varargs, **kwargs)
+
+ def args_varargs_and_kwargs(self, arg1='default1', arg2='default2',
+ *varargs, **kwargs):
+ return self._format_args(arg1, arg2, *varargs, **kwargs)
+
+ def _format_args(self, *args, **kwargs):
+ args += tuple('%s: %s' % (k, self._type(kwargs))
+ for k, v in sorted(kwargs.items()))
+ return ', '.join(self._type(a) for a in args)
+
+ def _type(self, arg):
+ if not isinstance(arg, basestring):
+ return '%s (%s)' % (arg, type(arg).__name__)
+ return arg
+
+
+if __name__ == '__main__':
+ RemoteServer(ArgumentCounts(), *sys.argv[1:])
=======================================
--- /dev/null
+++ /atest/testdata/standard_libraries/remote/argument_counts.txt Wed Dec
11 12:33:17 2013 UTC
@@ -0,0 +1,69 @@
+*** Settings ***
+Suite Setup Start And Import Remote argcounts
+Suite Teardown Stop Remote argcounts
+Resource resource.txt
+
+*** Test Cases ***
+No Arguments
+ [Template] Arguments Should Be Accepted
+ ${EMPTY} No Arguments
+
+Required Arguments
+ [Template] Arguments Should Be Accepted
+ some argument One Argument some argument
+ first argument, second argument Two Arguments first argument
second argument
+ 1, 2, 3 (int), 4, 5 Five Arguments 1 2 ${3} 4 5
+
+Arguments With Default Values
+ [Template] Arguments Should Be Accepted
+ one, two, three Arguments With Default Values one two three
+ one, two, 3 Arguments With Default Values one two
+ one, 2 (int), 3 Arguments With Default Values one
+
+Variable Number Of Arguments
+ [Template] Arguments Should Be Accepted
+ ${EMPTY} Varargs
+ One argument Varargs One argument
+ Three, arguments, now Varargs Three arguments now
+ 1, 2, 3, 4 (int), 5 Varargs 1 2 3 ${4} 5
+
+Required Arguments, Default Values and Varargs
+ [Template] Arguments Should Be Accepted
+ Hello, world Required Defaults And Varargs Hello
+ Hi, tellus Required Defaults And Varargs Hi tellus
+ Hello, again, world Required Defaults And Varargs Hello
again world
+ 1, 2, 3, 4, 5 (int) Required Defaults And Varargs 1 2 3
4 ${5}
+
+Using Arguments When No Accepted
+ [Documentation] FAIL Keyword 'Remote.No Arguments' expected 0
arguments, got 1.
+ No Arguments not allowed
+
+Too Few Arguments When Using Only Required Args
+ [Documentation] FAIL Keyword 'Remote.One Argument' expected 1
argument, got 0.
+ One Argument
+
+Too Many Arguments When Using Only Required Args
+ [Documentation] FAIL Keyword 'Remote.Two Arguments' expected 2
arguments, got 3.
+ Two Arguments too many arguments
+
+Too Few Arguments When Using Default Values
+ [Documentation] FAIL Keyword 'Remote.Arguments With Default Values'
expected 1 to 3 arguments, got 0.
+ Arguments With Default Values
+
+Too Many Arguments When Using Default Values
+ [Documentation] FAIL Keyword 'Remote.Arguments With Default Values'
expected 1 to 3 arguments, got 5.
+ Arguments With Default Values this is way too much
+
+Too Few Arguments When Using Varargs
+ [Documentation] FAIL Keyword 'Remote.Required Defaults And Varargs'
expected at least 1 argument, got 0.
+ Required Defaults And Varargs
+
+*** Keywords ***
+Arguments Should Be Accepted
+ [Arguments] ${expected} ${keyword} @{arguments}
+ ${actual} = Run Keyword ${keyword} @{arguments}
+ Should Be Equal ${actual} ${expected}
+
+Arguments Should Not Be Accepted
+ [Arguments] ${error} ${keyword} @{arguments}
+ Run Keyword And Expect Error ${error} ${keyword} @{arguments}
=======================================
--- /dev/null
+++ /atest/testdata/standard_libraries/remote/resource.txt Wed Dec 11
12:33:17 2013 UTC
@@ -0,0 +1,14 @@
+*** Settings ***
+Library Process
+
+*** Keywords ***
+Start And Import Remote
+ [Arguments] ${name}
+ Start Process python ${CURDIR}${/}${name}.py alias=${name}
stderr=STDOUT
+ Import Library Remote http://localhost:8270
+ Set Log Level DEBUG
+
+Stop Remote
+ [Arguments] ${name}
+ ${result} = Terminate Process handle=${name}
+ Log ${result.stdout}
=======================================
--- /dev/null
+++ /atest/testdata/standard_libraries/remote/simple_server.txt Wed Dec 11
12:33:17 2013 UTC
@@ -0,0 +1,29 @@
+*** Settings ***
+Documentation Server has only get_kw_names and run_kw methods and
returns minimal result dictionary.
+Suite Setup Start And Import Remote simpleserver
+Suite Teardown Stop Remote simpleserver
+Resource resource.txt
+
+*** Test Cases ***
+Passing
+ Passing
+ ${ret} = Passing I can has argz?
+ Should Be Equal ${ret} ${EMPTY}
+
+Failing
+ [Documentation] FAIL Teh error messaz
+ Failing Teh error messaz
+
+Failing with traceback
+ [Documentation] FAIL RemoteError
+ Traceback Teh trazeback
+
+Returning
+ ${ret} = Returning
+ Should Be Equal ${ret} ${EMPTY}
+ ${ret} = Returning I can has argz?
+ Should Be Equal ${ret} I can has argz?
+
+Logging
+ ${ret} = Logging I can has logz? *DEBUG* Yezz!!
+ Should Be Equal ${ret} ${EMPTY}
=======================================
--- /dev/null
+++ /atest/testdata/standard_libraries/remote/simpleserver.py Wed Dec 11
12:33:17 2013 UTC
@@ -0,0 +1,30 @@
+import sys
+from SimpleXMLRPCServer import SimpleXMLRPCServer
+
+
+class SimpleServer(SimpleXMLRPCServer):
+
+ def __init__(self, port=8270):
+ SimpleXMLRPCServer.__init__(self, ('localhost', int(port)))
+ self.register_function(self.get_keyword_names)
+ self.register_function(self.run_keyword)
+ self.serve_forever()
+
+ def get_keyword_names(self):
+ return ['Passing', 'Failing', 'Traceback', 'Returning', 'Logging']
+
+ def run_keyword(self, name, args):
+ if name == 'Passing':
+ return {'status': 'PASS'}
+ if name == 'Failing':
+ return {'status': 'FAIL', 'error': ' '.join(args)}
+ if name == 'Traceback':
+ return {'status': 'FAIL', 'traceback': ' '.join(args)}
+ if name == 'Returning':
+ return {'status': 'PASS', 'return': ' '.join(args)}
+ if name == 'Logging':
+ return {'status': 'PASS', 'output': '\n'.join(args)}
+
+
+if __name__ == '__main__':
+ SimpleServer(*sys.argv[1:])
--
---
You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.