Commit Graph

30 Commits

Author SHA1 Message Date
Erik Johnson
d729656703
Add unit tests for table outputter 2018-05-16 00:02:14 -05:00
Erik Johnson
7b13a7df8b
Replace json module usage with a helper to ensure unicode content is handled properly
This adds wrappers for json.dump{,s} which disable `ensure_ascii` by
default.
2017-12-27 09:30:58 -06:00
Mircea Ulinic
f6112fa89e
Add testcases for the nested outputter 2017-12-08 11:11:05 +00:00
Erik Johnson
877abb89d0
Complete the salt.utils refactor
This moves the remaining 30 functions from salt.utils to new locations.
2017-10-15 09:43:31 -05:00
Erik Johnson
3184168365 Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.

A summary of the changes in this PR is as follows:

* Moves the following functions from `salt.utils` to new locations
  (including a deprecation warning if invoked from `salt.utils`):
  `to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
  `dequote`, `is_hex`, `is_bin_str`, `rand_string`,
  `contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
  `which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
  `is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
  `is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
  `is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
  `salt/utils/__init__.py` for better organization, so we can keep the
  deprecated ones separate from the ones yet to be deprecated as we
  continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
  unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
  import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
  accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
  such that it returns a string matching the passed size. Previously
  this function would get `size` bytes from `os.urandom()`,
  base64-encode it, and return the result, which would in most cases not
  be equal to the passed size.
2017-08-08 13:33:43 -05:00
Pedro Algarvio
9a3f6d1350
Properly handle non native strings under py2 and py3 2017-04-28 13:33:36 +01:00
Pedro Algarvio
a15aa32404
Proper mocking. 2017-04-01 14:22:59 +01:00
Pedro Algarvio
d397763553
Adjust to the new LoaderModuleMockMixin usage 2017-03-28 19:03:59 +01:00
Pedro Algarvio
9b1e55aa85
Import the full module namespace to avoid import shadowing.
https://github.com/saltstack/salt/pull/39996#issuecomment-287857698
2017-03-28 19:02:47 +01:00
Pedro Algarvio
1f7a0aa65b
Proper mocking 2017-03-28 19:00:51 +01:00
Pedro Algarvio
40a64191a1
Absolute imports and A LOT of code cleanup. 2017-03-01 01:33:07 +00:00
Pedro Algarvio
3beb3fb801
Move whatever we need from salttesting to salt.
Let's drop the salttesting dependency cycle.
2017-02-28 22:52:49 +00:00
Pedro Algarvio
15af4c9728
Test filenames conformity. Adjust for pytest. 2017-02-23 23:19:42 +00:00
Pedro Algarvio
33d8832e40
Assert different outcome under Py3 2017-02-17 20:48:56 +00:00
Mike Place
43a209bd12 Remove unused imports for lint 2017-01-06 11:32:45 -07:00
msiebeneicher
c787285955 fixed failing import 2016-11-09 13:39:24 +01:00
msiebeneicher
1169cc3a11 reverted json log changes part2 2016-11-04 11:16:08 +01:00
msiebeneicher
9a1a23fca5 reverted json log changes 2016-11-04 11:09:45 +01:00
msiebeneicher
a1949dac9e fixed json_out unit tests after latest change 2016-11-03 17:20:47 +01:00
msiebeneicher
bac1d0fc28 unify json output tests for different plattform / lib versions 2016-10-12 12:15:08 +02:00
msiebeneicher
07f103954b fixed pylint issues 2016-10-12 10:14:45 +02:00
msiebeneicher
6bde592070 providing yaml output unit tests 2016-10-07 16:52:53 +02:00
msiebeneicher
63adf6c7e7 updated json output unit tests and added method exist check 2016-10-07 16:39:11 +02:00
Daniel Wallace
65b6734c04 catch unicode encoding errors in json outputter (#36033)
Add testing too
2016-09-02 14:56:09 -06:00
Thomas Jackson
686ec05b84 Remove test as well
Conflicts:

	tests/unit/output/grains.py
2015-02-05 09:20:29 -08:00
Pedro Algarvio
60f215f191 Add from __future__ import absolute_import 2015-01-30 22:25:04 +00:00
Thomas Jackson
975dee5bdd Remove test as well 2015-01-28 17:25:35 -08:00
rallytime
b4f98fc505 fix email address 2014-07-07 15:44:36 -06:00
rallytime
e1b6a2a9f1 Remove unnecessary line 2014-07-07 15:37:07 -06:00
rallytime
9aceee587c Test for unicode characters in grains outputter 2014-07-07 15:35:10 -06:00