Skip to content

Commit

Permalink
ci: add dead code detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas1312 committed Oct 10, 2023
1 parent dd02275 commit b72b25f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
15 changes: 1 addition & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,7 @@ jobs:

- name: Filter dead code
run: |
cat dead_code.log | \
grep -e "src/kili" | \
grep -v \
-e "is only referenced in tests" \
-e "_ is never read" \
-e "internal.py" \
-e "unused attribute 'internal'" \
-e "affected_rows" \
-e "src/kili/orm" \
-e "src/kili/types.py" \
-e "src/kili/services" \
-e "src/kili/entrypoints" \
-e "src/kili/core/graphql/ws_graphql_client" \
> dead_code_filtered.log
cat dead_code.log | grep -e "src/kili" | grep -v -e "src/kili/types.py" -e "is only referenced in tests" -e "_ is never read" -e "src/kili/orm" -e "src/kili/entrypoints" -e "internal.py" -e "src/kili/services" -e "affected_rows" -e "unused attribute 'internal'" -e "src/kili/core/graphql/ws_graphql_client" > dead_code_filtered.log
- name: Crash if dead code found
run: |
Expand Down
39 changes: 39 additions & 0 deletions tests/integration/presentation/test_cloud_storage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import pytest_mock

from kili.adapters.kili_api_gateway import KiliAPIGateway
from kili.presentation.client.cloud_storage import CloudStorageClientMethods
from kili.use_cases.cloud_storage import CloudStorageUseCases


def test_given_kili_client_when_calling_cloud_storage_connections_then_it_works(
kili_api_gateway: KiliAPIGateway, mocker: pytest_mock.MockerFixture
):
# Given
kili = CloudStorageClientMethods()
kili.kili_api_gateway = kili_api_gateway
data_connections = [{"id": "fake_data_connection_id"}]
mocker.patch.object(
CloudStorageUseCases, "list_data_connections", return_value=data_connections
)

# When
ret = kili.cloud_storage_connections(project_id="fake_proj_id")

# Then
assert ret == data_connections


def test_given_kili_client_when_calling_cloud_storage_connection_then_it_works(
kili_api_gateway: KiliAPIGateway, mocker: pytest_mock.MockerFixture
):
# Given
kili = CloudStorageClientMethods()
kili.kili_api_gateway = kili_api_gateway
data_connection = {"id": "fake_data_connection_id"}
mocker.patch.object(CloudStorageUseCases, "get_data_connection", return_value=data_connection)

# When
ret = kili.cloud_storage_connections(cloud_storage_connection_id="fake_data_connection_id")

# Then
assert ret == [data_connection]

0 comments on commit b72b25f

Please sign in to comment.