Commit Graph

69 Commits

Author SHA1 Message Date
Erik Johnson
b89efc16eb
Remove more unnecessary explicit unicode literals 2018-01-13 21:10:04 -06:00
Erik Johnson
6d52aeb739
Replace os.walk with a helper function
On PY2, when os.walk is invoked with a str as input, the paths in the
return data are all str types as well. This leaves undecoded unicode
data in those strings when files/dirs under the top dir that was passed
contain unicode characters in the filename.

>>> import os
>>> list(os.walk('temp'))
[('temp', [], ['\xd0\x94.txt', 'foo.txt'])]
>>> list(os.walk(u'temp'))
[(u'temp', [], [u'\u0414.txt', u'foo.txt'])]

The helper introduced here ensures that we always invoke os.walk with a
unicode top-level dir, so that we get unicode types in the return data.
2017-12-13 16:38:12 -06:00
Michael Calmer
b6365aee3c fix order of parameters in unit tests 2017-12-04 15:38:22 +01:00
rallytime
a38ceab7cf
Merge branch '2017.7' into 'develop'
Conflicts:
  - salt/cli/batch.py
  - salt/master.py
  - salt/utils/path.py
  - tests/unit/modules/test_state.py
2017-09-29 11:48:33 -04:00
twangboy
aafec7ab0e
Fix unit.modules.test_zypper for Windows
Use `os.linesep` for newline in expected return
2017-09-27 16:59:36 -06:00
Silvio Moioli
7b0a7432f4 test_zypper: adapt to new supported attrs 2017-08-31 16:21:26 +02:00
Nicole Thomas
e6357abdda Merge pull request #42718 from moio/yumpkg-list_pkg-attr-parameter
yumpkg.list_pkgs: add parameter for returned attribute selection
2017-08-09 16:58:02 -04:00
Silvio Moioli
5a15e53886 yumpkg.list_pkg: add/adapt tests
This includes changes to the zypper tests because of the refactoring that
affected both modules.
2017-08-09 11:43:56 +02: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
Silvio Moioli
5e23f5d678 zypper.list_pkgs: add install_time_date_t as a supported attribute 2017-07-21 08:15:50 +02:00
Silvio Moioli
db22777a09 zypper_test: add test for list_pkgs and attr 2017-07-21 08:14:37 +02:00
Silvio Moioli
bb049cb70f zypper_test: adapt existing unit tests to new code 2017-07-21 08:14:37 +02:00
Silvio Moioli
a32ee4af05 zypper_test: correct mock behavior
Previously incorrect, although the test passed
2017-07-21 08:14:37 +02:00
rallytime
ccf790a83f Update all references for moved functions to use "files" util
- fopen
- flopen
- fpopen
- safe_rm
- is_empty
- is_fcntl_available
2017-07-18 10:31:01 -06:00
rallytime
3c823109a1 Lint: Remove extra blank line 2017-06-28 13:29:31 -06:00
rallytime
e512a29f08 Merge branch '2017.7' into 'develop'
Conflicts:
  - salt/modules/state.py
  - salt/modules/yumpkg.py
  - salt/modules/zypper.py
  - salt/states/pkg.py
  - salt/version.py
  - tests/unit/config/test_config.py
  - tests/unit/modules/test_zypper.py
2017-06-28 11:31:53 -06:00
Bo Maryniuk
b08d790ede Lintfix: wrap lines over 120 chars 2017-06-19 14:54:22 +02:00
Pablo Suárez Hernández
fb444db0f2 Search the entire CACHE_DIR because storage paths change across versions
Prevents zero length error on Python 2.6

Fixes Zypper unit test

Enhances pkg.list_downloaded information of a package

Listing all patches instead of security ones only

Adapting Zypper test to new list_downloaded output

Fixes zypper test error after backporting

Pylint fixes
2017-06-16 15:28:42 +02:00
Pablo Suárez Hernández
27ef83fd62 Adding support for installing patches in yum/dnf execution module
Adding support for installing patches in Zypper module

Adding list_downloaded function to Zypper module

Adding list_downloaded function to Yum module

Adding new pkg.downloaded state

Adding documentation for pkg.downloaded state

Adding pkg.patched and pkg.patch_downloaded states

Check targets for advisory patches installation

Adds support for listing advisory patches with Zypper

Adds support for listing advisory patches with Yum

Improving function naming

Moving advisory ids checks into pkg_resource.parse_targets

Fixes _find_download_targets to call _preflight_check

