Improve importer, add channels and import both drop_campaigns and drop_campaign
This commit is contained in:
parent
7edf857127
commit
adc6deb314
8 changed files with 401 additions and 78 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from django.test import TestCase
|
||||
|
|
@ -30,7 +31,64 @@ class GetOrUpdateBenefitTests(TestCase):
|
|||
},
|
||||
)
|
||||
|
||||
benefit: DropBenefit = command._get_or_update_benefit(benefit_schema) # noqa: SLF001
|
||||
benefit: DropBenefit = command._get_or_update_benefit(benefit_schema)
|
||||
|
||||
benefit.refresh_from_db()
|
||||
assert not benefit.distribution_type
|
||||
|
||||
|
||||
class ExtractCampaignsTests(TestCase):
|
||||
"""Tests for response validation and campaign extraction."""
|
||||
|
||||
def test_validates_top_level_response_with_nested_campaign(self) -> None:
|
||||
"""Ensure validation handles full responses correctly."""
|
||||
command = Command()
|
||||
command.pre_fill_cache()
|
||||
|
||||
payload = {
|
||||
"data": {
|
||||
"user": {
|
||||
"id": "123",
|
||||
"dropCampaign": {
|
||||
"id": "c1",
|
||||
"name": "Test Campaign",
|
||||
"description": "",
|
||||
"startAt": "2025-01-01T00:00:00Z",
|
||||
"endAt": "2025-01-02T00:00:00Z",
|
||||
"accountLinkURL": "http://example.com",
|
||||
"detailsURL": "http://example.com",
|
||||
"imageURL": "",
|
||||
"status": "ACTIVE",
|
||||
"self": {"isAccountConnected": False, "__typename": "DropCampaignSelfEdge"},
|
||||
"game": {
|
||||
"id": "g1",
|
||||
"displayName": "Test Game",
|
||||
"boxArtURL": "http://example.com/art.png",
|
||||
"__typename": "Game",
|
||||
},
|
||||
"owner": {
|
||||
"id": "o1",
|
||||
"name": "Test Org",
|
||||
"__typename": "Organization",
|
||||
},
|
||||
"timeBasedDrops": [],
|
||||
"__typename": "DropCampaign",
|
||||
},
|
||||
"__typename": "User",
|
||||
},
|
||||
},
|
||||
"extensions": {
|
||||
"operationName": "TestOp",
|
||||
},
|
||||
}
|
||||
|
||||
# Validate response
|
||||
valid_responses, broken_dir = command._validate_responses(
|
||||
responses=[payload],
|
||||
file_path=Path("test.json"),
|
||||
options={},
|
||||
)
|
||||
|
||||
assert len(valid_responses) == 1
|
||||
assert broken_dir is None
|
||||
assert valid_responses[0].data.user is not None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue