test: untested functions in utils.py
- Dominant language
- Python
- Stars
- 17
- Forks
- 10
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 2
Description
these two functions in `./src/s2dm/exporters/utils.py` were added on main and are currently not tested
```
def get_argument_content(
element: GraphQLObjectType | GraphQLField, directive_name: str, argument_name: str
) -> Any | None:
"""
Extracts the comment from a GraphQL element (field or named type).
Args:
element (GraphQLNamedType | GraphQLField): The GraphQL element to extract the comment from.
Returns:
str | None: The comment if present, otherwise None.
"""
args = get_directive_arguments(element, directive_name)
return args.get(argument_name) if args and argument_name in args else None
def get_cardinality(field: GraphQLField) -> Cardinality | None:
"""
Extracts the @cardinality directive arguments from a GraphQL field, if present.
Args:
field (GraphQLField): The field to extract cardinality from.
Returns:
Cardinality | None: The Cardinality if the directive is present, otherwise None.
"""
if has_directive(field, "cardinality"):
args = get_directive_arguments(field, "cardinality")
min_val = None
max_val = None
if args:
min_val = int(args["min"]) if "min" in args and args["min"] is not None else None
max_val = int(args["max"]) if "max" in args and args["max"] is not None else None
return Cardinality(min=min_val, max=max_val)
else:
return None
```
Contributor guide
Research direction
Open src/s2dm/exporters/utils.py and read get_argument_content and get_cardinality first. Add tests covering their documented directive, argument, missing-value, and cardinality branches, then run the repository's Python tests; done means both functions have coverage for present and absent data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100