Skip to content
This repository was archived by the owner on Sep 8, 2024. It is now read-only.

Conversation

forslund
Copy link
Collaborator

@forslund forslund commented Jan 20, 2020

Description

This adds unittests for the common play framework along with the semi-replated audioservice interface. Resolves #2332

There are a couple of minor fixes and improvements

  • track_info now uses the wait_for_response mechanic
  • the queue now accepts tracks with mime info.
  • A bunch of docstrings are improved

How to test

Ensure that the travis tests passes.

Contributor license agreement signed?

CLA [ Yes]

@devs-mycroft devs-mycroft added the CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors) label Jan 20, 2020
@forslund forslund force-pushed the test/common-play-skills branch from d90004e to 7af9606 Compare January 23, 2020 18:15
Copy link
Member

@chrisveilleux chrisveilleux left a comment

Choose a reason for hiding this comment

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

Nice work with the refactoring. Try to re-use more code in the unit tests.

bus = mock.Mock(name='bus')
audioservice = AudioService(bus)

# Test proper uri
Copy link
Member

Choose a reason for hiding this comment

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

should each of these be separate tests? IMO each execution of code and result check is a separate test.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, the it's just variations of input so I don't think it should be separate tests. If each check required a bunch of extra setups separating the tests would be called for but not when it's as simple as this.


class TestAudioService(unittest.TestCase):
def test_lifecycle(self):
bus = mock.Mock(name='bus')
Copy link
Member

Choose a reason for hiding this comment

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

add a setup method and put the bus and audioservice init in there. make them instance attributes that can be used in each test. reduce, reuse, recycle! :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I personally want the tests to be as easy to follow as possible without jumping around to see exactly how the setup was done. If this requires some duplication of setup code that's fine by me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Especially since one of the tests include the init I don't want it to be in the setup

@forslund forslund force-pushed the test/common-play-skills branch from 7af9606 to a417efb Compare January 26, 2020 08:45
@forslund
Copy link
Collaborator Author

I refactored out the setup code in the test_common_play_skill since after looking at it again it was slightly complex and it made sense to move it out. I also split up the test of match play query and moved it to a separate testcase class to make sure the test was grouped logically.

The test_audioservice setup was so trivial so I left it as is, moving it to class members just makes it more fragmented and difficult to read.

@forslund forslund force-pushed the test/common-play-skills branch from a417efb to 1524576 Compare February 5, 2020 12:14
@forslund
Copy link
Collaborator Author

forslund commented Feb 5, 2020

Did some more refactoring of the tests, the multi tests have been split out into separate classes to make sure it's shown that they're related.

Some of the code duplication has been removed while some was kept to keep the logic of the test clear.

@forslund forslund merged commit 74c6a48 into MycroftAI:dev Feb 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA: Yes Contributor License Agreement exists (see https://github.com/MycroftAI/contributors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add basic testcases for the audioservice interface
3 participants