From a6cdc731f5452d2ff426fb50ca15f411f9a80b0e Mon Sep 17 00:00:00 2001 From: Kevin Glisson Date: Tue, 7 Mar 2023 14:56:58 -0800 Subject: [PATCH] Removing all references to raw data --- src/dispatch/signal/flows.py | 6 ++---- src/dispatch/signal/models.py | 11 ----------- tests/signal/test_signal_service.py | 18 +++++++++--------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/dispatch/signal/flows.py b/src/dispatch/signal/flows.py index 1709f64c16ba..581d31d2eb2a 100644 --- a/src/dispatch/signal/flows.py +++ b/src/dispatch/signal/flows.py @@ -5,12 +5,10 @@ from dispatch.case import flows as case_flows from dispatch.entity import service as entity_service from dispatch.signal import service as signal_service -from dispatch.signal.models import SignalInstanceCreate, RawSignal +from dispatch.signal.models import SignalInstanceCreate -def create_signal_instance( - db_session: SessionLocal, project: Project, signal_instance_data: RawSignal -): +def create_signal_instance(db_session: SessionLocal, project: Project, signal_instance_data: dict): """Creates a signal and a case if necessary.""" signal = signal_service.get_by_variant_or_external_id( db_session=db_session, diff --git a/src/dispatch/signal/models.py b/src/dispatch/signal/models.py index f1ae0b411967..75be94dd1961 100644 --- a/src/dispatch/signal/models.py +++ b/src/dispatch/signal/models.py @@ -250,17 +250,6 @@ class AdditionalMetadata(DispatchBase): important: Optional[bool] -class RawSignal(DispatchBase): - action: Optional[List[Dict]] = [] - additional_metadata: Optional[List[AdditionalMetadata]] = Field([], alias="additionalMetadata") - asset: Optional[List[Dict]] = [] - identity: Optional[Dict] = {} - origin_location: Optional[List[Dict]] = Field([], alias="originLocation") - variant: Optional[str] = None - created_at: Optional[datetime] = Field(None, fields="createdAt") - id: Optional[str] - - class SignalInstanceBase(DispatchBase): project: ProjectRead case: Optional[CaseRead] diff --git a/tests/signal/test_signal_service.py b/tests/signal/test_signal_service.py index bbb4f9e0a319..07738a8da3b7 100644 --- a/tests/signal/test_signal_service.py +++ b/tests/signal/test_signal_service.py @@ -1,3 +1,6 @@ +import json + + def test_get(session, signal): from dispatch.signal.service import get @@ -49,11 +52,11 @@ def test_delete(session, signal): # instance tests def test_create_instance(session, case, signal, project): - from dispatch.signal.models import RawSignal, SignalInstanceCreate + from dispatch.signal.models import SignalInstanceCreate from dispatch.signal.service import create_instance signal_instance_in = SignalInstanceCreate( - raw=RawSignal(id="foo"), + raw={"id": "foo"}, project=project, ) signal_instance = create_instance(db_session=session, signal_instance_in=signal_instance_in) @@ -62,7 +65,6 @@ def test_create_instance(session, case, signal, project): def test_filter_actions_deduplicate(session, signal, project): from dispatch.signal.models import ( - RawSignal, SignalFilter, SignalInstance, SignalFilterAction, @@ -84,12 +86,12 @@ def test_filter_actions_deduplicate(session, signal, project): # create instance signal_instance_1 = SignalInstance( - raw=RawSignal(id="foo").json(), project=project, signal=signal, entities=[entity] + raw=json.dumps({"id": "foo"}), project=project, signal=signal, entities=[entity] ) session.add(signal_instance_1) signal_instance_2 = SignalInstance( - raw=RawSignal(id="foo").json(), project=project, signal=signal, entities=[entity] + raw=json.dumps({"id": "foo"}), project=project, signal=signal, entities=[entity] ) session.add(signal_instance_2) signal.entity_types.append(entity_type) @@ -117,7 +119,6 @@ def test_filter_actions_deduplicate(session, signal, project): def test_filter_actions_snooze(session, signal, project): from datetime import datetime, timedelta, timezone from dispatch.signal.models import ( - RawSignal, SignalFilter, SignalInstance, SignalFilterAction, @@ -140,7 +141,7 @@ def test_filter_actions_snooze(session, signal, project): # create instance signal_instance_1 = SignalInstance( - raw=RawSignal(id="foo").json(), project=project, signal=signal, entities=[entity] + raw=json.dumps({"id": "foo"}), project=project, signal=signal, entities=[entity] ) session.add(signal_instance_1) session.commit() @@ -164,7 +165,6 @@ def test_filter_actions_snooze(session, signal, project): def test_filter_actions_snooze_expired(session, signal, project): from datetime import datetime, timedelta, timezone from dispatch.signal.models import ( - RawSignal, SignalFilter, SignalInstance, SignalFilterAction, @@ -186,7 +186,7 @@ def test_filter_actions_snooze_expired(session, signal, project): # create instance signal_instance_1 = SignalInstance( - raw=RawSignal(id="foo").json(), project=project, signal=signal, entities=[entity] + raw=json.dumps({"id": "foo"}), project=project, signal=signal, entities=[entity] ) session.add(signal_instance_1)