1nikitas

Untitled

May 26th, 2023
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.80 KB | None | 0 0
  1. C:\Users\nkiselev\PycharmProjects\etl-framework-dev\env\Scripts\python.exe "C:/Program Files/JetBrains/PyCharm Community Edition 2022.3.3/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py" --target test_monitoring.py::test_get_failed_tis_with_specific_tags
  2. Testing started at 13:10 ...
  3. Launching pytest with arguments test_monitoring.py::test_get_failed_tis_with_specific_tags --no-header --no-summary -q in C:\Users\nkiselev\PycharmProjects\etl-framework-dev\main\modules\airflow\dags\tests\unit_tests\services
  4.  
  5. ============================= test session starts =============================
  6. collecting ... collected 1 item
  7.  
  8. test_monitoring.py::test_get_failed_tis_with_specific_tags FAILED [100%]
  9. main\modules\airflow\dags\tests\unit_tests\services\test_monitoring.py:46 (test_get_failed_tis_with_specific_tags)
  10. mock_get_ti_log_lines = <MagicMock name='get_ti_log_lines_with_specific_log_levels' id='2553320663840'>
  11. mock_get_failed_tis = <MagicMock name='_get_failed_tis_by_period_with_specific_tags' id='2553316808496'>
  12. mock_get_data_interval = <MagicMock name='get_data_interval' id='2553320707552'>
  13. mock_get_context = <MagicMock name='get_current_context' id='2553320719600'>
  14.  
  15. @patch('airflow.operators.python.get_current_context')
  16. @patch('dependencies.services.utils.get_data_interval')
  17. @patch('dependencies.services.monitoring.monitoring._get_failed_tis_by_period_with_specific_tags')
  18. @patch('dependencies.services.monitoring.monitoring.get_ti_log_lines_with_specific_log_levels')
  19. def test_get_failed_tis_with_specific_tags(mock_get_ti_log_lines, mock_get_failed_tis, mock_get_data_interval, mock_get_context):
  20. # Настройка моков
  21. mock_get_context.return_value = MagicMock()
  22. mock_get_data_interval.return_value = (MagicMock(), MagicMock())
  23. mock_get_failed_tis.return_value = [MagicMock()]
  24. mock_get_ti_log_lines.return_value = ['Log line 1', 'Log line 2']
  25.  
  26. # Вызов тестируемой функции
  27. > result = get_failed_tis_with_specific_tags(['tag1', 'tag2'], ['INFO', 'WARNING'])
  28.  
  29. test_monitoring.py:59:
  30. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  31. ..\..\..\dependencies\services\monitoring\monitoring.py:52: in get_failed_tis_with_specific_tags
  32. context = get_current_context()
  33. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  34.  
  35. def get_current_context() -> Context:
  36. """
  37. Obtain the execution context for the currently executing operator without
  38. altering user method's signature.
  39. This is the simplest method of retrieving the execution context dictionary.
  40.  
  41. **Old style:**
  42.  
  43. .. code:: python
  44.  
  45. def my_task(**context):
  46. ti = context["ti"]
  47.  
  48. **New style:**
  49.  
  50. .. code:: python
  51.  
  52. from airflow.operators.python import get_current_context
  53.  
  54.  
  55. def my_task():
  56. context = get_current_context()
  57. ti = context["ti"]
  58.  
  59. Current context will only have value if this method was called after an operator
  60. was starting to execute.
  61. """
  62. if not _CURRENT_CONTEXT:
  63. > raise AirflowException(
  64. "Current context was requested but no context was found! "
  65. "Are you running within an airflow task?"
  66. )
  67. E airflow.exceptions.AirflowException: Current context was requested but no context was found! Are you running within an airflow task?
  68.  
  69. ..\..\..\..\..\..\..\env\lib\site-packages\airflow\operators\python.py:748: AirflowException
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86. ======================== 1 failed, 1 warning in 1.75s =========================
  87.  
  88. Process finished with exit code 1
  89.  
  90.  
  91.  
  92.  
Add Comment
Please, Sign In to add comment