Skip to content
Snippets Groups Projects
Commit 6573c18b authored by Jan Mach's avatar Jan Mach
Browse files

Implemented unit tests for 'hawat.blueprints.dnsr' module.

Also removed unnecessary docstrings.

(Redmine issue: #4410,#1017,#3443)
parent 1bc38f7d
No related branches found
No related tags found
No related merge requests found
......@@ -9,9 +9,6 @@
"""
Description
-----------
This pluggable module provides access to DNS service. It is implemented upon custom
:py:mod:`mentat.services.dnsr` module.
......@@ -87,12 +84,10 @@ class AbstractSearchView(RenderableView): # pylint: disable=locally-disabled,ab
@classmethod
def get_view_title(cls, **kwargs):
"""*Implementation* of :py:func:`vial.view.BaseView.get_view_title`."""
return lazy_gettext('Search DNS')
@classmethod
def get_menu_title(cls, **kwargs):
"""*Implementation* of :py:func:`vial.view.BaseView.get_menu_title`."""
return lazy_gettext('Search DNS')
#---------------------------------------------------------------------------
......@@ -137,7 +132,6 @@ class SearchView(HTMLMixin, AbstractSearchView): # pylint: disable=locally-disa
@classmethod
def get_view_name(cls):
"""*Implementation* of :py:func:`vial.view.BaseView.get_view_name`."""
return 'search'
......@@ -150,7 +144,6 @@ class APISearchView(AJAXMixin, AbstractSearchView): # pylint: disable=locally-d
@classmethod
def get_view_name(cls):
"""*Implementation* of :py:func:`vial.view.BaseView.get_view_name`."""
return 'apisearch'
......@@ -160,7 +153,9 @@ class SnippetSearchView(SnippetMixin, AbstractSearchView): # pylint: disable=lo
form of JSON document containing ready to use HTML page snippets.
"""
methods = ['GET', 'POST']
renders = ['label', 'full']
snippets = [
{
'name': 'hostnames',
......@@ -170,7 +165,6 @@ class SnippetSearchView(SnippetMixin, AbstractSearchView): # pylint: disable=lo
@classmethod
def get_view_name(cls):
"""*Implementation* of :py:func:`vial.view.BaseView.get_view_name`."""
return 'sptsearch'
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#-------------------------------------------------------------------------------
# This file is part of Mentat system (https://mentat.cesnet.cz/).
#
# Copyright (C) since 2011 CESNET, z.s.p.o (http://www.ces.net/)
# Use of this source is governed by the MIT license, see LICENSE file.
#-------------------------------------------------------------------------------
"""
Unit tests for :py:mod:`hawat.blueprints.dnsr`.
"""
import unittest
import vial.const
import vial.test
import vial.db
from hawat.test import BaseAppTestCase
class ConfigTestCase(BaseAppTestCase):
"""
Class for testing ``dnsr.config`` endpoint.
This endpoint is for developers only.
"""
def _attempt_fail(self):
self.assertGetURL(
'/dnsr/search',
403
)
def _attempt_succeed(self):
self.assertGetURL(
'/dnsr/search',
200,
[
b'Search DNS'
]
)
def test_01_as_anonymous(self):
"""Test access as anonymous user."""
self._attempt_fail()
@vial.test.do_as_user_decorator(vial.const.ROLE_USER)
def test_02_as_user(self):
"""Test access as user ``user``."""
self._attempt_succeed()
@vial.test.do_as_user_decorator(vial.const.ROLE_DEVELOPER)
def test_03_as_developer(self):
"""Test access as user ``developer``."""
self._attempt_succeed()
@vial.test.do_as_user_decorator(vial.const.ROLE_MAINTAINER)
def test_04_as_maintainer(self):
"""Test access as user ``maintainer``."""
self._attempt_succeed()
@vial.test.do_as_user_decorator(vial.const.ROLE_ADMIN)
def test_05_as_admin(self):
"""Test access as user ``admin``."""
self._attempt_succeed()
#-------------------------------------------------------------------------------
if __name__ == "__main__":
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment