Beispiel #1
0
 def test_forbid_to_simple_user_with_foreign_group_multiview(self):
     """User doesn't access to a multiview owned by other group."""
     create_multiview(self.host, group=self.group)
     multiviews = Multiview.objects.user_filter(self.user2)
     self.assertEqual(
         multiviews.count(), 0,
         "User can access to a multiview owned by other group.")
Beispiel #2
0
 def test_delete_several(self):
     """Delete a several multiviews."""
     create_view() ; create_view()
     create_multiview() ; create_multiview()
     IDS  = ','.join([ str(m.id) for m in Multiview.objects.all() ])
     argv = ['', 'multiview', 'del', '-i', IDS]
     Command().run_from_argv(argv)
     # Test deletion
     new_count = Multiview.objects.count()
     self.assertEqual(new_count, 0, "All multiviews wasn't deleted.")
Beispiel #3
0
 def test_delete(self):
     """Delete a multiview."""
     create_view() ; create_view()
     self.multiview = create_multiview()
     argv = ['', 'multiview', 'del', '-i', str(self.multiview.id)]
     Command().run_from_argv(argv)
     # Test deletion
     new_count = Multiview.objects.count()
     self.assertEqual(new_count, 0, "Multiview wasn't deleted.")
Beispiel #4
0
 def test_quiet_delete(self):
     """Delete a several without print."""
     create_view() ; create_view()
     multiview = create_multiview()
     argv = ['', 'multiview', 'del', '-i', str(multiview.id), '-q']
     Command().run_from_argv(argv)
     # Test stdout
     out = self.stdout.getvalue()
     self.assertFalse(out, "Output is printed:\n"+out)
Beispiel #5
0
 def test_quiet_mod(self):
     """Modify a multiview without print."""
     create_view() ; create_view()
     multiview = create_multiview()
     argv = ['', 'multiview', 'mod', '-i', str(multiview.id), '-n', 'NEW NAME', '-q']
     Command().run_from_argv(argv)
     # Test stdout
     out = self.stdout.getvalue()
     self.assertFalse(out, "Output is printed:\n"+out)
Beispiel #6
0
 def test_list(self):
     """Get listing."""
     self.multiview = create_multiview()
     argv = ['', 'multiview', 'list']
     Command().run_from_argv(argv)
     # Test stdout
     out = self.stdout.getvalue()
     self.assertTrue(out, "No output.")
     self.assertIn("Count: 1", out, "Output isn't showing total count.")
Beispiel #7
0
 def test_mod(self):
     """Modify a multiview."""
     create_view() ; create_view()
     multiview = create_multiview()
     argv = ['', 'multiview', 'mod', '-i', str(multiview.id), '-n', 'NEW NAME']
     Command().run_from_argv(argv)
     # Test mod
     multiview = Multiview.objects.get(id=multiview.id)
     self.assertEqual(multiview.name, 'NEW NAME', "Multiview's name wasn't modified.")
Beispiel #8
0
 def test_rm_views(self):
     """Remove views from a multiview."""
     create_view() ; create_view()
     multiview = create_multiview()
     view_ids = ','.join([ str(v.id) for v in multiview.views.all()[:1] ])
     default_count = multiview.views.count()
     argv = ['', 'multiview', 'mod', '-i', str(multiview.id), '--rm-views', view_ids ]
     Command().run_from_argv(argv)
     # Test mod
     multiview = Multiview.objects.get(id=multiview.id)
     new_count = multiview.views.count()
     self.assertGreater(default_count, new_count, "Views wasn't removed.")
Beispiel #9
0
 def test_add_views(self):
     """Add view to a multiview."""
     create_view() ; create_view()
     multiview = create_multiview()
     multiview_view_ids = [ v.id for v in multiview.views.all() ]
     default_count = len(multiview_view_ids)
     # Set new views
     views = View.objects.exclude(id__in=multiview_view_ids)[:2]
     view_ids = ','.join([ str(s.id) for s in views ])
     argv = ['', 'multiview', 'mod', '-i', str(multiview.id), '--add-views', view_ids ]
     Command().run_from_argv(argv)
     # Test mod
     multiview = Multiview.objects.get(id=multiview.id)
     new_count = multiview.views.count()
     self.assertLess(default_count, new_count, "Views wasn't added.")
Beispiel #10
0
 def test_grant_to_simple_user_with_user_and_group_multiview(self):
     """User access to his group multiview."""
     create_multiview(self.host, self.user, self.group)
     multiviews = Multiview.objects.user_filter(self.user)
     self.assertEqual(multiviews.count(), 1,
                      "User can't access to his group and user multiview")
Beispiel #11
0
 def test_grant_to_simple_user_with_his_user_view(self):
     """User access to his own multiview."""
     create_multiview(self.host, self.user)
     multiviews = Multiview.objects.user_filter(self.user)
     self.assertEqual(multiviews.count(), 1,
                      "User can't access to his multiview")
Beispiel #12
0
 def test_grant_to_super_user(self):
     """Superuser access to every multiviews."""
     create_multiview(self.host)
     multiviews = Multiview.objects.user_filter(self.admin)
     self.assertEqual(multiviews.count(), 1,
                      "Superuser can't access to a multiview")
Beispiel #13
0
 def setUp(self):
     self.view = create_view()
     self.multiview = create_multiview()
Beispiel #14
0
 def test_update(self):
     """Get updating multiview."""
     self.multiview = create_multiview()
     url = reverse('multiviews customize multiview edit', args=[self.multiview.id])
     r = self.c.get(url)
     self.assertEqual(r.status_code, 200, "Bad response code (%i)." % r.status_code)
Beispiel #15
0
 def test_forbid_to_simple_user_with_foreign_group_multiview(self):
     """User doesn't access to a multiview owned by other group."""
     create_multiview(self.host, group=self.group)
     multiviews = Multiview.objects.user_filter(self.user2)
     self.assertEqual(multiviews.count(), 0, "User can access to a multiview owned by other group.")
Beispiel #16
0
 def test_grant_to_simple_user_with_his_user_view(self):
     """User access to his own multiview."""
     create_multiview(self.host, self.user)
     multiviews = Multiview.objects.user_filter(self.user)
     self.assertEqual(multiviews.count(), 1, "User can't access to his multiview")
Beispiel #17
0
 def test_forbid_to_simple_user_with_not_owned_multiview(self):
     """User doesn't access to a not owned multiview."""
     create_multiview(self.host)
     multiviews = Multiview.objects.user_filter(self.user)
     self.assertEqual(multiviews.count(), 0,
                      "User can access to a not owned multiview.")
Beispiel #18
0
 def test_grant_to_simple_user_with_user_and_group_multiview(self):
     """User access to his group multiview."""
     create_multiview(self.host, self.user, self.group)
     multiviews = Multiview.objects.user_filter(self.user)
     self.assertEqual(multiviews.count(), 1, "User can't access to his group and user multiview")
Beispiel #19
0
 def test_grant_to_super_user(self):
     """Superuser access to every multiviews."""
     create_multiview(self.host)
     multiviews = Multiview.objects.user_filter(self.admin)
     self.assertEqual(multiviews.count(), 1, "Superuser can't access to a multiview")
Beispiel #20
0
 def test_forbid_to_simple_user_with_not_owned_multiview(self):
     """User doesn't access to a not owned multiview."""
     create_multiview(self.host)
     multiviews = Multiview.objects.user_filter(self.user)
     self.assertEqual(multiviews.count(), 0, "User can access to a not owned multiview.")