Skip to content

Commit

Permalink
additional unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
venkatajagannath committed Jun 12, 2024
1 parent 8c96b71 commit 3182afc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/triggers/test_anyscale_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@
from unittest.mock import patch, MagicMock
import asyncio
from datetime import datetime
import os
import pytest
from pathlib import Path
from airflow.models import DagBag, Connection
from airflow.utils.db import create_default_connections
from airflow.utils.session import provide_session, create_session

from anyscale.job.models import JobState
from anyscale.service.models import ServiceState

from anyscale_provider.triggers.anyscale import AnyscaleJobTrigger, AnyscaleServiceTrigger
from airflow.triggers.base import TriggerEvent
from airflow.models.connection import Connection

class TestAnyscaleJobTrigger(unittest.TestCase):
def setUp(self):
Expand Down Expand Up @@ -51,6 +59,17 @@ async def test_run_exception(self, mock_is_terminal_status):
self.assertEqual(events[0]['status'], JobState.FAILED)
self.assertIn('Error occurred', events[0]['message'])

async def test_run_no_job_id_provided(self):
trigger = AnyscaleJobTrigger(conn_id='default_conn',
job_id='',
job_start_time=datetime.now().timestamp())
events = []
async for event in trigger.run():
events.append(event)
self.assertEqual(len(events), 1)
self.assertEqual(events[0]['status'], 'error')
self.assertIn('No job_id provided', events[0]['message'])

class TestAnyscaleServiceTrigger(unittest.TestCase):
def setUp(self):
self.trigger = AnyscaleServiceTrigger(conn_id='default_conn',
Expand Down

0 comments on commit 3182afc

Please sign in to comment.