-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: reworked API * fix: failing test
- Loading branch information
Showing
3 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from account.models import Community | ||
from scorer_weighted.models import Scorer, BinaryWeightedScorer | ||
from django.test import Client | ||
from django.conf import settings | ||
import pytest | ||
|
||
pytestmark = pytest.mark.django_db # noqa: F821 | ||
|
||
client = Client() | ||
|
||
|
||
class TestGetWeights: | ||
base_url = "/ceramic-cache" | ||
|
||
def test_get_weights( | ||
self, | ||
scorer_account, | ||
): | ||
scorer_weights = {"provider-1": "0.5", "provider-2": "0.5"} | ||
scorer = BinaryWeightedScorer.objects.create( | ||
type=Scorer.Type.WEIGHTED_BINARY, weights=scorer_weights | ||
) | ||
|
||
community = Community.objects.create( | ||
name="Community 1", | ||
description="Community 1 - testing", | ||
account=scorer_account, | ||
scorer=scorer, | ||
) | ||
|
||
settings.CERAMIC_CACHE_SCORER_ID = community.pk | ||
response = client.get( | ||
f"{self.base_url}/weights", | ||
) | ||
|
||
returned_weights = response.json() | ||
assert response.status_code == 200 | ||
assert scorer_weights == returned_weights |