summaryrefslogtreecommitdiffstats
path: root/tests/unit/test_strutils.py
Commit message (Collapse)AuthorAgeFilesLines
* Add slugify to strutilsAlessio Ababilov2013-06-111-0/+15
| | | | | | This function will be used in apiclient library. Change-Id: I19f976eda896e7bede07510aafebe4931e512351
* Added common code into fileutils and strutils.Ghe Rivero2013-06-061-0/+32
| | | | | | | | | | | | | This methods are present in nova, cinder and also needed by ironic package. openstack.common.strutils => nova.utils <=> cinder.utils to_bytes(text, default=0) openstack.common.fileutils => nova.utils <=> cinder.utils <=> nova/virt/libvirt/utils.py file_open(*args, **kwargs) Change-Id: Ia65499b77eb551c0ffb6d48767b899435469bfb6 Implements: blueprint image-tools
* Add 't', 'y', and `strict` to `bool_from_string`Rick Harris2013-05-141-0/+61
| | | | | | | | | | | 't' and 'y' are commonly used for booleans as well, and since it's used in Nova already, probably makes sense to add common support for it. `strict` allows callers to detect anonmolous values so they can be handled separately. This is particularly useful when parsing input from API calls where bad values might result in 4XX errors instead of being treated as False. Change-Id: I6218a1895f72cfbfd81776602e63ca3d093475e0
* Handle ints passed to `boolean_from_string`Rick Harris2013-05-101-0/+12
| | | | | | | | | | | | | | | | | | | | The existing code would return True for '1' but False for int(1), unlike Nova's version which would return True for both inputs. Nova's version feels safer (i.e. it will do the most-likely-correct thing if an int is passed in), so this patch changes Openstack-Common's version to match. Note that this patch does not make Openstack-Common's `boolean_from_string` match Nova's `bool_from_string` exactly though. Nova's version would return True for both '42' and 42, while Openstack-Common's returns False. Though Nova's version, again, seems safer, the presence of unit-tests in Openstack-Common asserting the defined-correctness of this behavior makes me reluctant to change it. Fixes bug 1178760 Change-Id: I8b2a31c4852884187bcbda3a4e78c8513b1bb8c8
* Convert unicode strings for python3 portabilityChuck Short2013-05-071-47/+35
| | | | | | | | | | | From http://docs.python.org/3.1/whatsnew/3.0.html You can no longer use u"..." literals for Unicode text. However, you must use b"..." literals for binary data. Use python-six to make this migration easier. Change-Id: I95166a07f4edf33be55a4bdf2674c2f238a06f19 Signed-off-by: Chuck Short <chuck.short@canonical.com>
* Fix Copyright Headers - Rename LLC to FoundationDavanum Srinivas2013-03-111-1/+1
| | | | | | One code change, rest are in headers Change-Id: I73f59681358629e1ad74e49d3d3ca13fcb5c2eb1
* Decode / Encode string utils for openstackFlaper Fesp2013-02-251-1/+33
| | | | | | | | | | | | | | | | | | | | | | | | | Currently some clients lack of non-ASCII characters support. This patch introduces 2 functions (strutils.py) that will help clients and servers to "safely" encode and decode strings. About the ensure_(str|unicode) functions: They both try to use first the encoding used in stdin (or python's default encoding if that's None) and fallback to utf-8 if those encodings fail to decode a given text. Neither of them will try to encode / decode non-basestring objects and will raise a TypeError if one is passed. Use case: This is currently being used in glanceclient. I5c3ea93a716edfe284d19f6291d4e36028f91eb2 Needed For: * Bug 1061156 * Bug 1130572 Change-Id: I78960dfdb6159fd600a6f5e5551ab5d5a3366ab5
* Replace direct use of testtools BaseTestCase.Monty Taylor2013-01-241-3/+2
| | | | | | | | | Using the BaseTestCase across the tests in the tree lets us put in log fixtures and consistently handle mox and stubout. Part of blueprint grizzly-testtools. Change-Id: Iba7eb2c63b0c514009b2c28e5930b27726a147b0
* Use testtools as test base class.Monty Taylor2013-01-241-2/+2
| | | | | | | | | | | | | On the path to testr migration, we need to replace the unittest base classes with testtools. Replace tearDown with addCleanup, addCleanup is more resilient than tearDown. The fixtures library has excellent support for managing and cleaning tempfiles. Use it. Replace skip_ with testtools.skipTest Part of blueprint grizzly-testtools. Change-Id: I45e11bbb1ff9b31f3278d3b016737dcb7850cd98
* Rename utils.py to strutils.pyZhongyue Luo2012-11-301-0/+76
Fixes bug #1083956 Change-Id: I681227e9428778adb7824a1930a33cfa5ffa13a1