Ejemplo n.º 1
0
def test_stats_issue_43328(test_file):
    """
    Make sure that a CommandExecutionError is raised if the file does NOT
    exist
    """
    fake_file = test_file.parent / "fake.file"
    with pytest.raises(CommandExecutionError):
        win_file.stats(fake_file)
Ejemplo n.º 2
0
 def test_stat(self):
     with patch('os.path.exists', MagicMock(return_value=True)), \
             patch('salt.modules.win_file._resolve_symlink', MagicMock(side_effect=lambda path: path)), \
             patch('salt.modules.win_file.get_uid', MagicMock(return_value=1)), \
             patch('salt.modules.win_file.uid_to_user', MagicMock(return_value='dummy')), \
             patch('salt.modules.win_file.get_pgid', MagicMock(return_value=1)), \
             patch('salt.modules.win_file.gid_to_group', MagicMock(return_value='dummy')), \
             patch('os.stat', MagicMock(return_value=DummyStat())):
         ret = win_file.stats('dummy', None, True)
         self.assertEqual(ret['mode'], '0644')
         self.assertEqual(ret['type'], 'file')
Ejemplo n.º 3
0
 def test_stat(self):
     with patch("os.path.exists", MagicMock(return_value=True)), patch(
         "salt.modules.win_file._resolve_symlink",
         MagicMock(side_effect=lambda path: path),
     ), patch("salt.modules.win_file.get_uid", MagicMock(return_value=1)), patch(
         "salt.modules.win_file.uid_to_user", MagicMock(return_value="dummy")
     ), patch(
         "salt.modules.win_file.get_pgid", MagicMock(return_value=1)
     ), patch(
         "salt.modules.win_file.gid_to_group", MagicMock(return_value="dummy")
     ), patch(
         "os.stat", MagicMock(return_value=DummyStat())
     ):
         ret = win_file.stats("dummy", None, True)
         self.assertEqual(ret["mode"], "0644")
         self.assertEqual(ret["type"], "file")
Ejemplo n.º 4
0
def test_stat(test_file):
    ret = win_file.stats(str(test_file), None, True)
    assert ret["mode"] == "0666"
    assert ret["type"] == "file"