-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a FileManager and use it to load files and yaml with minimal c…
…ache capabilities
- Loading branch information
1 parent
7ad9afd
commit 1445720
Showing
7 changed files
with
146 additions
and
22 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
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import builtins | ||
|
||
from locale import gettext | ||
|
||
builtins.__dict__["_"] = gettext |
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,39 @@ | ||
# -*- coding: utf-8 -*- | ||
# pylint: disable=redefined-outer-name | ||
|
||
from guake.utils import FileManager | ||
|
||
|
||
def test_file_manager(fs): | ||
fs.create_file("/foo/bar", contents="test") | ||
fm = FileManager() | ||
assert fm.read("/foo/bar") == "test" | ||
|
||
|
||
def test_file_manager_hit(fs): | ||
f = fs.create_file("/foo/bar", contents="test") | ||
|
||
fm = FileManager(delta=9999) | ||
assert fm.read("/foo/bar") == "test" | ||
f.set_contents("changed") | ||
assert fm.read("/foo/bar") == "test" | ||
|
||
|
||
def test_file_manager_miss(fs): | ||
f = fs.create_file("/foo/bar", contents="test") | ||
|
||
fm = FileManager(delta=0.0) | ||
assert fm.read("/foo/bar") == "test" | ||
f.set_contents("changed") | ||
assert fm.read("/foo/bar") == "changed" | ||
|
||
|
||
def test_file_manager_clear(fs): | ||
f = fs.create_file("/foo/bar", contents="test") | ||
|
||
fm = FileManager(delta=9999) | ||
assert fm.read("/foo/bar") == "test" | ||
f.set_contents("changed") | ||
assert fm.read("/foo/bar") == "test" | ||
fm.clear() | ||
assert fm.read("/foo/bar") == "changed" |
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