Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing all references to raw data #3075

Merged
merged 1 commit into from
Mar 7, 2023
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
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