Merge lp:~linaro-validation/lava-dashboard/tests-for-xmlrpc into lp:lava-dashboard

Proposed by Zygmunt Krynicki
Status: Merged
Merged at revision: 194
Proposed branch: lp:~linaro-validation/lava-dashboard/tests-for-xmlrpc
Merge into: lp:lava-dashboard
Diff against target: 91 lines (+76/-1)
1 file modified
dashboard_app/tests/other/dashboard_api.py (+76/-1)
To merge this branch: bzr merge lp:~linaro-validation/lava-dashboard/tests-for-xmlrpc
Reviewer Review Type Date Requested Status
Linaro Validation Team Pending
Review via email: mp+61616@code.launchpad.net

Description of the change

A few tests (of many to come) to new xml-rpc methods.

This tests some aspects of make_stream()

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'dashboard_app/tests/other/dashboard_api.py'
--- dashboard_app/tests/other/dashboard_api.py 2011-03-16 21:17:05 +0000
+++ dashboard_app/tests/other/dashboard_api.py 2011-05-19 16:58:10 +0000
@@ -25,7 +25,7 @@
25from django.core.urlresolvers import reverse25from django.core.urlresolvers import reverse
26from django_testscenarios import TransactionTestCase26from django_testscenarios import TransactionTestCase
2727
28from dashboard_app.models import Bundle28from dashboard_app.models import Bundle, BundleStream
29from dashboard_app.tests import fixtures29from dashboard_app.tests import fixtures
30from dashboard_app.tests.utils import DashboardXMLRPCViewsTestCase30from dashboard_app.tests.utils import DashboardXMLRPCViewsTestCase
31from dashboard_app.xmlrpc import errors31from dashboard_app.xmlrpc import errors
@@ -412,3 +412,78 @@
412 self.assertEqual(ex.faultCode, errors.CONFLICT)412 self.assertEqual(ex.faultCode, errors.CONFLICT)
413 else:413 else:
414 self.fail("Should have raised an exception")414 self.fail("Should have raised an exception")
415
416
417class DashboardAPIMakeStreamTests(DashboardXMLRPCViewsTestCase):
418
419 scenarios = [
420 ('toplevel_anonymous/', {
421 'pathname': '/anonymous/',
422 'name': '',
423 }),
424 ('anonymous_with_slug', {
425 'pathname': '/anonymous/some-name/',
426 'name': '',
427 }),
428 ('anonymous_with_slug_and_name', {
429 'pathname': '/anonymous/some-name/',
430 'name': 'nonempty',
431 }),
432 ]
433
434 def setUp(self):
435 super(DashboardAPIMakeStreamTests, self).setUp()
436 self.response = self.xml_rpc_call("make_stream", self.pathname, self.name)
437
438 def test_response_is_pathname(self):
439 self.assertEqual(self.response, self.pathname)
440
441 def test_pathname_is_created(self):
442 self.assertEqual(BundleStream.objects.filter(pathname=self.pathname).count(), 1)
443
444 def test_pathname_has_name(self):
445 bundle_stream = BundleStream.objects.get(pathname=self.pathname)
446 self.assertEqual(self.name, bundle_stream.name)
447
448
449class DashboardAPIMakeStreamFailureTests(DashboardXMLRPCViewsTestCase):
450
451 _NAME = ""
452
453 scenarios = [
454 ('public_personal', {
455 'pathname': '/public/personal/NAME/',
456 }),
457 ('private_personal', {
458 'pathname': '/private/personal/NAME/',
459 }),
460 ('public_team', {
461 'pathname': '/public/team/NAME/',
462 }),
463 ('private_team', {
464 'pathname': '/private/team/NAME/',
465 }),
466 ('public_personal_with_slug', {
467 'pathname': '/public/personal/NAME/SLUG/',
468 }),
469 ('private_personal_with_slug', {
470 'pathname': '/private/personal/NAME/SLUG/',
471 }),
472 ('public_team_with_slug', {
473 'pathname': '/public/team/NAME/SLUG/',
474 }),
475 ('private_team_with_slug', {
476 'pathname': '/private/team/NAME/SLUG/',
477 }),
478 ('bogus', {
479 'pathname': '/bogus/pathname/'
480 }),
481 ]
482
483 def test_nonanonymous_streams(self):
484 try:
485 self.xml_rpc_call("make_stream", self.pathname, self._NAME)
486 except xmlrpclib.Fault as ex:
487 self.assertEqual(ex.faultCode, errors.FORBIDDEN)
488 else:
489 self.fail("Should have raised an exception")

Subscribers

People subscribed via source and target branches