Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed metric/management/__init__.py
Empty file.
Empty file.
109 changes: 0 additions & 109 deletions metric/management/commands/poll_metrics.py

This file was deleted.

17 changes: 0 additions & 17 deletions metric/management/commands/poll_reviews.py

This file was deleted.

38 changes: 7 additions & 31 deletions tests/integration/test_end_to_end.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,21 @@
import pytest

from app.models import App
from metric.models import Metric
from metric.strategies.generic import GenericMetricStrategy
from source.constants.source_type import SourceType
from source.models import Source
from source.services import SourceService


@pytest.mark.django_db
def test_full_flow_with_real_adapter():
# Setup: crear App, Metric y Source reals
app = App.objects.create(
code="discord",
name="Discord",
description="App de comunicació global",
appstore_id="985746746",
)
metric = Metric.objects.create(code="average_rating", name="Average Rating", value_type="float")
source = Source.objects.create(
code="itunes",
name="iTunes Search API",
type=SourceType.API,
url="https://itunes.apple.com",
)

def test_full_flow_with_real_adapter(dummy_app):
# Adapter real (ja ha de formar part del projecte i registrar-se automàticament)
adapters = SourceService().load_sources()
itunes_adapter = next((a for a in adapters if a.code == "itunes"), None)

assert itunes_adapter is not None, "iTunes adapter not found in loaded sources"

strategy = GenericMetricStrategy("average_rating")
values = strategy.compute_all(app.id, [itunes_adapter])
values = itunes_adapter.fetch(dummy_app.id, ["average_rating"])

for v in values:
print(f"metric={v.metric.code}, app={v.app.code}, source={v.source.code}, value={v.value}")
# Comprovar que el valor retornat és un diccionari i conté la clau "average_rating"
assert isinstance(values, dict), "Expected values to be a dictionary"
assert "average_rating" in values, "'average_rating' key not found in values"

assert isinstance(values, list)
assert any(
v.metric == metric and v.app == app and v.source == source
for v in values
if v.value is not None
)
# Comprovar que el valor no és None
assert values["average_rating"] is not None, "'average_rating' value is None"
48 changes: 0 additions & 48 deletions tests/unit/test_generic_metric_strategy.py

This file was deleted.