Skip to content

Commit afa872b

Browse files
authored
Merge pull request #175 from MoseleyBioinformaticsLab/paths
Makes the git repository, tests, and source code compatible with Windows
2 parents d2f1be6 + e9c708d commit afa872b

12 files changed

Lines changed: 609 additions & 33 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ on:
1212
jobs:
1313
build:
1414

15-
runs-on: ubuntu-latest
1615
strategy:
1716
matrix:
1817
python-version: ["3.8", "3.9", "3.10"]
18+
os: [ ubuntu-latest, windows-latest ]
19+
runs-on: ${{matrix.os}}
1920

2021
steps:
2122
- uses: actions/checkout@v3

dev/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ echo "Removing previous .env/ directory if it exists..."
22
rm -rf .env/
33
echo "Creating new .env/ directory..."
44
python3 -m venv .env/
5-
source .env/bin/activate
5+
source .env/bin/activate || source .env/Scripts/activate # Windows has Scripts instead of bin
66
python3 -m pip install --upgrade pip
77
python3 -m pip install pytest pytest-mock pytest-cov sphinx sphinx-rtd-theme notebook
88
python3 -m pip install -e .

dev/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
source .env/bin/activate
1+
source .env/bin/activate || source .env/Scripts/activate # Windows has Scripts instead of bin
22

3-
python -m pytest dev --cov --cov-branch --cov-report=term-missing
3+
python3 -m pytest dev --cov --cov-branch --cov-report=term-missing

dev/test_data/all-brite-entry-ids.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ br:br01800
122122
br:br01810
123123
br:br08011
124124
br:br08020
125+
br:br08012
125126
br:br08120
126127
br:br08319
127128
br:br08329

dev/test_data/brite-entries.zip

-11.5 KB
Binary file not shown.
File renamed without changes.

dev/test_data/brite-entries/br_br08431.txt

Lines changed: 554 additions & 0 deletions
Large diffs are not rendered by default.
File renamed without changes.

dev/test_data/module-pathway-link.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ path:map00030 md:M00633
2020
path:map00030 md:M00631
2121
path:map00030 md:M00580
2222
path:map00030 md:M00308
23+
path:map00030 md:M00968
2324
path:map00040 md:M00129
2425
path:map00040 md:M00061
2526
path:map00040 md:M00014
@@ -100,6 +101,7 @@ path:map00230 md:M00053
100101
path:map00230 md:M00005
101102
path:map00230 md:M00546
102103
path:map00230 md:M00959
104+
path:map00230 md:M00968
103105
path:map00230 md:M00958
104106
path:map00232 md:M00915
105107
path:map00240 md:M00046
@@ -108,6 +110,7 @@ path:map00240 md:M00052
108110
path:map00240 md:M00053
109111
path:map00240 md:M00938
110112
path:map00240 md:M00939
113+
path:map00240 md:M00968
111114
path:map00250 md:M00027
112115
path:map00250 md:M00740
113116
path:map00253 md:M00778
@@ -301,6 +304,7 @@ path:map00630 md:M00373
301304
path:map00630 md:M00740
302305
path:map00630 md:M00741
303306
path:map00630 md:M00532
307+
path:map00630 md:M00968
304308
path:map00640 md:M00013
305309
path:map00640 md:M00741
306310
path:map00650 md:M00027
@@ -417,6 +421,8 @@ path:map00941 md:M00138
417421
path:map00941 md:M00940
418422
path:map00943 md:M00941
419423
path:map00943 md:M00942
424+
path:map00946 md:M00967
425+
path:map00946 md:M00966
420426
path:map00950 md:M00945
421427
path:map00950 md:M00943
422428
path:map00950 md:M00944
@@ -824,6 +830,7 @@ path:map01100 md:M00904
824830
path:map01100 md:M00906
825831
path:map01100 md:M00932
826832
path:map01100 md:M00933
833+
path:map01100 md:M00967
827834
path:map01100 md:M00952
828835
path:map01100 md:M00953
829836
path:map01100 md:M00960
@@ -836,6 +843,8 @@ path:map01100 md:M00900
836843
path:map01100 md:M00925
837844
path:map01100 md:M00915
838845
path:map01100 md:M00934
846+
path:map01100 md:M00966
847+
path:map01100 md:M00968
839848
path:map01100 md:M00909
840849
path:map01100 md:M00951
841850
path:map01100 md:M00958

dev/test_main.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ def test_main_pull(mocker, args: list, output: str):
121121
stdin_mock = """
122122
br:br08005
123123
br:br08902
124-
124+
br:br08431
125+
125126
br:br03220
126127
br:br03222
127128
"""
@@ -130,18 +131,22 @@ def test_main_pull(mocker, args: list, output: str):
130131

131132
successful_entry_ids = [
132133
'br:br08005',
133-
'br:br08902'
134+
'br:br08902',
135+
'br:br08431'
134136
]
135137

138+
# The expected output file names have underscores instead of colons in case testing on Windows.
139+
expected_output_files: list = [entry_id.replace(':', '_') for entry_id in successful_entry_ids]
140+
136141
expected_pull_results = {
137142
'successful-entry-ids': successful_entry_ids,
138143
'failed-entry-ids': ['br:br03220', 'br:br03222'],
139144
'timed-out-entry-ids': [],
140-
'num-successful': 2,
145+
'num-successful': 3,
141146
'num-failed': 2,
142147
'num-timed-out': 0,
143-
'num-total': 4,
144-
'percent-success': 50.0,
148+
'num-total': 5,
149+
'percent-success': 60.0,
145150
'pull-minutes': 1.0
146151
}
147152

@@ -153,22 +158,23 @@ def test_main_pull(mocker, args: list, output: str):
153158

154159
assert time_mock.call_count == 2
155160

156-
if output.endswith('.zip'):
157-
with zf.ZipFile(output, 'r') as actual_zip:
158-
with zf.ZipFile(f'dev/test_data/{output}', 'r') as expected_zip:
159-
for successful_entry_id in successful_entry_ids:
160-
actual_entry: str = actual_zip.read(successful_entry_id + '.txt').decode()
161-
expected_entry: str = expected_zip.read(successful_entry_id + '.txt').decode()
161+
# If running on Windows, change the actual files names to have underscores instead of colons.
162+
if os.name == 'nt': # pragma: no cover
163+
expected_output_files: list = expected_output_files[:-1] # The last brite gives different output on Windows
164+
successful_entry_ids: list = expected_output_files # pragma: no cover
162165

163-
assert actual_entry == expected_entry
164-
else:
165-
for successful_entry_id in successful_entry_ids:
166+
for successful_entry_id, expected_output_file in zip(successful_entry_ids, expected_output_files):
167+
if output.endswith('.zip'):
168+
with zf.ZipFile(output, 'r') as actual_zip:
169+
actual_entry: str = actual_zip.read(successful_entry_id + '.txt').decode()
170+
else:
166171
with open(f'{output}/{successful_entry_id}.txt') as actual_file:
167-
with open(f'dev/test_data/{output}/{successful_entry_id}.txt') as expected_file:
168-
actual_entry: str = actual_file.read()
169-
expected_entry: str = expected_file.read()
172+
actual_entry: str = actual_file.read()
173+
174+
with open(f'dev/test_data/brite-entries/{expected_output_file}.txt') as expected_file:
175+
expected_entry: str = expected_file.read()
170176

171-
assert actual_entry == expected_entry
177+
assert actual_entry == expected_entry
172178

173179
with open('pull-results.json', 'r') as file:
174180
actual_pull_results: dict = j.load(file)

0 commit comments

Comments
 (0)