Skip to content

Commit

Permalink
fix all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jennmueng committed Sep 6, 2024
1 parent 9793943 commit 293c565
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
5 changes: 3 additions & 2 deletions tests/automation/autofix/test_autofix_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
StacktraceFrame,
ThreadDetails,
)
from seer.automation.state import LocalMemoryState
from seer.automation.state import DbStateRunTypes, LocalMemoryState
from seer.automation.summarize.issue import IssueSummary
from seer.db import DbIssueSummary, DbPrIdToAutofixRunIdMapping, Session

Expand Down Expand Up @@ -170,7 +170,8 @@ def setUp(self):
repos=[],
issue=IssueDetails(id=0, title="", events=[error_event], short_id="ISSUE_1"),
),
)
),
type=DbStateRunTypes.AUTOFIX,
)
self.autofix_context = AutofixContext(self.state, MagicMock(), MagicMock())
self.autofix_context.get_org_slug = MagicMock(return_value="slug")
Expand Down
15 changes: 4 additions & 11 deletions tests/automation/autofix/test_autofix_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from seer.automation.autofix.models import AutofixContinuation
from seer.automation.autofix.state import ContinuationState
from seer.automation.state import DbStateRunTypes
from seer.db import DbRunState


Expand All @@ -13,19 +14,11 @@ def mock_session(self):
with patch("seer.automation.autofix.state.Session") as mock:
yield mock

def test_from_id(self):
with patch("seer.automation.state.DbState.from_id") as mock_from_id:
mock_from_id.return_value = MagicMock(spec=ContinuationState)
result = ContinuationState.from_id(1, AutofixContinuation)

mock_from_id.assert_called_once_with(1, AutofixContinuation)
assert isinstance(result, ContinuationState)

def test_set(self, mock_session):
mock_session_instance = MagicMock()
mock_session.return_value.__enter__.return_value = mock_session_instance

state = ContinuationState(id=1, model=AutofixContinuation)
state = ContinuationState(id=1, model=AutofixContinuation, type=DbStateRunTypes.AUTOFIX)
mock_autofix_continuation = MagicMock(spec=AutofixContinuation)
mock_autofix_continuation.model_dump.return_value = {"key": "value"}
mock_autofix_continuation.updated_at = "2023-01-01"
Expand All @@ -48,7 +41,7 @@ def test_set(self, mock_session):
def test_get(self):
with patch("seer.automation.state.DbState.get") as mock_get:
mock_get.return_value = MagicMock(spec=AutofixContinuation)
state = ContinuationState(id=1, model=AutofixContinuation)
state = ContinuationState(id=1, model=AutofixContinuation, type=DbStateRunTypes.AUTOFIX)
result = state.get()

mock_get.assert_called_once()
Expand All @@ -59,7 +52,7 @@ def test_update(self):
mock_context = MagicMock()
mock_update.return_value.__enter__.return_value = mock_context

state = ContinuationState(id=1, model=AutofixContinuation)
state = ContinuationState(id=1, model=AutofixContinuation, type=DbStateRunTypes.AUTOFIX)
with state.update() as context:
assert context == mock_context

Expand Down
3 changes: 2 additions & 1 deletion tests/test_celery.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from celery import Celery

import celery_app.tasks
from celery_app.app import celery_app, setup_celery_entrypoint
from celery_app.config import CeleryConfig
from seer.dependency_injection import resolve
Expand All @@ -15,7 +16,7 @@ def test_detected_celery_jobs():
"seer.automation.autofix.steps.steps.autofix_parallelized_conditional_step_task",
"seer.automation.autofix.tasks.run_autofix_evaluation_on_item",
"seer.automation.autofix.tasks.check_and_mark_recent_autofix_runs",
"seer.automation.autofix.tasks.delete_data_for_ttl",
"seer.automation.tasks.delete_data_for_ttl",
"seer.smoke_test.smoke_test",
]
)
Expand Down

0 comments on commit 293c565

Please sign in to comment.