##// END OF EJS Templates
oss-licenses: Fix tests for open source licenses view.
Martin Bornhold -
r220:bdf36d1f default
parent child Browse files
Show More
@@ -460,7 +460,11 b' class TestLabsSettings(object):'
460
460
461 @pytest.mark.usefixtures('app')
461 @pytest.mark.usefixtures('app')
462 class TestOpenSourceLicenses(object):
462 class TestOpenSourceLicenses(object):
463 def test_records_are_displayed(self, autologin_user):
463
464 def _get_url(self, request):
465 return ADMIN_PREFIX + '/settings/open_source'
466
467 def test_records_are_displayed(self, autologin_user, request_stub):
464 sample_licenses = {
468 sample_licenses = {
465 "python2.7-pytest-2.7.1": {
469 "python2.7-pytest-2.7.1": {
466 "UNKNOWN": None
470 "UNKNOWN": None
@@ -470,11 +474,10 b' class TestOpenSourceLicenses(object):'
470 }
474 }
471 }
475 }
472 read_licenses_patch = mock.patch(
476 read_licenses_patch = mock.patch(
473 'rhodecode.controllers.admin.settings.read_opensource_licenses',
477 'rhodecode.admin.views.read_opensource_licenses',
474 return_value=sample_licenses)
478 return_value=sample_licenses)
475 with read_licenses_patch:
479 with read_licenses_patch:
476 response = self.app.get(
480 response = self.app.get(self._get_url(request_stub), status=200)
477 url('admin_settings_open_source'), status=200)
478
481
479 assert_response = AssertResponse(response)
482 assert_response = AssertResponse(response)
480 assert_response.element_contains(
483 assert_response.element_contains(
@@ -484,15 +487,15 b' class TestOpenSourceLicenses(object):'
484 for license in sample_licenses[name]:
487 for license in sample_licenses[name]:
485 assert_response.element_contains('.panel-body', license)
488 assert_response.element_contains('.panel-body', license)
486
489
487 def test_records_can_be_read(self, autologin_user):
490 def test_records_can_be_read(self, autologin_user, request_stub):
488 response = self.app.get(url('admin_settings_open_source'), status=200)
491 response = self.app.get(self._get_url(request_stub), status=200)
489 assert_response = AssertResponse(response)
492 assert_response = AssertResponse(response)
490 assert_response.element_contains(
493 assert_response.element_contains(
491 '.panel-heading', 'Licenses of Third Party Packages')
494 '.panel-heading', 'Licenses of Third Party Packages')
492
495
493 def test_forbidden_when_normal_user(self, autologin_regular_user):
496 def test_forbidden_when_normal_user(self, autologin_regular_user,
494 self.app.get(
497 request_stub):
495 url('admin_settings_open_source'), status=403)
498 self.app.get(self._get_url(request_stub), status=403)
496
499
497
500
498 @pytest.mark.usefixtures("app")
501 @pytest.mark.usefixtures("app")
General Comments 0
You need to be logged in to leave comments. Login now