Skip to content

Commit 948621a

Browse files
authored
Merge pull request eclecticiq#212 from eclecticiq/improve-docs-2021-12-09
Make doc coverage check automatically non-decreasing and improve docs
2 parents 7283b2a + 708448b commit 948621a

File tree

5 files changed

+49
-6
lines changed

5 files changed

+49
-6
lines changed

.github/workflows/interrogate.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
4+
5+
interrogate --fail-under=0 --config "$SCRIPT_DIR/../../pyproject.toml" $1 | grep -o "actual: [0-9]*\.[0-9]*%" | grep -o "[0-9]*\.[0-9]*"

.github/workflows/interrogate.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,22 @@ jobs:
66
check:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- name: Checkout head branch
10+
uses: actions/checkout@v2
11+
with:
12+
path: head
13+
- name: Checkout base branch
14+
uses: actions/checkout@v2
15+
with:
16+
ref: ${{ github.base_ref }}
17+
path: base
1018
- name: Set up Python 3.9
1119
uses: actions/setup-python@v2
1220
with:
1321
python-version: 3.9
1422
- name: Install interrogate
15-
run: pip install -r requirements-interrogate.txt
16-
- name: Run interrogate
17-
run: interrogate
23+
run: pip install -r head/requirements-interrogate.txt
24+
- name: Run interrogate on base branch for baseline
25+
run: echo "old_cov=$(head/.github/workflows/interrogate.sh base)" >> $GITHUB_ENV
26+
- name: Run interrogate on head branch to check coverage didn't drop
27+
run: interrogate --fail-under=${{ env.old_cov }} head

opentaxii/taxii/services/handlers/subscription_request_handlers.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424

2525

2626
def action_subscribe(request, service, collection, version, **kwargs):
27+
"""
28+
Handle SUBSCRIBE action.
2729
30+
taxii 1.0: create or update description
31+
taxii 1.1: first validate message, then create or update description
32+
"""
2833
if version == 11:
2934
params = request.subscription_parameters
3035
response_type = params.response_type
@@ -69,6 +74,11 @@ def action_subscribe(request, service, collection, version, **kwargs):
6974

7075

7176
def action_unsubscribe(request, service, subscription, **kwargs):
77+
"""
78+
Handle UNSUBSCRIBE action.
79+
80+
Update subscription to unsubscribed status, if it exists.
81+
"""
7282
if subscription:
7383
subscription.status = SubscriptionEntity.UNSUBSCRIBED
7484
return service.update_subscription(subscription)
@@ -82,19 +92,34 @@ def action_unsubscribe(request, service, subscription, **kwargs):
8292

8393

8494
def action_status(service, subscription, **kwargs):
95+
"""
96+
Handle STATUS action.
97+
98+
Return status of single subscription or all subscriptions for service.
99+
"""
85100
if subscription:
86101
return subscription
87102
return service.get_subscriptions()
88103

89104

90105
def action_pause(service, subscription, **kwargs):
106+
"""
107+
Handle PAUSE action.
108+
109+
Update subscription to paused status, if it exists.
110+
"""
91111
if subscription.status == SubscriptionEntity.PAUSED:
92112
return subscription
93113
subscription.status = SubscriptionEntity.PAUSED
94114
return service.update_subscription(subscription)
95115

96116

97117
def action_resume(service, subscription, **kwargs):
118+
"""
119+
Handle RESUME action.
120+
121+
Update subscriptoin to active status, if it exists.
122+
"""
98123
if subscription.status != SubscriptionEntity.PAUSED:
99124
return subscription
100125
subscription.status = SubscriptionEntity.ACTIVE

opentaxii/taxii2/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
class ValidationError(Exception):
2+
"""
3+
Exception used when taxii2 envelope doesn't pass validation.
4+
"""
5+
26
pass

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ ignore-nested-classes = true
88
ignore-private = true
99
ignore-semiprivate = true
1010
omit-covered-files = true
11-
verbose = 2
12-
fail-under = 32.7
11+
verbose = 0
1312
exclude = ["tests"]

0 commit comments

Comments
 (0)