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

Incorrectly raised Error in part.instance() #207

Closed
raduiordache opened this issue Sep 28, 2017 · 2 comments
Closed

Incorrectly raised Error in part.instance() #207

raduiordache opened this issue Sep 28, 2017 · 2 comments
Assignees
Labels
Milestone

Comments

@raduiordache
Copy link
Contributor

The code looks like this:

    def instance(self):
        """
        Retrieve the single (expected) instance of this 'Part' (of `Category.MODEL`) as a 'Part'.

        See `Part.instances()` method for documentation.

        :return: pykechain.models.Part
        :raises: NotFoundError, MultipleFoundError
        """
        instances_list = list(self.instances())
        if len(instances_list) == 1:
            return instances_list[0]
        else:
            raise MultipleFoundError("Part {} has more than a single instance. "
                                     "Use the `Part.instances()` method".format(self.name))

It should look something like this:

    def instance(self):
        """
        Retrieve the single (expected) instance of this 'Part' (of `Category.MODEL`) as a 'Part'.

        See `Part.instances()` method for documentation.

        :return: pykechain.models.Part
        :raises: NotFoundError, MultipleFoundError
        """
        instances_list = list(self.instances())
        if len(instances_list) == 1:
            return instances_list[0]
        elif len(instances_list) > 1:
            raise MultipleFoundError("Part {} has more than a single instance. "
                                     "Use the `Part.instances()` method".format(self.name))
       elif len(instances_list) < 1:
            raise NotFoundError("Part {} has no instance. "
                                     "Use the `Part.instances()` method".format(self.name))
@raduiordache
Copy link
Contributor Author

For parts that have multiplicity '0 or x'

@jberends jberends self-assigned this Oct 2, 2017
@jberends jberends added this to the 1.12 milestone Oct 2, 2017
jberends pushed a commit that referenced this issue Oct 2, 2017
jberends pushed a commit that referenced this issue Oct 2, 2017
jberends added a commit that referenced this issue Oct 2, 2017
…nstance

#207 fixed correct response on the notfound and multiplefounderr
@jberends
Copy link
Member

jberends commented Oct 2, 2017

in 1.12.7

@jberends jberends closed this as completed Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants