Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add Group and Group Membership data models to restapi #329

Closed
wants to merge 6 commits into from

Conversation

alexb1200
Copy link
Contributor

resolves #287

log.info("Request received", group_id=groupId)
group = self._group_service.get(groupId, error_if_not_found=True, log=log)

return cast(Group, group)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if necessary, service returns Group type already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mypy raises an error as it interprets the return from the query as Any.

)
name = fields.String(
attribute="name",
allow_none=True, # should we force the user to pick a name?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving a note here for James to review. I think all groups should have names.

class GroupService(object):
"""The service methods for registering and managing groups by their unique id."""

def get_all(self, **kwargs) -> List[Group]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to returning -> list[Group]

from __future__ import annotations

import datetime
from typing import Any, List, cast
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove List import


log.info("Request received")

parsed_obj = request.parsed_obj # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth defining default values for some of these parameters (not sure if read and write values will always be provided. I achieved this with request.args.get(), but that code still needs to be reviewed by James.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For permissions, I think we should always force the creator to define what the added User can and cannot do explicitly. Otherwise we risk permissions being applied inappropriately, which may lead to further issues down the road. Maybe defaults can exist as part of the ui in terms of toggles? That way the user is at least fully aware of what is being set.

"""Retrieve a list of all group memberships.

Returns:
List[GroupMembership]: List of group memberships.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo, List instead of list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, the whole type should be removed from the docstring. My mistake for including it.

Copy link
Contributor

@lbarbMITRE lbarbMITRE Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only file that needs major changes. Main takeaways are:
-Tests need to interact with the controller and not the service
-Tests need to be restructured to focus on user flow, rather than testing functionality individually.
-Tests need to be restructured according to the "actions", "assertions", and "tests" sections
-We might need to split up group and group_membership tests. As they are so closely related, maybe not if we can define tests which combine and cover them both (need James' input on this one).

Before going back over the file again, I would try to define some integrative user stories, get feedback, and then use them as a framework for reorganizing the tests.

Since the purpose of this PR is to get the group and group_membership src files merged, we can possibly separate out the tests into another issue and I can have a crack at them.

@alexb1200
Copy link
Contributor Author

Closing due to REST V1 refactors and new database.

@alexb1200 alexb1200 closed this Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants