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
1=== modified file 'dashboard_app/tests/other/dashboard_api.py'
2--- dashboard_app/tests/other/dashboard_api.py 2011-03-16 21:17:05 +0000
3+++ dashboard_app/tests/other/dashboard_api.py 2011-05-19 16:58:10 +0000
4@@ -25,7 +25,7 @@
5 from django.core.urlresolvers import reverse
6 from django_testscenarios import TransactionTestCase
7
8-from dashboard_app.models import Bundle
9+from dashboard_app.models import Bundle, BundleStream
10 from dashboard_app.tests import fixtures
11 from dashboard_app.tests.utils import DashboardXMLRPCViewsTestCase
12 from dashboard_app.xmlrpc import errors
13@@ -412,3 +412,78 @@
14 self.assertEqual(ex.faultCode, errors.CONFLICT)
15 else:
16 self.fail("Should have raised an exception")
17+
18+
19+class DashboardAPIMakeStreamTests(DashboardXMLRPCViewsTestCase):
20+
21+ scenarios = [
22+ ('toplevel_anonymous/', {
23+ 'pathname': '/anonymous/',
24+ 'name': '',
25+ }),
26+ ('anonymous_with_slug', {
27+ 'pathname': '/anonymous/some-name/',
28+ 'name': '',
29+ }),
30+ ('anonymous_with_slug_and_name', {
31+ 'pathname': '/anonymous/some-name/',
32+ 'name': 'nonempty',
33+ }),
34+ ]
35+
36+ def setUp(self):
37+ super(DashboardAPIMakeStreamTests, self).setUp()
38+ self.response = self.xml_rpc_call("make_stream", self.pathname, self.name)
39+
40+ def test_response_is_pathname(self):
41+ self.assertEqual(self.response, self.pathname)
42+
43+ def test_pathname_is_created(self):
44+ self.assertEqual(BundleStream.objects.filter(pathname=self.pathname).count(), 1)
45+
46+ def test_pathname_has_name(self):
47+ bundle_stream = BundleStream.objects.get(pathname=self.pathname)
48+ self.assertEqual(self.name, bundle_stream.name)
49+
50+
51+class DashboardAPIMakeStreamFailureTests(DashboardXMLRPCViewsTestCase):
52+
53+ _NAME = ""
54+
55+ scenarios = [
56+ ('public_personal', {
57+ 'pathname': '/public/personal/NAME/',
58+ }),
59+ ('private_personal', {
60+ 'pathname': '/private/personal/NAME/',
61+ }),
62+ ('public_team', {
63+ 'pathname': '/public/team/NAME/',
64+ }),
65+ ('private_team', {
66+ 'pathname': '/private/team/NAME/',
67+ }),
68+ ('public_personal_with_slug', {
69+ 'pathname': '/public/personal/NAME/SLUG/',
70+ }),
71+ ('private_personal_with_slug', {
72+ 'pathname': '/private/personal/NAME/SLUG/',
73+ }),
74+ ('public_team_with_slug', {
75+ 'pathname': '/public/team/NAME/SLUG/',
76+ }),
77+ ('private_team_with_slug', {
78+ 'pathname': '/private/team/NAME/SLUG/',
79+ }),
80+ ('bogus', {
81+ 'pathname': '/bogus/pathname/'
82+ }),
83+ ]
84+
85+ def test_nonanonymous_streams(self):
86+ try:
87+ self.xml_rpc_call("make_stream", self.pathname, self._NAME)
88+ except xmlrpclib.Fault as ex:
89+ self.assertEqual(ex.faultCode, errors.FORBIDDEN)
90+ else:
91+ self.fail("Should have raised an exception")

Subscribers

People subscribed via source and target branches