Skip to content

Commit

Permalink
Check correct values for args, nothing printed
Browse files Browse the repository at this point in the history
  • Loading branch information
dyastremsky committed Feb 29, 2024
1 parent e7b934e commit 655a506
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/c++/perf_analyzer/genai-pa/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from pathlib import Path

import pytest
from genai_pa import parser
from genai_pa.main import run


class TestCLIArguments:
Expand All @@ -52,33 +53,37 @@ def test_help_arguments_output_and_exit(self, arg, expected_output, capsys):
assert expected_output in captured.out

@pytest.mark.parametrize(
"arg, expected_output",
"arg, expected_attributes",
[
(["-b", "2"], "batch_size=2"),
(["--batch-size", "2"], "batch_size=2"),
(["--concurrency", "3"], "concurrency_range='3'"),
(["--max-threads", "4"], "max_threads=4"),
(["-b", "2"], {"batch_size": 2}),
(["--batch-size", "2"], {"batch_size": 2}),
(["--concurrency", "3"], {"concurrency_range": "3"}),
(["--max-threads", "4"], {"max_threads": 4}),
(
["--profile-export-file", "text.txt"],
"profile_export_file=PosixPath('text.txt')",
{"profile_export_file": Path("text.txt")},
),
(["--request-rate", "1.5"], "request_rate_range='1.5'"),
(["--service-kind", "triton"], "service_kind='triton'"),
(["--service-kind", "openai"], "service_kind='openai'"),
(["--request-rate", "1.5"], {"request_rate_range": "1.5"}),
(["--service-kind", "triton"], {"service_kind": "triton"}),
(["--service-kind", "openai"], {"service_kind": "openai"}),
# TODO: Remove streaming from implementation. It is invalid with HTTP.
# (["--streaming"], "Streaming=True"),
(["--version"], "version=True"),
(["-u", "test_url"], "u='test_url'"),
(["--url", "test_url"], "u='test_url'"),
# (["--streaming"], {"streaming": True}),
(["--version"], {"version": True}),
(["-u", "test_url"], {"u": "test_url"}),
(["--url", "test_url"], {"u": "test_url"}),
],
)
def test_arguments_output(self, arg, expected_output, capsys):
def test_arguments_output(self, arg, expected_attributes, capsys):
combined_args = ["--model", "test_model"] + arg
_ = parser.parse_args(combined_args)
args = parser.parse_args(combined_args)

# Capture that the correct message was displayed
# Check that the attributes are set correctly
for key, value in expected_attributes.items():
assert getattr(args, key) == value

# Check that nothing was printed as a byproduct of parsing the arguments
captured = capsys.readouterr()
assert expected_output in captured.out
assert captured.out == ""

def test_arguments_model_not_provided(self):
with pytest.raises(SystemExit) as exc_info:
Expand Down

0 comments on commit 655a506

Please sign in to comment.