mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #35000 from rallytime/bp-33875
Back-port #33875 and #34999 to 2015.8
This commit is contained in:
commit
2b511f3013
@ -198,11 +198,15 @@ def diff_mtime_map(map1, map2):
|
|||||||
'''
|
'''
|
||||||
# check if the mtimes are the same
|
# check if the mtimes are the same
|
||||||
if sorted(map1) != sorted(map2):
|
if sorted(map1) != sorted(map2):
|
||||||
#log.debug('diff_mtime_map: the maps are different')
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# map1 and map2 are guaranteed to have same keys,
|
||||||
|
# so compare mtimes
|
||||||
|
for filename, mtime in six.iteritems(map1):
|
||||||
|
if map2[filename] != mtime:
|
||||||
|
return True
|
||||||
|
|
||||||
# we made it, that means we have no changes
|
# we made it, that means we have no changes
|
||||||
#log.debug('diff_mtime_map: the maps are the same')
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
1
tests/unit/fileserver/__init__.py
Normal file
1
tests/unit/fileserver/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
30
tests/unit/fileserver/map.py
Normal file
30
tests/unit/fileserver/map.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
'''
|
||||||
|
:codeauthor: :email:`Joao Mesquita <jmesquita@sangoma.com>`
|
||||||
|
'''
|
||||||
|
|
||||||
|
# Import Python libs
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
# Import Salt Testing libs
|
||||||
|
from salttesting import TestCase
|
||||||
|
|
||||||
|
from salt import fileserver
|
||||||
|
|
||||||
|
|
||||||
|
class MapDiffTestCase(TestCase):
|
||||||
|
def test_diff_with_diffent_keys(self):
|
||||||
|
'''
|
||||||
|
Test that different maps are indeed reported different
|
||||||
|
'''
|
||||||
|
map1 = {'file1': 1234}
|
||||||
|
map2 = {'file2': 1234}
|
||||||
|
assert fileserver.diff_mtime_map(map1, map2) is True
|
||||||
|
|
||||||
|
def test_diff_with_diffent_values(self):
|
||||||
|
'''
|
||||||
|
Test that different maps are indeed reported different
|
||||||
|
'''
|
||||||
|
map1 = {'file1': 12345}
|
||||||
|
map2 = {'file1': 1234}
|
||||||
|
assert fileserver.diff_mtime_map(map1, map2) is True
|
Loading…
Reference in New Issue
Block a user