1
1
from io import StringIO
2
2
from typing import Iterable
3
+ import unittest
3
4
4
5
import pytest
5
6
from flask import Flask
@@ -140,6 +141,13 @@ class MockBedtoolsService:
140
141
]
141
142
SUBTRACT_RESULT = [SubtractRecord (** DEFAULT_COMPARISON_RECORD .dict ())]
142
143
144
+ @staticmethod
145
+ def _log_operation (operation , a_records , b_records_list , is_strand ):
146
+ MockBedtoolsService .last_operation = operation
147
+ MockBedtoolsService .last_a_dataset = list (a_records )
148
+ MockBedtoolsService .last_b_dataset_list = [list (x ) for x in b_records_list ]
149
+ MockBedtoolsService .last_is_strand = is_strand
150
+
143
151
def intersect_comparison_records (
144
152
self ,
145
153
a_records : Iterable [ComparisonRecord ],
@@ -149,13 +157,6 @@ def intersect_comparison_records(
149
157
self ._log_operation ("intersect" , a_records , b_records_list , is_strand )
150
158
return MockBedtoolsService .INTERSECT_RESULT
151
159
152
- @staticmethod
153
- def _log_operation (operation , a_records , b_records_list , is_strand ):
154
- MockBedtoolsService .last_operation = operation
155
- MockBedtoolsService .last_a_dataset = list (a_records )
156
- MockBedtoolsService .last_b_dataset_list = [list (x ) for x in b_records_list ]
157
- MockBedtoolsService .last_is_strand = is_strand
158
-
159
160
def closest_comparison_records (
160
161
self ,
161
162
a_records : Iterable [ComparisonRecord ],
@@ -358,15 +359,20 @@ def test_bad_url(test_client, mock_services, url, http_status, message):
358
359
359
360
360
361
def check_comparison_mocks (operation , reference , comparison , upload , euf , strand ):
362
+ # cf. 8a24c638b9c2a2f21d5ceaa926943d851f59d951
363
+ # assertCountEqual tests that sequence first contains the same elements
364
+ # as second, regardless of their order
365
+ case = unittest .TestCase ()
361
366
assert MockBedtoolsService .last_operation == operation
362
367
assert MockBedtoolsService .last_is_strand == strand
363
- assert MockBedtoolsService .last_a_dataset == get_a_datasets_as_comparison_records (
364
- * reference
368
+ case .assertCountEqual (
369
+ MockBedtoolsService .last_a_dataset ,
370
+ get_a_datasets_as_comparison_records (* reference ),
365
371
)
366
372
if comparison is not None :
367
- assert (
368
- MockBedtoolsService .last_b_dataset_list
369
- == get_b_dataset_list_as_comparison_records (* comparison )
373
+ case . assertCountEqual (
374
+ MockBedtoolsService .last_b_dataset_list ,
375
+ get_b_dataset_list_as_comparison_records (* comparison ),
370
376
)
371
377
if upload is not None :
372
378
if euf :
0 commit comments