-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Speedwagon-497 Save System information to File exits with an unhandle…
…d exception
- Loading branch information
1 parent
6c9a846
commit 3757256
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from speedwagon import utils | ||
import pathlib | ||
|
||
|
||
def test_get_desktop_path_finds_valid(monkeypatch): | ||
fake_home = os.path.join("usr", "home") | ||
monkeypatch.setattr( | ||
pathlib.Path, "home", lambda: pathlib.Path(fake_home) | ||
) | ||
|
||
def exists(path): | ||
return str(path) == os.path.join(fake_home, "Desktop") | ||
|
||
monkeypatch.setattr(os.path, "exists", exists) | ||
assert utils.get_desktop_path() | ||
|
||
|
||
def test_get_desktop_path_not_found_throws(monkeypatch): | ||
fake_home = os.path.join("usr", "home") | ||
|
||
monkeypatch.setattr( | ||
pathlib.Path, "home", lambda: pathlib.Path(fake_home) | ||
) | ||
|
||
monkeypatch.setattr(os.path, "exists", lambda _: False) | ||
with pytest.raises(FileNotFoundError): | ||
utils.get_desktop_path() |