def test_push_dir_non_absolute_path(): """ Test if push_dir fails on a non absolute path. """ path = "../saltines" ret = False assert cp.push_dir(path) == ret
def test_push_dir_non_absolute_path(self): ''' Test if push_dir fails on a non absolute path. ''' path = '../saltines' ret = False self.assertEqual(cp.push_dir(path), ret)
def test_push_dir_non_absolute_path(self): """ Test if push_dir fails on a non absolute path. """ path = "../saltines" ret = False self.assertEqual(cp.push_dir(path), ret)
def test_push_dir_file_success(self): ''' Test if push_dir succeeds on a file. ''' path = '/srv/salt/saltines' ret = True with patch('salt.modules.cp.push', MagicMock(return_value=True)): self.assertEqual(cp.push_dir(path), ret)
def test_push_dir_success(self): ''' Test if push_dir succeeds on a file. ''' path = '/srv/salt/cheese' # The tuple must be enclosed within another tuple since Mock/MagicMock # will unpack its return_value if return_value is set to an iterable. # This at least happens when Mock is mocking a function that is being # returned into a generator context. mock_walk_ret = (('/srv/salt/cheese', [], ['saltines.sls', 'biscuits.sls']), ) ret = True with patch('salt.modules.cp.push', MagicMock(return_value=True)): with patch('os.walk', MagicMock(return_value=mock_walk_ret)): self.assertEqual(cp.push_dir(path), ret)
def test_push_dir_success(self): ''' Test if push_dir succeeds on a file. ''' path = '/srv/salt/cheese' # The tuple must be enclosed within another tuple since Mock/MagicMock # will unpack its return_value if return_value is set to an iterable. # This at least happens when Mock is mocking a function that is being # returned into a generator context. mock_walk_ret = (('/srv/salt/cheese', [], ['saltines.sls', 'biscuits.sls']),) ret = True with patch('salt.modules.cp.push', MagicMock(return_value=True)): with patch('os.walk', MagicMock(return_value=mock_walk_ret)): self.assertEqual(cp.push_dir(path), ret)