mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-29 12:09:37 +00:00
help: Update test for contribute view
- Verify that issue data is sent in context properly. - Ensure that an external request is not made during testing. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
e5a866dd64
commit
9647b00278
@ -9,6 +9,7 @@ Pending: - status log
|
||||
|
||||
"""
|
||||
|
||||
import json
|
||||
import pathlib
|
||||
import subprocess
|
||||
from unittest.mock import patch
|
||||
@ -42,7 +43,6 @@ def fixture_app_urls():
|
||||
|
||||
|
||||
@pytest.mark.parametrize("view_name, view", (
|
||||
('contribute', views.contribute),
|
||||
('feedback', views.feedback),
|
||||
('support', views.support),
|
||||
('index', views.index),
|
||||
@ -53,6 +53,40 @@ def test_simple_help_pages(rf, view_name, view):
|
||||
assert _is_page(response)
|
||||
|
||||
|
||||
@patch('apt.Cache')
|
||||
@patch('gzip.decompress')
|
||||
@patch('requests.get')
|
||||
def test_contribute_page(requests_get, decompress, apt_cache, rf):
|
||||
"""Test the contribute page."""
|
||||
issues = [{
|
||||
'type': 'testing-autorm',
|
||||
'packages': ['autormpkg'],
|
||||
'source': 'autormsrc',
|
||||
'bugs': ['123']
|
||||
}, {
|
||||
'type': 'no-testing',
|
||||
'package': ['notestingpkg'],
|
||||
'source': 'nottestingsrc',
|
||||
}, {
|
||||
'type': 'gift',
|
||||
'package': ['giftpkg'],
|
||||
'bug': '456',
|
||||
'title': 'bug 456 title',
|
||||
}, {
|
||||
'type': 'help',
|
||||
'package': ['helppkg'],
|
||||
'bug': '567',
|
||||
'title': 'bug 567 title',
|
||||
}]
|
||||
decompress.return_value = json.dumps(issues)
|
||||
response = views.contribute(rf.get(urls.reverse('help:contribute')))
|
||||
assert _is_page(response)
|
||||
assert issues == (response.context_data['testing_autorm'] +
|
||||
response.context_data['no_testing'] +
|
||||
response.context_data['gift'] +
|
||||
response.context_data['help'])
|
||||
|
||||
|
||||
def test_about(rf):
|
||||
"""Test some expected items in about view."""
|
||||
manual_url = urls.reverse('help:manual')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user