Forked mumble-django project from https://bitbucket.org/Svedrin/mumble-django
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.3 KiB

  1. # -*- coding: utf-8 -*-
  2. """
  3. * Copyright © 2009-2010, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
  4. *
  5. * Mumble-Django is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This package is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. """
  15. import os
  16. from django.test.simple import run_tests as django_run_tests
  17. from django.conf import settings
  18. from murmurenvutils import get_available_versions, run_callback, wait_for_user
  19. def run_tests( test_labels, verbosity=1, interactive=True, extra_tests=[] ):
  20. """ Run the Django built in testing framework, but before testing the mumble
  21. app, allow Murmur to be set up correctly.
  22. """
  23. if not test_labels:
  24. test_labels = [ appname.split('.')[-1] for appname in settings.INSTALLED_APPS ];
  25. # No need to sync any murmur servers for the other apps
  26. os.environ['MURMUR_CONNSTR'] = '';
  27. # The easy way: mumble is not being tested.
  28. if "mumble" not in test_labels:
  29. return django_run_tests( test_labels, verbosity, interactive, extra_tests );
  30. # First run everything apart from mumble. mumble will be tested separately, so Murmur
  31. # can be set up properly first.
  32. failed_tests = 0;
  33. if len(test_labels) > 1:
  34. # only run others if mumble is not the only app to be tested
  35. test_labels = list(test_labels);
  36. test_labels.remove( "mumble" );
  37. failed_tests += django_run_tests( test_labels, verbosity, interactive, extra_tests );
  38. failed_tests += run_mumble_tests( verbosity, interactive );
  39. return failed_tests;
  40. def run_mumble_tests( verbosity=1, interactive=True ):
  41. connstrings = {
  42. 'DBus': 'net.sourceforge.mumble.murmur',
  43. 'Ice': 'Meta:tcp -h 127.0.0.1 -p 6502',
  44. };
  45. def django_run_tests_wrapper( process, version ):
  46. wr_failed_tests = 0;
  47. for method in connstrings:
  48. # Check if this server is ready to be used with the current method
  49. if getattr( process.capabilities, ("has_%s" % method.lower()), False ):
  50. print "Testing mumble %s via %s" % ( version, method );
  51. os.environ['MURMUR_CONNSTR'] = connstrings[method];
  52. settings.DEFAULT_CONN = connstrings[method];
  53. settings.SLICE_VERSION = [ int(dgt) for dgt in version.split('.') ];
  54. print "MURMUR_CONNSTR:", os.environ['MURMUR_CONNSTR'];
  55. print "DEFAULT_CONN: ", settings.DEFAULT_CONN;
  56. print "SLICE_VERSION: ", settings.SLICE_VERSION;
  57. if not process.capabilities.has_users:
  58. print "Waiting for user to connect (60 seconds)."
  59. wait_for_user( process, timeout=60 );
  60. wr_failed_tests += django_run_tests( ('mumble',), verbosity, interactive, [] );
  61. else:
  62. print "Mumble %s does not support Method %s" % ( version, method );
  63. return wr_failed_tests;
  64. failed_tests = 0;
  65. from mctl import MumbleCtlBase
  66. for version in get_available_versions():
  67. MumbleCtlBase.clearCache();
  68. run = raw_input( "Run tests for %s? [Y/n] " % version );
  69. if run in ('Y', 'y', ''):
  70. failed_tests += run_callback( version, django_run_tests_wrapper, version );
  71. return failed_tests;