Skip to content

Commit

Permalink
test(coverage): Add test coverage github action.
Browse files Browse the repository at this point in the history
Exclude `@abstractmethod`s from code coverage.
  • Loading branch information
caarmen committed Jul 20, 2024
1 parent b9ab81e commit 5b0bee7
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[run]
concurrency = thread,gevent

[report]
exclude_lines =
@abstractmethod
6 changes: 6 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
Check:
runs-on: ubuntu-latest
permissions:
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v4
Expand All @@ -29,6 +30,11 @@ jobs:
if: always() # always run even if the previous step fails
with:
report_paths: 'reports/junit.xml'
- name: Post coverage report
uses: 5monkeys/cobertura-action@v14
with:
path: reports/coverage.xml
minimum_coverage: 80
- name: Archive reports
if: always()
uses: actions/upload-artifact@v4
Expand Down
14 changes: 13 additions & 1 deletion slackhealthbot/domain/localrepository/localfitbitrepository.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dataclasses
import datetime
from abc import ABC
from abc import ABC, abstractmethod

from slackhealthbot.core.models import OAuthFields
from slackhealthbot.domain.models.activity import ActivityData, TopActivityStats
Expand All @@ -20,6 +20,7 @@ class User:


class LocalFitbitRepository(ABC):
@abstractmethod
async def create_user(
self,
slack_alias: str,
Expand All @@ -28,68 +29,79 @@ async def create_user(
) -> User:
pass

@abstractmethod
async def get_user_identity_by_fitbit_userid(
self,
fitbit_userid: str,
) -> UserIdentity | None:
pass

@abstractmethod
async def get_all_user_identities(self) -> list[UserIdentity]:
pass

@abstractmethod
async def get_oauth_data_by_fitbit_userid(
self,
fitbit_userid: str,
) -> OAuthFields:
pass

@abstractmethod
async def get_user_by_fitbit_userid(
self,
fitbit_userid: str,
) -> User:
pass

@abstractmethod
async def get_latest_activity_by_user_and_type(
self,
fitbit_userid: str,
type_id: int,
) -> ActivityData | None:
pass

@abstractmethod
async def get_activity_by_user_and_log_id(
self,
fitbit_userid: str,
log_id: int,
) -> ActivityData | None:
pass

@abstractmethod
async def create_activity_for_user(
self,
fitbit_userid: str,
activity: ActivityData,
):
pass

@abstractmethod
async def update_sleep_for_user(
self,
fitbit_userid: str,
sleep: SleepData,
):
pass

@abstractmethod
async def get_sleep_by_fitbit_userid(
self,
fitbit_userid: str,
) -> SleepData | None:
pass

@abstractmethod
async def update_oauth_data(
self,
fitbit_userid: str,
oauth_data: OAuthFields,
):
pass

@abstractmethod
async def get_top_activity_stats_by_user_and_activity_type(
self,
fitbit_userid: str,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
import datetime
from abc import ABC
from abc import ABC, abstractmethod

from slackhealthbot.core.models import OAuthFields
from slackhealthbot.domain.models.activity import ActivityData
from slackhealthbot.domain.models.sleep import SleepData


class RemoteFitbitRepository(ABC):
@abstractmethod
async def subscribe(
self,
oauth_fields: OAuthFields,
):
pass

@abstractmethod
async def get_activity(
self, oauth_fields: OAuthFields, when: datetime.datetime
) -> tuple[str, ActivityData] | None:
pass

@abstractmethod
async def get_sleep(
self,
oauth_fields: OAuthFields,
when: datetime.date,
) -> SleepData | None:
pass

@abstractmethod
def parse_oauth_fields(
self,
response_data: dict[str, str],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from abc import ABC
from abc import ABC, abstractmethod


class RemoteSlackRepository(ABC):
@abstractmethod
async def post_message(self, message: str):
pass
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from abc import ABC
from abc import ABC, abstractmethod

from slackhealthbot.core.models import OAuthFields


class RemoteWithingsRepository(ABC):

@abstractmethod
async def subscribe(
self,
oauth_fields: OAuthFields,
):
pass

@abstractmethod
async def get_last_weight_kg(
self,
oauth_fields: OAuthFields,
Expand All @@ -19,6 +21,7 @@ async def get_last_weight_kg(
) -> float | None:
pass

@abstractmethod
def parse_oauth_fields(
self,
response_data: dict[str, str],
Expand Down

0 comments on commit 5b0bee7

Please sign in to comment.