6eaa5a4ed5f1598d78b7c6e24cd2c3c3a5cb8ee9
[integration/test.git] / tools / Robot_Tool / libraries / Common.py
1 """
2 Library for the robot based system test tool of the OpenDaylight project.
3 Authors: Baohua Yang@IBM, Denghui Huang@IBM
4 Updated: 2013-11-14
5 """
6 import collections
7
8 '''
9 Common constants and functions for the robot framework.
10 '''
11
12
13 def collection_should_contain(collection, *members):
14     """
15     Fail if not every members is in the collection.
16     """
17     if not isinstance(collection, collections.Iterable):
18         return False
19     for m in members:
20         if m not in collection:
21             return False
22     else:
23         return True
24
25
26 def combine_strings(*strings):
27     """
28     Combines the given `strings` together and returns the result.
29     The given strings are not altered by this keyword.
30     """
31     result = ''
32     for s in strings:
33         if isinstance(s, str) or isinstance(s, unicode):
34             result += s
35     if result == '':
36         return None
37     else:
38         return result
39
40 if __name__ == '__main__':
41     pass