Skip to content

Commit

Permalink
[FMWK-77] Check code coverage in Github actions workflow (#9)
Browse files Browse the repository at this point in the history
- Fix test case for invalid operate policy
- Fix converting any policy to an operate policy
  • Loading branch information
juliannguyen4 committed Oct 21, 2022
1 parent 0021762 commit 3dc4e77
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ jobs:
poetry run python3 cookbook-ex.py
- name: Run unit tests
run: |
cd tests/
poetry run python3 test.py
poetry run coverage run -m unittest tests/test.py
- name: Run coverage test
run: poetry run coverage report --fail-under=100 --include=documentapi/api.py
2 changes: 1 addition & 1 deletion documentapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def convertToOperatePolicy(policy: Policy) -> Union[Policy, None]:

# Filter out non-operate policies
operatePolicy = policy.copy()
for key in operatePolicy:
for key in policy:
if key not in OPERATE_CONFIG_KEYS:
operatePolicy.pop(key)

Expand Down
65 changes: 64 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ packages = [{include = "documentapi"}]
python = ">= 3.7, < 3.10"
jsonpath-ng-aerospike = "^1.5.3"
aerospike = ">= 6.0, < 8.0"
coverage = "^6.5.0"

[tool.poetry.group.dev.dependencies]
flake8 = "^5.0.4"
Expand Down
9 changes: 9 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ def testGetKeyWithBrackets(self):
results = documentClient.get(keyTuple, MAP_BIN_NAME, "$['key[with.brackets]']")
self.assertEqual(results, mapJsonObj["key[with.brackets]"])

def testGetWithInvalidOperatePolicy(self):
# This read policy should be filtered out
# Since it can't be used in an operate policy
readPolicy = {
"deserialize": False
}
results = documentClient.get(keyTuple, MAP_BIN_NAME, "$['key[with.brackets]']", readPolicy)
self.assertEqual(results, mapJsonObj["key[with.brackets]"])


class TestGetAdvancedOps(TestGets):

Expand Down

0 comments on commit 3dc4e77

Please sign in to comment.