This repository has been archived by the owner on Jan 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix concurrent access to self.cache in nosqldict (#121)
* fix concurrent access to self.cache in nosqldict * bump version to 0.4.2 * add -d to docker run in CI
- Loading branch information
Showing
8 changed files
with
182 additions
and
49 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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--with_nosqldict", action="store_true", help="Run the tests with the nosqldict" | ||
) | ||
|
||
|
||
def pytest_configure(config): | ||
config.addinivalue_line("markers", "nosqldict: mark test as requiring MongoDB") | ||
|
||
|
||
def pytest_collection_modifyitems(config, items): | ||
if config.getoption("--with_nosqldict"): | ||
return | ||
skip_nosqldict = pytest.mark.skip(reason="need --with_nosqldict option to run") | ||
for item in items: | ||
if "nosqldict" in item.keywords: | ||
item.add_marker(skip_nosqldict) |
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,55 @@ | ||
import secrets | ||
|
||
import pytest | ||
|
||
from enochecker.nosqldict import NoSqlDict | ||
|
||
|
||
@pytest.fixture | ||
def nosqldict(): | ||
dict_name = secrets.token_hex(8) | ||
checker_name = secrets.token_hex(8) | ||
return NoSqlDict(dict_name, checker_name) | ||
|
||
|
||
@pytest.mark.nosqldict | ||
def test_basic(nosqldict): | ||
nosqldict["abc"] = "xyz" | ||
assert nosqldict["abc"] == "xyz" | ||
|
||
with pytest.raises(KeyError): | ||
_ = nosqldict["xyz"] | ||
|
||
nosqldict["abc"] = {"stuff": b"asd"} | ||
assert nosqldict["abc"] == {"stuff": b"asd"} | ||
|
||
del nosqldict["abc"] | ||
with pytest.raises(KeyError): | ||
_ = nosqldict["abc"] | ||
|
||
|
||
@pytest.mark.nosqldict | ||
def test_nested_change(): | ||
dict_name = secrets.token_hex(8) | ||
checker_name = secrets.token_hex(8) | ||
|
||
def scoped_access(dict_name, checker_name): | ||
nosqldict = NoSqlDict(dict_name, checker_name) | ||
|
||
x = { | ||
"asd": 123, | ||
} | ||
nosqldict["test"] = x | ||
x["asd"] = 456 | ||
|
||
assert nosqldict["test"] == { | ||
"asd": 456, | ||
} | ||
|
||
scoped_access(dict_name, checker_name) | ||
|
||
nosqldict_new = NoSqlDict(dict_name, checker_name) | ||
|
||
assert nosqldict_new["test"] == { | ||
"asd": 456, | ||
} |