from ..format import (
    _format_argument,
    _format_arguments,
    _format_classad_boolean_expression,
    _format_condor_command_value,
    _semicolon_separated_pairs,
)


def test_format_argument_with_quotes():
    assert _format_argument("it's") == "'it''s'"
    assert _format_argument('say "hi"') == '\'say ""hi""\''


def test_format_arguments():
    assert _format_arguments(["a", "b"]) == "\"'a' 'b'\""


def test_format_classad_boolean_expression():
    result = _format_classad_boolean_expression(["A", "B"])
    assert result == "(A) {operator} (B)"


def test_semicolon_separated_pairs():
    result = _semicolon_separated_pairs({"key": "val", "flag": None})
    assert result == '"key=val; flag"'


def test_format_condor_command_value_oauth():
    result = _format_condor_command_value(
        "scitokens_oauth_permissions", ["read", "write"]
    )
    assert result == "read write"


def test_format_condor_command_value_oauth_resource():
    result = _format_condor_command_value("myservice_oauth_resource", ["res1", "res2"])
    assert result == "res1 res2"
