Coverage for tests\dummies_utils.py: 100.00%
14 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-22 23:23 +0100
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-22 23:23 +0100
1# -*- coding: utf-8 -*-
3"""
4* Name: interactive-clustering-gui/tests/dummies_utils.py
5* Description: Utils methods to create dummies projects for the pytest "app" test suite.
6* Author: Erwan Schild
7* Created: 22/02/2022
8* Licence: CeCILL (https://cecill.info/licences.fr.html)
9"""
11# ==============================================================================
12# IMPORT PYTHON DEPENDENCIES
13# ==============================================================================
15import os
16import shutil
17from pathlib import Path
18from typing import List, Tuple
20# ==============================================================================
21# LIST OF DUMMY DATASETS
22# ==============================================================================
23LIST_OF_DUMMY_DATASETS: Tuple = (
24 "dummy_24_err.csv",
25 "dummy_24_err.xlsx",
26 "dummy_24.csv",
27 "dummy_24.xlsx",
28)
31# ==============================================================================
32# LIST OF DUMMY PROJECTS
33# ==============================================================================
34LIST_OF_DUMMY_PROJECTS: Tuple = (
35 "0a_INITIALIZATION_WITHOUT_MODELIZATION",
36 "0b_INITIALIZATION_WITH_PENDING_MODELIZATION",
37 "0c_INITIALIZATION_WITH_WORKING_MODELIZATION",
38 "0d_CLUSTERING_TODO",
39 "0e_CLUSTERING_PENDING",
40 "0f_CLUSTERING_WORKING",
41 "0g_ITERATION_END",
42 "1a_SAMPLING_TODO",
43 "1b_SAMPLING_PENDING",
44 "1c_SAMPLING_WORKING",
45 "1d_ANNOTATION_WITH_UPTODATE_MODELIZATION",
46 "1e_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITHOUT_CONFLICTS",
47 "1f_ANNOTATION_WITH_PENDING_MODELIZATION_WITHOUT_CONFLICTS",
48 "1g_ANNOTATION_WITH_WORKING_MODELIZATION_WITHOUT_CONFLICTS",
49 "1h_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS",
50 "1i_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS",
51 "1j_ANNOTATION_WITH_PENDING_MODELIZATION_WITH_CONFLICTS",
52 "1k_ANNOTATION_WITH_WORKING_MODELIZATION_WITH_CONFLICTS",
53 "1l_ANNOTATION_WITH_UPTODATE_MODELIZATION",
54 "1m_CLUSTERING_TODO",
55 "1n_CLUSTERING_PENDING",
56 "1o_CLUSTERING_WORKING",
57 "1p_ITERATION_END",
58 "2a_SAMPLING_TODO",
59 "2b_SAMPLING_PENDING",
60 "2b2_SAMPLING_PENDING",
61 "2d_ANNOTATION_WITH_UPTODATE_MODELIZATION",
62 "import_0y0_INITIALIZATION_WITHOUT_MODELIZATION",
63 "import_0y1_INITIALIZATION_WITH_PENDING_MODELIZATION",
64 "import_0y2_INITIALIZATION_WITH_WORKING_MODELIZATION",
65 "import_1w0_IMPORT_AT_SAMPLING_STEP_WITHOUT_MODELIZATION",
66 "import_1w1_IMPORT_AT_SAMPLING_STEP_WITH_PENDING_MODELIZATION",
67 "import_1w2_IMPORT_AT_SAMPLING_STEP_WITH_WORKING_MODELIZATION",
68 "import_1x0_IMPORT_AT_ANNOTATION_STEP_WITHOUT_MODELIZATION",
69 "import_1x1_IMPORT_AT_ANNOTATION_STEP_WITH_PENDING_MODELIZATION",
70 "import_1x2_IMPORT_AT_ANNOTATION_STEP_WITH_WORKING_MODELIZATION",
71 "import_1y0_IMPORT_AT_CLUSTERING_STEP_WITHOUT_MODELIZATION",
72 "import_1y1_IMPORT_AT_CLUSTERING_STEP_WITH_PENDING_MODELIZATION",
73 "import_1y2_IMPORT_AT_CLUSTERING_STEP_WITH_WORKING_MODELIZATION",
74 "import_1z0_IMPORT_AT_ITERATION_END_WITHOUT_MODELIZATION",
75 "import_1z1_IMPORT_AT_ITERATION_END_WITH_PENDING_MODELIZATION",
76 "import_1z2_IMPORT_AT_ITERATION_END_WITH_WORKING_MODELIZATION",
77 "import_error_0y1_INITIALIZATION_WITH_PENDING_MODELIZATION",
78 "import_error_0y3_INITIALIZATION_WITH_ERRORS",
79 "import_error_1w1_IMPORT_AT_SAMPLING_STEP_WITH_PENDING_MODELIZATION",
80 "import_error_1w3_IMPORT_AT_SAMPLING_STEP_WITH_ERRORS",
81 "import_error_1x1_IMPORT_AT_ANNOTATION_STEP_WITH_PENDING_MODELIZATION",
82 "import_error_1x3_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS",
83 "import_error_1y1_IMPORT_AT_CLUSTERING_STEP_WITH_PENDING_MODELIZATION",
84 "import_error_1y3_IMPORT_AT_CLUSTERING_STEP_WITH_ERRORS",
85 "import_error_1z1_IMPORT_AT_ITERATION_END_WITH_PENDING_MODELIZATION",
86 "import_error_1z3_IMPORT_AT_ITERATION_END_WITH_ERRORS",
87)
90# ==============================================================================
91# LIST OF DUMMY EXPORTS
92# ==============================================================================
93LIST_OF_DUMMY_EXPORTS: Tuple = (
94 "archive-0a_INITIALIZATION_WITHOUT_MODELIZATION.zip",
95 "archive-1b_SAMPLING_PENDING.zip",
96 "archive-1d_ANNOTATION_WITH_UPTODATE_MODELIZATION.zip",
97 "archive-1h_ANNOTATION_WITH_OUTDATED_MODELIZATION_WITH_CONFLICTS.zip",
98 "archive-1j_ANNOTATION_WITH_PENDING_MODELIZATION_WITH_CONFLICTS.zip",
99 "archive-1k_ANNOTATION_WITH_WORKING_MODELIZATION_WITH_CONFLICTS.zip",
100 "archive-1l_ANNOTATION_WITH_UPTODATE_MODELIZATION.zip",
101 "archive-1o_CLUSTERING_WORKING.zip",
102 "archive-1p_ITERATION_END.zip",
103 "archive-ERROR_metadata_bad_creation_timestamp.zip",
104 "archive-ERROR_metadata_bad_project_name.zip",
105 "archive-ERROR_metadata_missing_creation_timestamp.zip",
106 "archive-ERROR_metadata_missing_project_name.zip",
107 "archive-ERROR_missing_files.zip",
108 "archive-ERROR_status_bad_state.zip",
109 "archive-ERROR_status_missing_state.zip",
110)
113# ==============================================================================
114# COPY DUMMY PROJECTS
115# ==============================================================================
116def create_dummy_projects(tmp_path: Path, list_of_dummy_project_ids: List[str]):
117 """
118 Create a list of dummy project (copying from "./dummies").
120 Args:
121 tmp_path (Path): The path to a temporary directory.
122 list_of_dummy_project_ids (List[str]): A list of IDs of dummy projects to copy.
123 """
125 # Get path to dummy projects.
126 path_to_dummy_projects: Path = Path(__file__).parent / "dummies"
128 # For each request dummy project ID...
129 for dummy_project_id in list_of_dummy_project_ids:
130 # Copy the dummy project.
131 if os.path.isdir(path_to_dummy_projects / dummy_project_id):
132 shutil.copytree(
133 src=(path_to_dummy_projects / dummy_project_id),
134 dst=(tmp_path / dummy_project_id),
135 )
136 else:
137 shutil.copy(
138 src=(path_to_dummy_projects / dummy_project_id),
139 dst=(tmp_path / dummy_project_id),
140 )