Exemple #1
0
 def test_quiet_add(self):
     """Add a multiview without print."""
     create_view() ; create_view()
     view_ids = ','.join([ str(v.id) for v in View.objects.all()[:2] ])
     argv = ['', 'multiview', 'add', '-n', 'TEST MULTIVIEW', '-V', view_ids, '-q']
     Command().run_from_argv(argv)
     # Test stdout
     out = self.stdout.getvalue()
     self.assertFalse(out, "Output is printed:\n" + out)
Exemple #2
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.")
Exemple #3
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)
Exemple #4
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.")
Exemple #5
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)
Exemple #6
0
 def test_delete_several(self):
     """Delete a several views."""
     create_view() ; create_view()
     IDS  = ','.join([ str(s.id) for s in View.objects.all() ])
     argv = ['', 'view', 'del', '-i', IDS]
     Command().run_from_argv(argv)
     # Test deletion
     new_count = View.objects.count()
     self.assertEqual(new_count, 0, "All views wasn't deleted.")
Exemple #7
0
 def test_add(self):
     """Add a multiview."""
     create_view() ; create_view()
     view_ids = ','.join([ str(v.id) for v in View.objects.all()[:2] ])
     argv = ['', 'multiview', 'add', '-n', 'TEST MULTIVIEW', '-V', view_ids]
     Command().run_from_argv(argv)
     # Test creation
     new_count = Multiview.objects.count()
     out = self.stdout.getvalue()
     self.assertGreater(new_count, 0, "Multiview wasn't created.")
Exemple #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.")
Exemple #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.")
Exemple #10
0
 def test_get(self):
     """Get a source."""
     self.view = create_view()
     url = reverse('multiviews customize view edit', args=[self.view.id])
     r = self.c.get(url)
     self.assertEqual(r.status_code, 200,
                      "Bad response code (%i)." % r.status_code)
Exemple #11
0
 def test_quiet_mod(self):
     """Modify a view without print."""
     view = create_view()
     argv = ['', 'view', 'mod', '-i', str(view.id), '-n', 'NEW NAME', '-q']
     Command().run_from_argv(argv)
     # Test stdout
     out = self.stdout.getvalue()
     self.assertFalse(out, "Output is printed:\n"+out)
Exemple #12
0
 def test_quiet_delete(self):
     """Delete a several without print."""
     view = create_view()
     argv = ['', 'view', 'del', '-i', str(view.id), '-q']
     Command().run_from_argv(argv)
     # Test stdout
     out = self.stdout.getvalue()
     self.assertFalse(out, "Output is printed:\n"+out)
Exemple #13
0
 def test_delete(self):
     """Delete a view."""
     self.view = create_view()
     argv = ['', 'view', 'del', '-i', str(self.view.id)]
     Command().run_from_argv(argv)
     # Test deletion
     new_count = View.objects.count()
     self.assertEqual(new_count, 0, "View wasn't deleted.")
Exemple #14
0
 def test_mod(self):
     """Modify a view."""
     view = create_view()
     argv = ['', 'view', 'mod', '-i', str(view.id), '-n', 'NEW NAME']
     Command().run_from_argv(argv)
     # Test mod
     view = View.objects.get(id=view.id)
     self.assertEqual(view.name, 'NEW NAME', "View's name wasn't modified.")
