Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
gagantrivedi committed Dec 7, 2023
1 parent 6ac8156 commit 924bca5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions api/tests/unit/sse/test_tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
from datetime import datetime
from typing import Callable
from unittest import mock
from unittest.mock import call

import pytest
Expand All @@ -15,6 +17,10 @@
send_environment_update_message_for_project,
update_sse_usage,
)
from task_processor.management.commands.runprocessor import (
Command as RunProcessorCommand,
)
from task_processor.models import RecurringTask


def test_send_environment_update_message_for_project_make_correct_request(
Expand Down Expand Up @@ -138,3 +144,24 @@ def test_track_sse_usage(
bucket=influxdb_bucket,
record=mocked_influx_point().field().tag().tag().tag().time(),
)


@mock.patch.dict(os.environ, {})
@pytest.mark.django_db
def test_track_sse_usage_is_installed_correctly(
settings: SettingsWrapper,
):
# Given
settings.AWS_SSE_LOGS_BUCKET_NAME = "test_bucket"

# When
# Initialising the command should save the task to the database
RunProcessorCommand()

# Then
assert (
RecurringTask.objects.filter(
task_identifier=f"tasks.{update_sse_usage.__name__}"
).exists()
is True
)

0 comments on commit 924bca5

Please sign in to comment.