-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
191 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Publish Pypi | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
build-and-publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install --upgrade setuptools | ||
python -m pip install poetry | ||
python -m pip install twine | ||
python -m poetry install | ||
- name: Build and publish to Test PyPI | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.TEST_PYPI }} | ||
run: | | ||
python -m poetry build | ||
twine upload --skip-existing --repository-url https://test.pypi.org/legacy/ dist/* | ||
- name: Publish to PyPI (if it's a new tag) | ||
if: github.ref == 'refs/heads/master' | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | ||
run: | | ||
python -m poetry build | ||
twine upload dist/* |
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,40 @@ | ||
import pytest | ||
from secured.attribute import AttrDict | ||
from secured.secure import Secure | ||
|
||
def test_attribute_access(): | ||
"""Test attribute-style access to dictionary keys.""" | ||
ad = AttrDict({'key1': 'value1', 'key2': 'value2'}) | ||
assert ad.key1 == 'value1' | ||
assert ad.key2 == 'value2' | ||
|
||
def test_secure_value_access(): | ||
"""Test that values are secured correctly when the secure flag is True.""" | ||
ad = AttrDict({'password': 'my_secret'}, secure=True, message="<Custom Secured>") | ||
assert isinstance(ad.password, Secure) | ||
assert str(ad.password) == "<Custom Secured>" | ||
|
||
def test_nested_dict_conversion(): | ||
"""Test that nested dictionaries are converted into AttrDict instances.""" | ||
ad = AttrDict({'nested': {'key': 'value'}}, secure=False) | ||
assert isinstance(ad.nested, AttrDict) | ||
assert ad.nested.key == 'value' | ||
|
||
def test_setattr_behavior(): | ||
"""Test setting attributes using dot notation.""" | ||
ad = AttrDict(secure=False) | ||
ad.new_key = 'new_value' | ||
assert 'new_key' in ad | ||
assert ad['new_key'] == 'new_value' | ||
|
||
def test_secure_flag_inheritance(): | ||
"""Test that the secure flag is inherited by nested AttrDict instances.""" | ||
ad = AttrDict({'nested': {'key': 'value'}}, secure=True, message="<Custom Secured>") | ||
assert isinstance(ad.nested.key, Secure) | ||
assert str(ad.nested.key) == "<Custom Secured>" | ||
|
||
def test_exception_for_nonexistent_attribute(): | ||
"""Test that accessing a nonexistent attribute raises an AttributeError.""" | ||
ad = AttrDict(secure=False) | ||
with pytest.raises(AttributeError): | ||
_ = ad.nonexistent |
Empty file.
Empty file.