Exemple #15
0
 def test_list(self):
     """Get listing."""
     self.view = create_view()
     argv = ['', 'view', '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.")
Exemple #16
0
 def test_rm_sources(self):
     """Remove sources from a view."""
     view = create_view()
     source_ids = ','.join([ str(v.id) for v in view.sources.all()[:1] ])
     default_count = view.sources.count()
     argv = ['', 'view', 'mod', '-i', str(view.id), '--rm-sources', source_ids ]
     Command().run_from_argv(argv)
     # Test mod
     view = View.objects.get(id=view.id)
     new_count = view.sources.count()
     self.assertGreater(default_count, new_count, "Sources wasn't removed.")
Exemple #17
0
 def test_add_sources(self):
     """Add sources to a view."""
     view = create_view()
     view_source_ids = [ v.id for v in view.sources.all() ]
     default_count = len(view_source_ids)
     # Set new sources
     sources = Source.objects.exclude(id__in=view_source_ids)[:2]
     source_ids = ','.join([ str(s.id) for s in sources ])
     argv = ['', 'view', 'mod', '-i', str(view.id), '--add-sources', source_ids ]
     Command().run_from_argv(argv)
     # Test mod
     view = View.objects.get(id=view.id)
     new_count = view.sources.count()
     self.assertLess(default_count, new_count, "Sources wasn't added.")
Exemple #18
0
 def setUp(self):
     self.view = create_view()
Exemple #19
0
 def test_forbid_to_simple_user_with_foreign_group_view(self):
     """User doesn't access to a view owned by other group."""
     self.view = create_view(self.host, group=self.group)
     views = View.objects.user_filter(self.user2)
     self.assertEqual(views.count(), 0,
                      "User can access to a view owned by other group.")
Exemple #20
0
 def test_forbid_to_simple_user_with_not_owned_view(self):
     """User doesn't access to a not owned view."""
     self.view = create_view(self.host)
     views = View.objects.user_filter(self.user)
     self.assertEqual(views.count(), 0,
                      "User can access to a not owned view.")
Exemple #21
0
 def setUp(self):
     self.view = create_view()
Exemple #22
0
 def test_forbid_to_simple_user_with_not_owned_view(self):
     """User doesn't access to a not owned view."""
     self.view = create_view(self.host)
     views = View.objects.user_filter(self.user)
     self.assertEqual(views.count(), 0, "User can access to a not owned view.")
Exemple #23
0
 def test_grant_to_simple_user_with_his_user_view(self):
     """User access to his own view."""
     self.view = create_view(self.host, self.user)
     views = View.objects.user_filter(self.user)
     self.assertEqual(views.count(), 1, "User can't access to his view")
Exemple #24
0
 def test_get(self):
     """Get a source."""
     self.view = create_view()
     url = reverse('multiviews customize view edit', args=[self.view.id])
     r = self.c.get(url)
     self.assertEqual(r.status_code, 200, "Bad response code (%i)." % r.status_code)
Exemple #25
0
 def setUp(self):
     self.host = Host.objects.all()[0]
     self.plugin = Plugin.objects.all()[0]
     self.source = Data_Source.objects.all()[0]
     self.view = create_view()
Exemple #26
0
 def test_grant_to_super_user(self):
     """Superuser access to every views."""
     self.view = create_view(self.host)
     views = View.objects.user_filter(self.admin)
     self.assertEqual(views.count(), 1, "Superuser can't access to a view")
Exemple #27
0
 def setUp(self):
     self.view = create_view()
     self.multiview = create_multiview()
Exemple #28
0
 def test_grant_to_simple_user_with_user_and_group_view(self):
     """User access to his group view."""
     self.view = create_view(self.host, self.user, self.group)
     views = View.objects.user_filter(self.user)
     self.assertEqual(views.count(), 1, "User can't access to his group and user view")
Exemple #29
0
 def test_grant_to_super_user(self):
     """Superuser access to every views."""
     self.view = create_view(self.host)
     views = View.objects.user_filter(self.admin)
     self.assertEqual(views.count(), 1, "Superuser can't access to a view")
Exemple #30
0
 def test_forbid_to_simple_user_with_foreign_group_view(self):
     """User doesn't access to a view owned by other group."""
     self.view = create_view(self.host, group=self.group)
     views = View.objects.user_filter(self.user2)
     self.assertEqual(views.count(), 0, "User can access to a view owned by other group.")
Exemple #31
0
 def test_grant_to_simple_user_with_his_user_view(self):
     """User access to his own view."""
     self.view = create_view(self.host, self.user)
     views = View.objects.user_filter(self.user)
     self.assertEqual(views.count(), 1, "User can't access to his view")
Exemple #32
0
 def setUp(self):
     self.host = Host.objects.all()[0]
     self.plugin = Plugin.objects.all()[0]
     self.source = Data_Source.objects.all()[0]
     self.view = create_view()
Exemple #33
0
 def test_grant_to_simple_user_with_user_and_group_view(self):
     """User access to his group view."""
     self.view = create_view(self.host, self.user, self.group)
     views = View.objects.user_filter(self.user)
     self.assertEqual(views.count(), 1,
                      "User can't access to his group and user view")