Testing channels using nose

I’m working on getting Plex channels and nose working together. This can allow a much quicker workflow: run tests without the server running.

Documentation for Plex/nose Example
Source on GitHub

Read either of those, if you’d like. The repository also doubles as a functional starting point for Plex channels (read: plex plugin boilerplate)

Since I am fairly new to Python and newer still to testing in Python, any insight you may have would be greatly appreciated.

I’ve pushed some new features: a couple of new decorators to ensure the Dict is always reset and a TestCase to inherit from to save you from repeating the same decorators over and over.

import plex_nose
class SimpleTests(plex_nose.TestCase):
def test_dict_is_reset():
eq_({}, Dict._dict)

Is anyone using this? I’m adding what I can as I go, but my channel doesn’t use Data, SharedCode or anything other than Dict, really.

I'm not using it (yet), haven't had the time to RTFM but in the future I'd like to start using this.  

Maybe a very brief tutorial might be in order if you have the time/inclination to do so.

I have been trying to keep its own Contents/Code/test___init__.py as exemplary as possible, though I suppose I could write a “zero-to-testing” tutorial later when work is finished

Yep a zero-to-testing example with a real-world example would probably be very useful (not only for myself but for others).  Thanks for doing this!

So I could not get things running smoothly on Ubuntu.

  • Plex ships its own python on Linux, so you cannot install nose via pip or easy_install or apt
  • tests needed to be run under sudo for permission errors
  • the file to run the tests does not exit properly, so you’ve got to kill a python process before you can continue
  • tests pass or fail at random


    I’ll see if it will work on at least windows, but that’s really got me bummed out.

so windows was even less of a go, but I've got Ubuntu dialed in at least. and now running tests without guard is much easier via run-osx.sh or run-ubuntu.sh

still no concrete tutorial though, that will take some time.

Thanks again for continuing to work on this one.  I think it will be incredibly useful for us channel devs going forward once it's up and running and we have a tutorial to point people towards.

so I’ve just pushed a “tutorial” of sorts. the channel now streams videos from Gamespot.com, complete with a URL service and using Services/Shared Code, everything is tested, and more importantly, it doesn’t actually hit the network during the tests.

Now, I am awful at writing tutorials, but love answering questions. so if you have any, shoot.

after another round of integrating this with my plugin, I’ve added a few test helpers, spec so the output is nicer, and tried my best at documenting everything in the README (though I still recommend browsing Contents/Tests/)

okay, last update for a while. first post is hella updated.

I’ve also pushed the current development branch of ss-plex, for a way more in-depth example.

really, I cannot stress how easy this makes development. the suite in ss-plex finishes in just under 2s real time (~0.3s in python).

and when it comes time to start hacking at something, just write a function in a file that gets tested (test___init__.py), code away as you would in your init.py (bonus: print is a useful statement to us now), and the tests get run each file save.

either way, you get a meaningful response from your code before Plex Media Server would usually have it reloaded.

Looks very cool. I'll have to take a look at this.

just added support for Windows x86/x64, at least I hope it’s smart enough to work on both. only tested on Windows 7 x64.

For whatever reason, on Windows, tests seem to run much faster when the server is left running.

Not sure if this of any interest to anyone, for kicks I tried spinning up to run the plex/nose “test suite” (if you could call it that) in a Cloud9 editor.

7gvgkpe.png

It took about 5 clicks and some manual extracting of the plexmediaserver.rpm, but it works dangit. And you can try channel development from any browser.

That’s pretty sweet. I sometimes use Cloud9 at work.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.