Skip to content

Commit

Permalink
Removing all references to raw data (Netflix#3075) (#55)
Browse files Browse the repository at this point in the history
Co-authored-by: kevgliss <[email protected]>
  • Loading branch information
rutvijmehta-harness and kevgliss authored Mar 17, 2023
1 parent 73a76d8 commit 0eb6b1e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
6 changes: 2 additions & 4 deletions src/dispatch/signal/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 0 additions & 11 deletions src/dispatch/signal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
18 changes: 9 additions & 9 deletions tests/signal/test_signal_service.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import json


def test_get(session, signal):
from dispatch.signal.service import get

Expand Down Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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()
Expand All @@ -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,
Expand All @@ -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)

Expand Down

0 comments on commit 0eb6b1e

Please sign in to comment.