
    ?i                         d Z ddlmZ ddlmZmZmZmZ  G d de      Z G d de      Z	 G d d	e      Z
 G d
 de      Zy)z,
Tests for django_cronjob_utils exceptions.
    )TestCase)CronJobErrorTaskNotFoundErrorConcurrentExecutionErrorValidationErrorc                   "    e Zd ZdZd Zd Zd Zy)CronJobErrorTestsz&Tests for CronJobError base exception.c                     | j                  t              5 }t        d      # 1 sw Y   nxY w| j                  t        j                        d       y)z Test CronJobError can be raised.z
Test errorN)assertRaisesr   assertEqualstr	exceptionselfcms     E/home/cursorai/projects/django-cronjob-utils/tests/test_exceptions.pytest_cron_job_errorz%CronJobErrorTests.test_cron_job_error   sA    |,|,, -, 	R\\*L9   "+c                 J    | j                  t        t        t                     y)z"Test CronJobError is an Exception.N)
assertTrue
issubclassr   	Exceptionr   s    r   test_cron_job_error_inheritancez1CronJobErrorTests.test_cron_job_error_inheritance   s    
<;<    c                 Z    | j                  t              5  t               # 1 sw Y   yxY w)z"Test CronJobError without message.N)r   r   r   s    r   test_cron_job_error_no_messagez0CronJobErrorTests.test_cron_job_error_no_message   s!    |,.  -,s   !*N)__name__
__module____qualname____doc__r   r   r    r   r   r	   r	      s    0:=!r   r	   c                   "    e Zd ZdZd Zd Zd Zy)TaskNotFoundErrorTestszTests for TaskNotFoundError.c                     | j                  t              5 }t        d      # 1 sw Y   nxY w| j                  t        j                        d       y)z$Test TaskNotFoundError with message.zTask 'test-task' not foundNr   r   r   r   r   r   s     r   test_task_not_found_errorz0TaskNotFoundErrorTests.test_task_not_found_error$   sD    01R#$@AA 21 	R\\*,HIr   c                 J    | j                  t        t        t                     y)z2Test TaskNotFoundError inherits from CronJobError.N)r   r   r   r   r   s    r   %test_task_not_found_error_inheritancez<TaskNotFoundErrorTests.test_task_not_found_error_inheritance+   s    
#4lCDr   c                     | j                  t              5 }t        d      # 1 sw Y   nxY w| j                  t        j                        d       y)z*Test TaskNotFoundError with empty message. Nr&   r   s     r   'test_task_not_found_error_empty_messagez>TaskNotFoundErrorTests.test_task_not_found_error_empty_message/   sB    01R#B'' 21 	R\\*B/r   N)r   r   r    r!   r'   r)   r,   r"   r   r   r$   r$   !   s    &JE0r   r$   c                   "    e Zd ZdZd Zd Zd Zy)ConcurrentExecutionErrorTestsz#Tests for ConcurrentExecutionError.c                     | j                  t              5 }t        d      # 1 sw Y   nxY w| j                  t        j                        d       y)z+Test ConcurrentExecutionError with message.zTask already runningN)r   r   r   r   r   r   s     r   test_concurrent_execution_errorz=ConcurrentExecutionErrorTests.test_concurrent_execution_error:   sD    78B*+ABB 98 	R\\*,BCr   c                 J    | j                  t        t        t                     y)z9Test ConcurrentExecutionError inherits from CronJobError.N)r   r   r   r   r   s    r   +test_concurrent_execution_error_inheritancezIConcurrentExecutionErrorTests.test_concurrent_execution_error_inheritanceA   s    
#;\JKr   c                     d}| j                  t              5 }t        |      # 1 sw Y   nxY w| j                  dt        j                               | j                  dt        |j                               y)z4Test ConcurrentExecutionError with detailed message.zITask A001 already running for 2024-01-15 (started at 2024-01-15 10:00:00)NA001z
2024-01-15)r   r   assertInr   r   r   messager   s      r   0test_concurrent_execution_error_detailed_messagezNConcurrentExecutionErrorTests.test_concurrent_execution_error_detailed_messageE   s\    ]78B*733 98 	fc",,/0lC$56   $-N)r   r   r    r!   r0   r2   r8   r"   r   r   r.   r.   7   s    -DL7r   r.   c                   "    e Zd ZdZd Zd Zd Zy)ValidationErrorTestszTests for ValidationError.c                     | j                  t              5 }t        d      # 1 sw Y   nxY w| j                  t        j                        d       y)z"Test ValidationError with message.zInvalid execution_dateN)r   r   r   r   r   r   s     r   test_validation_errorz*ValidationErrorTests.test_validation_errorR   sC    /2!":;; 0/ 	R\\*,DEr   c                 J    | j                  t        t        t                     y)z0Test ValidationError inherits from CronJobError.N)r   r   r   r   r   s    r   !test_validation_error_inheritancez6ValidationErrorTests.test_validation_error_inheritanceY   s    
?LABr   c                     d}| j                  t              5 }t        |      # 1 sw Y   nxY w| j                  dt        j                               | j                  dt        |j                               y)z1Test ValidationError with field-specific message.z7execution_date must be a date object, got <class 'str'>Nexecution_datezdate object)r   r   r5   r   r   r6   s      r   $test_validation_error_field_specificz9ValidationErrorTests.test_validation_error_field_specific]   s\    K/2!'** 0/ 	&BLL(9:mS%67r9   N)r   r   r    r!   r=   r?   rB   r"   r   r   r;   r;   O   s    $FC8r   r;   N)r!   django.testr   django_cronjob_utils.exceptionsr   r   r   r   r	   r$   r.   r;   r"   r   r   <module>rE      sI    ! ! !(0X 0,7H 7088 8r   