Skip to content

Conversation

@pkess
Copy link
Contributor

@pkess pkess commented Dec 20, 2021

This implements test for the issue #584. It is not finished yet but i will continue working on this

@codecov
Copy link

codecov bot commented Dec 20, 2021

Codecov Report

Merging #1198 (7a20405) into develop (e7a2b04) will increase coverage by 0.17%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop    #1198      +/-   ##
===========================================
+ Coverage    65.65%   65.83%   +0.17%     
===========================================
  Files           86       86              
  Lines         8846     8859      +13     
===========================================
+ Hits          5808     5832      +24     
+ Misses        3038     3027      -11     

@pkess
Copy link
Contributor Author

pkess commented Dec 26, 2021

I think this is ready for review and merge now

Copy link
Collaborator

@zariiii9003 zariiii9003 left a comment

Choose a reason for hiding this comment

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

Hello Peter, thank you for your contribution and sorry for the late reply! Tests are always welcome.
I think it makes sense to check the call arguments of the mock. Otherwise this looks good to me, just some minor cosmetic issues.

pkess and others added 3 commits January 11, 2022 20:27
Co-authored-by: zariiii9003 <52598363+zariiii9003@users.noreply.github.com>
@pkess
Copy link
Contributor Author

pkess commented Jan 11, 2022

Thank you for your review. i changed the code now accordingly

@pkess
Copy link
Contributor Author

pkess commented Jan 11, 2022

Unfortunatelly the compare operator was not implemented for messages. I implemented this now. But do you want this to be added with this pr?

@zariiii9003
Copy link
Collaborator

Unfortunatelly the compare operator was not implemented for messages. I implemented this now. But do you want this to be added with this pr?

There is a Message.equals() method for this purpose. I'd say remove your last commit since that is out of scope for this PR.

@pkess
Copy link
Contributor Author

pkess commented Jan 12, 2022

Unfortunatelly the compare operator was not implemented for messages. I implemented this now. But do you want this to be added with this pr?

There is a Message.equals() method for this purpose. I'd say remove your last commit since that is out of scope for this PR.

I knew about the equals function and i used it in the compare operator. But i think it was necessary to get your proposal with assert_has_calls working. What should i do with this? should i implement an own compare for the executed calls?

@zariiii9003
Copy link
Collaborator

I knew about the equals function and i used it in the compare operator. But i think it was necessary to get your proposal with assert_has_calls working. What should i do with this? should i implement an own compare for the executed calls?

I wonder how i did not notice that, sorry. Nevertheless, there was a discussion in #413 and __eq__ was removed.

We could this instead:

        self.assertTrue(self.mock_virtual_bus.send.mock_calls[0].args[0].equals(msg1))
        self.assertTrue(self.mock_virtual_bus.send.mock_calls[1].args[0].equals(msg2))

It's ugly but it does the job.

@felixdivo felixdivo added the QA about improving and maintaining the quality of the library label Jan 15, 2022
@pkess pkess force-pushed the 584-add_test_player branch from a243016 to 5c6480b Compare January 15, 2022 20:54
@pkess
Copy link
Contributor Author

pkess commented Jan 15, 2022

I knew about the equals function and i used it in the compare operator. But i think it was necessary to get your proposal with assert_has_calls working. What should i do with this? should i implement an own compare for the executed calls?

I wonder how i did not notice that, sorry. Nevertheless, there was a discussion in #413 and __eq__ was removed.

We could this instead:

        self.assertTrue(self.mock_virtual_bus.send.mock_calls[0].args[0].equals(msg1))
        self.assertTrue(self.mock_virtual_bus.send.mock_calls[1].args[0].equals(msg2))

It's ugly but it does the job.

Ok, i implemented it this way now. I used the created message object for the equals function to be sure there will be no error method does not exist when the called argument is not correct.

@pkess
Copy link
Contributor Author

pkess commented Jan 15, 2022

Unfortunately some tests fail now. i will try to fix this

@pkess
Copy link
Contributor Author

pkess commented Jan 15, 2022

Unfortunately some tests fail now. i will try to fix this

It looks like the problem is that the args property was introduced with python3.8. So i only compare this in higher versions now. I think this is ok as the behaviour should not change with python version

Copy link
Collaborator

@felixdivo felixdivo left a comment

Choose a reason for hiding this comment

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

This is a really nice PR! Thanks for tackling this "technical debt" and making sure the code actually works in unit tests! And most importantly, these serve as great regression tests for future changes.

Do you agree that this resolves #584?

@felixdivo felixdivo added this to the 4.0.0 Release milestone Jan 16, 2022
Co-authored-by: Felix Divo <4403130+felixdivo@users.noreply.github.com>
@felixdivo felixdivo merged commit 8b6b592 into hardbyte:develop Jan 16, 2022
@felixdivo felixdivo changed the title 584 add test player Add tests for player Jan 16, 2022
@pkess pkess deleted the 584-add_test_player branch January 16, 2022 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

QA about improving and maintaining the quality of the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants