Skip to content

Commit

Permalink
🔨 Update tests files
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoinePELAMOURGUES committed Nov 20, 2024
1 parent 613e48f commit 1e37964
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 29 deletions.
22 changes: 13 additions & 9 deletions tests/Dags_airflow/test_knn_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@
import numpy as np

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../airflow/dags')))
from predict_knn_model import create_X
from predict_knn_model import create_X, my_dag

@pytest.fixture()
def dagbag():
return DagBag()
def test_dag_loaded():
"""Test que le DAG est correctement chargé."""
assert my_dag is not None
assert len(imdb_scraper_dag.tasks) == 1
assert my_dag.task_dict['train_model'] is not None


# Test des propriétés basiques du DAG
assert my_dag.dag_id == 'KNN_train_model'
assert my_dag.schedule_interval == '@daily'
assert my_dag.default_args['owner'] == 'airflow'
assert my_dag.default_args['start_date'] == datetime(2024, 11, 15)

def test_dag_loaded(dagbag):
dag = dagbag.get_dag(dag_id="KNN_train_model")
assert dagbag.import_errors == {}
assert dag is not None
assert len(dag.tasks) == 1

def test_create_X():
# Créer un petit DataFrame de test
Expand Down
22 changes: 13 additions & 9 deletions tests/Dags_airflow/test_scrapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
import os

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../airflow/dags')))
from scrapping import dag


@pytest.fixture()
def dagbag():
return DagBag()

def test_dag_loaded(dagbag):
dag = dagbag.get_dag(dag_id="imdb_scraper_dag")
assert dagbag.import_errors == {}
def test_dag_loaded():
"""Test que le DAG est correctement chargé."""
assert dag is not None
assert len(dag.tasks) == 1
assert len(imdb_scraper_dag.tasks) == 3
assert dag.task_dict['scrape_imdb_task'] is not None
assert dag.task_dict['update_movies_task'] is not None
assert dag.task_dict['update_links_task'] is not None


# Test des propriétés basiques du DAG
assert dag.dag_id == 'imdb_scraper_dag'
assert dag.schedule_interval == '@daily'
assert dag.default_args['owner'] == 'airflow'
assert dag.default_args['start_date'] == datetime(2024, 11, 19)
24 changes: 14 additions & 10 deletions tests/Dags_airflow/test_surprise_svd.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import pytest
from airflow.models import DagBag
import sys
import os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../airflow/dags')))
from airflow.models import DagBag
from datetime import datetime

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../airflow/dags')))
from predict_surprise_SVD import svd_dag

@pytest.fixture()
def dagbag():
return DagBag()
def test_dag_loaded():
"""Test que le DAG est correctement chargé."""
assert svd_dag is not None
assert len(svd_dag.tasks) == 1
assert svd_dag.task_dict['train_model'] is not None

def test_dag_loaded(dagbag):
dag = dagbag.get_dag(dag_id="SVD_train_and_compare_model")
assert dagbag.import_errors == {}
assert dag is not None
assert len(dag.tasks) == 1
# Test des propriétés basiques du DAG
assert svd_dag.dag_id == 'SVD_train_and_compare_model'
assert svd_dag.schedule_interval == '@daily'
assert svd_dag.default_args['owner'] == 'airflow'
assert svd_dag.default_args['start_date'] == datetime(2024, 11, 3)

1 change: 0 additions & 1 deletion tests/test_api_auth.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from unittest.mock import patch, MagicMock
from fastapi.testclient import TestClient
from api.main import app
from api.auth import validate_username, validate_email, validate_password
import pandas as pd
import numpy as np
Expand Down

0 comments on commit 1e37964

Please sign in to comment.