Skip to content

Conversation

@andrey-yantsen
Copy link
Contributor

@andrey-yantsen andrey-yantsen commented Sep 8, 2018

Currently I can see following problems with tests:

  1. Tests which run on Travis-CI depends on external Plex Server
  2. The tests aren't running for pull requests
  3. flake8 executed for each python version, which is senselessly
  4. Deploy to PyPi executed for each python version which lead to errors in uploading
  5. The tests require quite a work on building a library, but even after the library is ready not all tests are passing
  6. Part of tests are require an existence of user PKKid
  7. Some of MyPlexAccount test require that you don't have a PlexPass (and it's not really documented)
  8. My Mobile Sync tests require a Plex Pass on other hand, and this is also not documented
  9. The readme not covers a testing procedure
  10. Test results should be reproducible, without "unstable" tests
  11. Tests agains shared libraries should be easy-to-run, and the should run automatically in Travis

As for now I've partially resolved first few easy issues, and stuck with generating a proper library: I have no idea how to get tests related to photoalbum to pass, and I need your help here.

To get my new approach working you have to define PLEXAPI_AUTH_MYPLEX_USERNAME and PLEXAPI_AUTH_MYPLEX_PASSWORD in the your Travis CI ENV variables, instead of PLEXAPI_AUTH_SERVER_BASEURL and PLEXAPI_AUTH_SERVER_TOKEN.

After each run of travis the newly created server and client would be removed from the MyPlex account.

You can check the Travis CI output by visiting https://travis-ci.org/andrey-yantsen/python-plexapi/builds/426206148.

@andrey-yantsen
Copy link
Contributor Author

Which version of Plex are you currently using for tests? There is no setting named collectUsageData in latest public build.

@Hellowlol
Copy link
Collaborator

Dunno, Its @pkkid test server.

@Hellowlol
Copy link
Collaborator

I dont know. @pkkid what version is the test server? Our test account don’t have plex pass so these need to be be skipped if plex pass is missing.

@andrey-yantsen
Copy link
Contributor Author

Yep, I've just added a skip if there is no PlexPass... Anyway, the main question now is about the current testing server: which version of Plex is used and how exactly library is organised.

@Hellowlol
Copy link
Collaborator

Dunno, my suggestion would be to build a root dir with tvshow, movies, photo and music. Add the files there and just zip them. We could download and setup the entire thing on demand. I’m a bit worried about testing time and I don’t want to keep downloading the same files over and over. Metadata creation might take some time too.

@andrey-yantsen
Copy link
Contributor Author

Testing time is ~8 minutes (or 20 minutes, if you test all python versions sequentially) with bootstrapping from scratch: download the required media, set up libraries, wait for metadata, and this is exactly how the tests working in this PR. It's about 4 times longer the the your current approach.

@andrey-yantsen
Copy link
Contributor Author

Ok, looks like I've resolved the issue with photos: Plex have 2 types of photo albums:

  1. Playlists
  2. Physical folders on the server

And I initially found only first one. Thank you for the attention :) I hope other issues would be less problematic.

@pkkid
Copy link
Collaborator

pkkid commented Sep 9, 2018

@andrey-yantsen - I'm OK with tests taking 4 times longer if we are standing up and tearing down the Plex server as part of it. It's a much more reliable way to test moving forward. -- We should add the requirements to get tests working to the README of the project. I think all it requires beyond the pip install is the environment variables mentioned above?

@andrey-yantsen
Copy link
Contributor Author

Ok guys, seems like I've done here, please review all of this.

As for websocket-client — version 0.53.0 didn't worked on Travis from the first try and I didn't investigated it further.

@andrey-yantsen andrey-yantsen changed the title [WIP] [Do not merge] Improvements in tests process Improvements in tests process Sep 10, 2018
def test_myplex_webhooks(account):
if account.subscriptionActive:
assert not account.webhooks()
assert type(account.webhooks()) is list
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not isinstance?

releases = self.fetchItems('/updater/status')
if len(releases):
return releases[0]
else:
Copy link
Collaborator

Choose a reason for hiding this comment

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

the else part could just be removed. since returns None anyway.

def seasons(self, **kwargs):
""" Returns a list of :class:`~plexapi.video.Season` objects. """
key = '/library/metadata/%s/children' % self.ratingKey
key = '/library/metadata/%s/children?excludeAllLeaves=1' % self.ratingKey
Copy link
Collaborator

Choose a reason for hiding this comment

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

Whats the benefit by excludeAllLeaves? Faster?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without it we'd have "All Seasons" as one more seasons, I think it's a bit unexpected.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Im not sure i understand. This is supposed to returns all seasons. does that still happen?

Copy link
Contributor Author

@andrey-yantsen andrey-yantsen Sep 11, 2018

Choose a reason for hiding this comment

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

Yep, sure. If the show has 2 seasons it'll return [<Season 1>, <Season 2>], but if you'd omit excludeAllLeaves you'll receive [<All Seasons>, <Season 1>, <Season 2>].

@andrey-yantsen
Copy link
Contributor Author

Oh, guys, just remembered: I know nothing about client-related tests, can you please cover it in the docs?

@Hellowlol
Copy link
Collaborator

Hellowlol commented Sep 11, 2018

i dont think the clients is tested at all atm as it needs to be on the same local network as the server. Really stellar work btw! Thank you so much.

@andrey-yantsen
Copy link
Contributor Author

Ooooh, I have one more idea, I can't stop it, sorry :) I'll try to automate the client tests this evening using Plex Web and some Selenium magic.

@andrey-yantsen
Copy link
Contributor Author

I've made some progress with client tests, but in order to get them working I need to dig into PlexClient and rewrite some parts of it. You can take a look at my working branch for this, if you're interested: https://github.com/andrey-yantsen/python-plexapi/tree/client-tests.

Shortly: In my working branch I was able to create an instance of Plex Web within a docker, and also I was able to play a photo/video on it using my real browser, but that's all what I've achieved.

I'll perform another attempt later, but I think it would be better to do it within another PR.

@Hellowlol Hellowlol merged commit 68fc970 into pushingkarmaorg:master Sep 14, 2018
@andrey-yantsen
Copy link
Contributor Author

@Hellowlol you need to remove PLEXAPI_AUTH_SERVER_TOKEN from env in Travis

@andrey-yantsen andrey-yantsen deleted the shiny-travis branch September 14, 2018 18:17
@andrey-yantsen
Copy link
Contributor Author

image
🎉 🎉 🎉

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.

3 participants