Added the "serve-tests" option to the charm, defaulting to False. When the option is enabled it is possible to run the Juju GUI unit tests using https://[sevice url]/test/.
I needed to conditionally add the corresponding location to the nginx configuration file. I discussed with Gary about possible ways to achieve this. Using the standard Python string substitution seemed hacky, and the resulting template file could be less readable. We decided to start using a templating library: ended up with tempita because it is lightweight and it is already used in maas.
nginx is now configured so that the /test/ location: - serves unit tests if "serve-tests" is True; - redirects to / if "serve-tests" is False. The latter is required because otherwise the test location would be added to the browser appcache: the index.html file would be served and it references the manifest file.
Also fixed dependency management in the install hook. Now all the Python libraries required by the charm are installed at the beginning of the process, before utils, launchpadlib, tempita etc. are imported.
QA:
- deploy the charm; - juju set juju-gui serve-tests=true; - go to "https://[sevice url]/test/"; - you should see tests run (mocha html reporter).
Problems:
test-debug (staging=true) fails to run because it attempts to load external (insecure) resources. Filed bug #1116320.