Skip to content

Commit 22443d4

Browse files
authored
CLI: for reverse, the input column parameters were ignored (#63)
1 parent 07d71cb commit 22443d4

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

opencage/batch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ async def read_input(self, csv_input, queue):
110110
async def read_one_line(self, row, row_id):
111111
warnings = False
112112

113-
if self.options.command == 'reverse':
114-
input_columns = [1, 2]
115-
elif self.options.input_columns:
113+
if self.options.input_columns:
116114
input_columns = self.options.input_columns
115+
elif self.options.command == 'reverse':
116+
input_columns = [1, 2]
117117
else:
118118
input_columns = None
119119

test/cli/test_cli_args.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,22 @@ def test_defaults():
155155
assert args.optional_api_params == {}
156156
assert args.no_progress is False
157157
assert args.quiet is False
158+
159+
def test_reverse_input_columns():
160+
args = parse_args([
161+
"reverse",
162+
"--api-key", "12345678901234567890123456789012",
163+
"--input", "test/fixtures/input.txt",
164+
"--output", "test/fixtures/output.csv"
165+
])
166+
assert args.input_columns == [1, 2]
167+
168+
args = parse_args([
169+
"reverse",
170+
"--api-key", "12345678901234567890123456789012",
171+
"--input", "test/fixtures/input.txt",
172+
"--output", "test/fixtures/output.csv",
173+
"--input-columns", '2,1'
174+
])
175+
176+
assert args.input_columns == [2, 1]

0 commit comments

Comments
 (0)