getmoto / moto

A library that allows you to easily mock out tests based on AWS infrastructure.
http://docs.getmoto.org/en/latest/
Apache License 2.0
7.66k stars 2.05k forks source link

batch: fix bug in add_parameters_to_command #8162

Closed giograno closed 1 month ago

giograno commented 1 month ago

https://github.com/getmoto/moto/pull/7973 introduced support for parameters in job commands. However, the _add_parameters_to_command function had a bug that resulted in duplicated arguments, when the number of arguments was greater than one.

This was due to the nested list comprehension logic adopted.

For instance, the given the following job parameters {'dossier_md5': 'abc', 'event_id': 'E12340060311'} and the following command ['--dossier_md5', 'Ref::dossier_md5', '--event_id', 'Ref::event_id'] we were given the following output:

['--dossier_md5', '--dossier_md5', 'abc', 'Ref::dossier_md5', '--event_id', '--event_id', 'Ref::event_id', 'E12340060311']

This PR adjusts the logic accordingly and adds a simple unit test to verify the fix.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.50%. Comparing base (6c68326) to head (9e621f5). Report is 9 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #8162 +/- ## ========================================== - Coverage 94.50% 94.50% -0.01% ========================================== Files 1150 1150 Lines 99203 99202 -1 ========================================== - Hits 93752 93751 -1 Misses 5451 5451 ``` | [Flag](https://app.codecov.io/gh/getmoto/moto/pull/8162/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | Coverage Δ | | |---|---|---| | [servertests](https://app.codecov.io/gh/getmoto/moto/pull/8162/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | `28.79% <100.00%> (+<0.01%)` | :arrow_up: | | [unittests](https://app.codecov.io/gh/getmoto/moto/pull/8162/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto) | `94.47% <100.00%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=getmoto#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.