|
16 | 16 | from process_tracker.models.extract import ExtractStatus |
17 | 17 | from process_tracker.models.process import ( |
18 | 18 | ErrorType, |
| 19 | + Process, |
19 | 20 | ProcessDependency, |
20 | 21 | ProcessStatus, |
21 | 22 | ProcessType, |
@@ -128,6 +129,54 @@ def test_create_cluster(self): |
128 | 129 |
|
129 | 130 | self.assertEqual("Test Cluster", given_name) |
130 | 131 |
|
| 132 | + def test_create_cluster_process(self): |
| 133 | + """ |
| 134 | + Testing that when creating a cluster process relationship record, it is added. |
| 135 | + :return: |
| 136 | + """ |
| 137 | + cluster = self.data_store.get_or_create_item( |
| 138 | + model=Cluster, cluster_name="Test Cluster" |
| 139 | + ) |
| 140 | + |
| 141 | + process = self.data_store.get_or_create_item( |
| 142 | + model=Process, process_name="Test Cluster Process" |
| 143 | + ) |
| 144 | + |
| 145 | + result = self.runner.invoke( |
| 146 | + main, |
| 147 | + 'create -t "cluster process" --cluster "%s" --child "%s"' |
| 148 | + % (cluster.cluster_name, process.process_name), |
| 149 | + ) |
| 150 | + |
| 151 | + instance = ( |
| 152 | + self.session.query(ClusterProcess) |
| 153 | + .filter(ClusterProcess.cluster_id == cluster.cluster_id) |
| 154 | + .filter(ClusterProcess.process_id == process.process_id) |
| 155 | + .first() |
| 156 | + ) |
| 157 | + |
| 158 | + given_result = [instance.cluster_id, instance.process_id] |
| 159 | + expected_result = [cluster.cluster_id, process.process_id] |
| 160 | + |
| 161 | + self.runner.invoke( |
| 162 | + main, |
| 163 | + [ |
| 164 | + "delete", |
| 165 | + "-t", |
| 166 | + "cluster process", |
| 167 | + "--cluster", |
| 168 | + "Test Cluster", |
| 169 | + "-c", |
| 170 | + "Test Cluster Process", |
| 171 | + ], |
| 172 | + ) |
| 173 | + self.runner.invoke(main, ["delete", "-t", "cluster", "-n", "Test Cluster"]) |
| 174 | + self.runner.invoke( |
| 175 | + main, ["delete", "-t", "process", "-n", "Test Cluster Process"] |
| 176 | + ) |
| 177 | + |
| 178 | + self.assertEqual(expected_result, given_result) |
| 179 | + |
131 | 180 | def test_create_extract_status(self): |
132 | 181 | """ |
133 | 182 | Testing that when creating an extract status record it is added. |
@@ -356,6 +405,51 @@ def test_delete_cluster(self): |
356 | 405 | self.assertEqual(None, instance) |
357 | 406 | self.assertEqual(0, result.exit_code) |
358 | 407 |
|
| 408 | + def test_create_cluster_process(self): |
| 409 | + """ |
| 410 | + Testing that when creating a cluster process relationship record, it is added. |
| 411 | + :return: |
| 412 | + """ |
| 413 | + cluster = self.data_store.get_or_create_item( |
| 414 | + model=Cluster, cluster_name="Test Cluster" |
| 415 | + ) |
| 416 | + |
| 417 | + process = self.data_store.get_or_create_item( |
| 418 | + model=Process, process_name="Test Cluster Process" |
| 419 | + ) |
| 420 | + |
| 421 | + result = self.runner.invoke( |
| 422 | + main, |
| 423 | + 'create -t "cluster process" --cluster "%s" --child "%s"' |
| 424 | + % (cluster.cluster_name, process.process_name), |
| 425 | + ) |
| 426 | + |
| 427 | + self.runner.invoke( |
| 428 | + main, |
| 429 | + [ |
| 430 | + "delete", |
| 431 | + "-t", |
| 432 | + "cluster process", |
| 433 | + "--cluster", |
| 434 | + "Test Cluster", |
| 435 | + "-c", |
| 436 | + "Test Cluster Process", |
| 437 | + ], |
| 438 | + ) |
| 439 | + self.runner.invoke(main, ["delete", "-t", "cluster", "-n", "Test Cluster"]) |
| 440 | + self.runner.invoke( |
| 441 | + main, ["delete", "-t", "process", "-n", "Test Cluster Process"] |
| 442 | + ) |
| 443 | + |
| 444 | + instance = ( |
| 445 | + self.session.query(ClusterProcess) |
| 446 | + .filter(ClusterProcess.cluster_id == cluster.cluster_id) |
| 447 | + .filter(ClusterProcess.process_id == process.process_id) |
| 448 | + .first() |
| 449 | + ) |
| 450 | + |
| 451 | + self.assertEqual(None, instance) |
| 452 | + |
359 | 453 | def test_delete_extract_status(self): |
360 | 454 | """ |
361 | 455 | Testing that when deleting an extract status record not on the protected list, it is deleted. |
|
0 commit comments