-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
version dictionary is now case-insensitive.
- Loading branch information
1 parent
e1b322d
commit 8c09037
Showing
3 changed files
with
62 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pytest | ||
from uranium.packages.versions import Versions | ||
|
||
|
||
@pytest.fixture | ||
def versions(): | ||
return Versions() | ||
|
||
|
||
def test_versions_coerce_lowercase(versions): | ||
""" | ||
coerce package names to lowercase | ||
""" | ||
versions["SQLAlchemy"] = "==1.0.11" | ||
assert versions["sqlalchemy"] == "==1.0.11" | ||
|
||
|
||
def test_versions_coerce_lowercase_update(versions): | ||
""" | ||
coerce package names to lowercase for update. | ||
""" | ||
versions.update({ | ||
"SQLAlchemy": "==1.0.11" | ||
}) | ||
assert versions["sqlalchemy"] == "==1.0.11" | ||
|
||
|
||
def test_versions_coerce_lowercase_get(versions): | ||
""" | ||
getting a package name should also be lowercase. | ||
""" | ||
versions.update({ | ||
"SQLAlchemy": "==1.0.11" | ||
}) | ||
assert versions["SQLAlchemy"] == "==1.0.11" |
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,25 @@ | ||
from collections import MutableMapping | ||
|
||
|
||
class Versions(MutableMapping): | ||
""" a dictionary containing version specs. """ | ||
|
||
def __init__(self): | ||
self._values = {} | ||
|
||
def __setitem__(self, key, value): | ||
key = str(key).lower() | ||
self._values[key] = value | ||
|
||
def __getitem__(self, key): | ||
key = str(key).lower() | ||
return self._values[key] | ||
|
||
def __delitem__(self, key): | ||
del self._values[key] | ||
|
||
def __iter__(self): | ||
return iter(self._values) | ||
|
||
def __len__(self): | ||
return len(self._values) |