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

Issue with "ContainsTheEntry" resolution in version 4.2.0 #83

Closed
jardilac91 opened this issue Jun 5, 2023 · 8 comments
Closed

Issue with "ContainsTheEntry" resolution in version 4.2.0 #83

jardilac91 opened this issue Jun 5, 2023 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@jardilac91
Copy link

jardilac91 commented Jun 5, 2023

Hi, i have this issue with the "ContainsTheEntry" resolution:

self = <[AttributeError("'ContainsTheEntry' object has no attribute 'expected'") raised in repr()] ContainsTheEntry object at 0x1d0fb311ed0>
description = <hamcrest.core.string_description.StringDescription object at 0x000001D0FB725090>

def describe_to(self, description: Description) -> None:
        """passthrough to the matcher's method."""
>       return self.matcher.describe_to(description)
E       AttributeError: 'ContainsTheEntry' object has no attribute 'matcher'`

This happens with screenpy version 4.2.0 in the version 4.1.2 it works fine.

@perrygoy
Copy link
Member

perrygoy commented Jun 6, 2023

Er, how embarrassing—either we missed that one in the deprecation of BaseResolution or we had a botched merge.

Thanks for the issue! I'll get a 4.2.1 release readied up as fast as i can.

@perrygoy perrygoy self-assigned this Jun 6, 2023
@perrygoy perrygoy added the bug Something isn't working label Jun 6, 2023
@bandophahita
Copy link
Contributor

Yikes. I missed this too.

perrygoy added a commit that referenced this issue Jun 6, 2023
* #83: remove BaseResolution inheritance.

* add describe tests for Resolutions.

* remove deprecation test after method was removed.

* add a missing l (h/t @langgaibo).
@perrygoy
Copy link
Member

perrygoy commented Jun 6, 2023

@jardilac91 we've published 4.2.1 with this bugfix! Can you confirm that the issue has been fixed?

@jardilac91
Copy link
Author

jardilac91 commented Jun 6, 2023

Hi @perrygoy the issue was solved, but I have a new problem with this version, in the version 4.1.2 I use this in order to search a key/value in a nested dictionary:

See.the(
            DecryptedBodyOfTheLastResponse(), 
            ContainsTheEntry(user_info = ContainsTheEntry(
                                            some_key = some_value, 
                                            some_key = some_value,
                                            some_key = some_value
                                            )
                              )
)

In this version I have to use:

See.the(
            DecryptedBodyOfTheLastResponse(), 
            ContainsTheEntry({"user_info" : {"some_key" : some_value, 
                                            "some_key" : some_value,
                                            "some_key" : some_value,
                                            }
                                }
                            )
                            
        )

but in this version the assert fails, because it searches that the key user_info contains all the values that the service returns, but I need to validate only some key/values.

Can you help me with this?

@perrygoy
Copy link
Member

perrygoy commented Jun 6, 2023

Aah, interesting. That would be because in the old way, the BaseResolution class inherited from pyhamcrest's BaseMatcher, which allowed you to pass matchers into other matchers. We hadn't thought of this case, i've never used it!

That is a really cool use-case, and we might be able to get it back by having some Resolutions check to see if they were given a Resolvable themselves... in the meantime, will this workaround work?

# cool custom Question, by the way!
body = DecryptedBodyOfTheLastResponse().answered_by(the_actor)
the_actor.should(
    See.the(
        body["user_info"], 
        ContainsTheEntries(  # there is this alias for multi-entry tests, if you want to use it
            {
                "some_key" : some_value, 
                "some_key" : some_value,
                "some_key" : some_value,
            }
        )
    ),
)

Unfortunately, this will slightly change the output of the log, but hopefully it will still be easy to understand.

@perrygoy
Copy link
Member

perrygoy commented Jun 6, 2023

I opened #85 to look into whether we can re-enable that really cool functionality!

@jardilac91
Copy link
Author

jardilac91 commented Jun 6, 2023

Hi @perrygoy thanks, this workaround works great!

@perrygoy
Copy link
Member

perrygoy commented Jun 6, 2023

Thanks for the responses, @jardilac91, and thanks for opening this issue! I'll close this one and track the effort to bring back that old functionality in the other one.

@perrygoy perrygoy closed this as completed Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants