Skip to content

Commit f603334

Browse files
committed
FIX test for 8a24c63
1 parent 8a24c63 commit f603334

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

server/tests/unit/api/test_dataset_api.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from io import StringIO
22
from typing import Iterable
3+
import unittest
34

45
import pytest
56
from flask import Flask
@@ -140,6 +141,13 @@ class MockBedtoolsService:
140141
]
141142
SUBTRACT_RESULT = [SubtractRecord(**DEFAULT_COMPARISON_RECORD.dict())]
142143

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+
143151
def intersect_comparison_records(
144152
self,
145153
a_records: Iterable[ComparisonRecord],
@@ -149,13 +157,6 @@ def intersect_comparison_records(
149157
self._log_operation("intersect", a_records, b_records_list, is_strand)
150158
return MockBedtoolsService.INTERSECT_RESULT
151159

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-
159160
def closest_comparison_records(
160161
self,
161162
a_records: Iterable[ComparisonRecord],
@@ -358,15 +359,20 @@ def test_bad_url(test_client, mock_services, url, http_status, message):
358359

359360

360361
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()
361366
assert MockBedtoolsService.last_operation == operation
362367
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),
365371
)
366372
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),
370376
)
371377
if upload is not None:
372378
if euf:

0 commit comments

Comments
 (0)