Fixes parse_targets when advisory id is passed as name

Pylint fixes

Enables pkg.downloaded to verify packages after package manager call.

Adding missing kwargs parameters to pkg.install call

Adding versionadded flags

Some refactoring and minor fixes

Adding unit tests for Zypper execution module

Adding more unit tests for Zypper module

Pylint fix
2017-06-16 15:28:10 +02:00
Bo Maryniuk
fa5c2c1672 Add UT for unsupported operators 2017-05-25 12:55:46 -06:00
Bo Maryniuk
157b83c05a Lintfixes 2017-05-25 12:55:46 -06:00
Bo Maryniuk
43abd345b2 Add UT for operator conditions 2017-05-25 12:55:46 -06:00
Bo Maryniuk
1053daf2d0 Add UT for typecheck on the output data 2017-05-25 12:55:46 -06:00
Bo Maryniuk
5c1259834f Add UT for None type verification if version has been not passed 2017-05-25 12:55:46 -06:00
Bo Maryniuk
0dd27380b1 Add UT for wildcard finder usage 2017-05-25 12:55:46 -06:00
Bo Maryniuk
5e836a2543 Test the exact methods for matcher 2017-05-25 12:55:46 -06:00
Bo Maryniuk
2af4160a1a Add UT for exact match of the pattern at the beginning 2017-05-25 12:55:46 -06:00
Bo Maryniuk
5a2248d254 Add UT for exact match of the pattern at the end 2017-05-25 12:55:46 -06:00
Bo Maryniuk
334c634826 Add UT to match multiple asterisks 2017-05-25 12:55:46 -06:00
Bo Maryniuk
f73b39fd3c Add UT for matching all versions 2017-05-25 12:55:46 -06:00
Bo Maryniuk
a9c3c8bf03 Fix a docstring 2017-05-25 12:55:46 -06:00
Bo Maryniuk
344295666b Rename UT to a proper name 2017-05-25 12:55:46 -06:00
Bo Maryniuk
369b4bf127 Add unit test scaffold for wildcard support 2017-05-25 12:55:46 -06:00
Mike Place
49f93cb091 Merge pull request #41405 from isbm/isbm-zypper-wildcards-dev
Wildcards for Zypper
2017-05-24 11:57:42 -05:00
Bo Maryniuk
22732504a3 Add UT for unsupported operators 2017-05-24 16:29:59 +02:00
Bo Maryniuk
a579ffc166 Lintfixes 2017-05-24 15:19:39 +02:00
Bo Maryniuk
3d40688cd9 Add UT for operator conditions 2017-05-24 13:55:49 +02:00
Bo Maryniuk
0bf0950158 Add UT for typecheck on the output data 2017-05-24 13:55:49 +02:00
Bo Maryniuk
20ff494b93 Add UT for None type verification if version has been not passed 2017-05-24 13:55:49 +02:00
Bo Maryniuk
c806128d51 Add UT for wildcard finder usage 2017-05-24 13:55:49 +02:00
Bo Maryniuk
552b3265d0 Test the exact methods for matcher 2017-05-24 13:55:49 +02:00
Bo Maryniuk
561ae0b8c8 Add UT for exact match of the pattern at the beginning 2017-05-24 13:55:49 +02:00
Bo Maryniuk
b1ddcccda0 Add UT for exact match of the pattern at the end 2017-05-24 13:55:49 +02:00
Bo Maryniuk
4c9dd39118 Add UT to match multiple asterisks 2017-05-24 13:55:49 +02:00
Bo Maryniuk
8839f7219b Add UT for matching all versions 2017-05-24 13:55:49 +02:00
Bo Maryniuk
5988e3b5d3 Fix a docstring 2017-05-24 13:55:49 +02:00
Bo Maryniuk
508c439b2b Rename UT to a proper name 2017-05-24 13:55:49 +02:00
Bo Maryniuk
3b44018f58 Add unit test scaffold for wildcard support 2017-05-24 13:55:49 +02:00
rallytime
718b0adc70 Merge branch 'nitrogen' into 'develop'
Conflicts:
  - salt/modules/zypper.py
  - tests/unit/utils/test_network.py
2017-05-23 09:05:13 -06:00
rallytime
c6c1d30c48 Merge branch '2016.11' into 'nitrogen'
Conflicts:
  - salt/modules/yumpkg.py
  - salt/spm/__init__.py
  - tests/unit/modules/test_zypper.py
  - tests/unit/utils/test_network.py
2017-05-20 17:07:34 -06:00