mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
Fix failing non-root tests
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
590ba78f89
commit
6b9bbc8acc
@ -1,43 +0,0 @@
|
|||||||
#
|
|
||||||
# This file is part of Plinth.
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
"""
|
|
||||||
Test get apps for api module.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
from plinth.modules.api.views import get_app_payload
|
|
||||||
|
|
||||||
|
|
||||||
class TestApi(unittest.TestCase):
|
|
||||||
apps = [{
|
|
||||||
'name': 'someName',
|
|
||||||
'short_description': 'someDescription',
|
|
||||||
'icon': 'someIconURl',
|
|
||||||
'label': 'someLabel'
|
|
||||||
}]
|
|
||||||
|
|
||||||
expected = [{
|
|
||||||
'name': 'someName',
|
|
||||||
'short_description': 'someDescription',
|
|
||||||
'icon': 'static/theme/icons/someIconURl.svg'
|
|
||||||
}]
|
|
||||||
|
|
||||||
def test_get_app_payload(self):
|
|
||||||
apps = get_app_payload(self.apps)
|
|
||||||
self.assertEquals(apps, self.expected)
|
|
||||||
@ -15,16 +15,15 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import augeas
|
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from plinth.utils import format_lazy
|
import augeas
|
||||||
from plinth import actions, action_utils, frontpage, \
|
from plinth import service as service_module
|
||||||
service as service_module
|
from plinth import action_utils, actions, frontpage
|
||||||
from plinth.errors import DomainNotRegisteredError
|
from plinth.errors import DomainNotRegisteredError
|
||||||
from plinth.menu import main_menu
|
from plinth.menu import main_menu
|
||||||
from .manifest import clients
|
from plinth.utils import format_lazy
|
||||||
|
|
||||||
domain_name_file = "/etc/diaspora/domain_name"
|
domain_name_file = "/etc/diaspora/domain_name"
|
||||||
lazy_domain_name = None # To avoid repeatedly reading from file
|
lazy_domain_name = None # To avoid repeatedly reading from file
|
||||||
@ -70,25 +69,23 @@ description = [
|
|||||||
' federate with other diaspora* pods.')
|
' federate with other diaspora* pods.')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
from .manifest import clients # isort:skip
|
||||||
clients = clients
|
clients = clients
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
"""Initialize the Diaspora module."""
|
"""Initialize the Diaspora module."""
|
||||||
menu = main_menu.get('apps')
|
menu = main_menu.get('apps')
|
||||||
menu.add_urlname(name, 'glyphicon-thumbs-up', 'diaspora:index', short_description)
|
menu.add_urlname(name, 'glyphicon-thumbs-up', 'diaspora:index',
|
||||||
|
short_description)
|
||||||
|
|
||||||
global service
|
global service
|
||||||
setup_helper = globals()['setup_helper']
|
setup_helper = globals()['setup_helper']
|
||||||
if setup_helper.get_state() != 'needs-setup':
|
if setup_helper.get_state() != 'needs-setup':
|
||||||
service = service_module.Service(
|
service = service_module.Service(managed_services[0], name, ports=[
|
||||||
managed_services[0],
|
'http', 'https'
|
||||||
name,
|
], is_external=True, is_enabled=is_enabled, enable=enable,
|
||||||
ports=['http', 'https'],
|
disable=disable)
|
||||||
is_external=True,
|
|
||||||
is_enabled=is_enabled,
|
|
||||||
enable=enable,
|
|
||||||
disable=disable)
|
|
||||||
|
|
||||||
if is_enabled():
|
if is_enabled():
|
||||||
add_shortcut()
|
add_shortcut()
|
||||||
@ -103,18 +100,13 @@ def setup(helper, old_version=None):
|
|||||||
|
|
||||||
|
|
||||||
def setup_domain_name(domain_name):
|
def setup_domain_name(domain_name):
|
||||||
actions.superuser_run('diaspora',
|
actions.superuser_run('diaspora', ['setup', '--domain-name', domain_name])
|
||||||
['setup', '--domain-name', domain_name])
|
|
||||||
global service
|
global service
|
||||||
if service is None:
|
if service is None:
|
||||||
service = service_module.Service(
|
service = service_module.Service(managed_services[0], name, ports=[
|
||||||
managed_services[0],
|
'http', 'https'
|
||||||
name,
|
], is_external=True, is_enabled=is_enabled, enable=enable,
|
||||||
ports=['http', 'https'],
|
disable=disable)
|
||||||
is_external=True,
|
|
||||||
is_enabled=is_enabled,
|
|
||||||
enable=enable,
|
|
||||||
disable=disable)
|
|
||||||
service.notify_enabled(None, True)
|
service.notify_enabled(None, True)
|
||||||
add_shortcut()
|
add_shortcut()
|
||||||
|
|
||||||
@ -123,9 +115,7 @@ def add_shortcut():
|
|||||||
"""Add shortcut to diaspora on the Plinth homepage"""
|
"""Add shortcut to diaspora on the Plinth homepage"""
|
||||||
if is_setup():
|
if is_setup():
|
||||||
frontpage.add_shortcut(
|
frontpage.add_shortcut(
|
||||||
'diaspora',
|
'diaspora', name, short_description,
|
||||||
name,
|
|
||||||
short_description,
|
|
||||||
url='https://diaspora.{}'.format(get_configured_domain_name()),
|
url='https://diaspora.{}'.format(get_configured_domain_name()),
|
||||||
login_required=True)
|
login_required=True)
|
||||||
|
|
||||||
@ -170,16 +160,14 @@ def diagnose():
|
|||||||
results = []
|
results = []
|
||||||
|
|
||||||
results.append(
|
results.append(
|
||||||
action_utils.diagnose_url(
|
action_utils.diagnose_url('http://diaspora.localhost', kind='4',
|
||||||
'http://diaspora.localhost', kind='4', check_certificate=False))
|
check_certificate=False))
|
||||||
results.append(
|
results.append(
|
||||||
action_utils.diagnose_url(
|
action_utils.diagnose_url('http://diaspora.localhost', kind='6',
|
||||||
'http://diaspora.localhost', kind='6', check_certificate=False))
|
check_certificate=False))
|
||||||
results.append(
|
results.append(
|
||||||
action_utils.diagnose_url(
|
action_utils.diagnose_url('http://diaspora.{}'.format(
|
||||||
'http://diaspora.{}'.format(get_configured_domain_name()),
|
get_configured_domain_name()), kind='4', check_certificate=False))
|
||||||
kind='4',
|
|
||||||
check_certificate=False))
|
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@ -197,8 +185,7 @@ def generate_apache_configuration(conf_file, domain_name):
|
|||||||
aug.set('/augeas/load/Httpd/incl[last() + 1]', conf_file)
|
aug.set('/augeas/load/Httpd/incl[last() + 1]', conf_file)
|
||||||
aug.load()
|
aug.load()
|
||||||
|
|
||||||
aug.defvar('conf',
|
aug.defvar('conf', '/files' + conf_file)
|
||||||
'/files' + conf_file)
|
|
||||||
|
|
||||||
aug.set('$conf/VirtualHost', None)
|
aug.set('$conf/VirtualHost', None)
|
||||||
aug.defvar('vh', '$conf/VirtualHost')
|
aug.defvar('vh', '$conf/VirtualHost')
|
||||||
|
|||||||
@ -17,10 +17,11 @@
|
|||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from plinth.modules import diaspora
|
||||||
from plinth.templatetags.plinth_extras import Mobile_OS, Store
|
from plinth.templatetags.plinth_extras import Mobile_OS, Store
|
||||||
from plinth.utils import format_lazy
|
from plinth.utils import f_droid_url, format_lazy
|
||||||
|
|
||||||
from . import get_configured_domain_name
|
dandelion_package_id = 'com.github.dfa.diaspora_android'
|
||||||
|
|
||||||
clients = [{
|
clients = [{
|
||||||
'name':
|
'name':
|
||||||
@ -32,8 +33,7 @@ clients = [{
|
|||||||
'type': 'store',
|
'type': 'store',
|
||||||
'os': Mobile_OS.ANDROID.value,
|
'os': Mobile_OS.ANDROID.value,
|
||||||
'store_name': Store.F_DROID.value,
|
'store_name': Store.F_DROID.value,
|
||||||
'url': 'https://f-droid.org/repository/browse/?fdid=com'
|
'url': f_droid_url(dandelion_package_id),
|
||||||
'.github.dfa.diaspora_android ',
|
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
'name':
|
'name':
|
||||||
@ -43,6 +43,7 @@ clients = [{
|
|||||||
'web',
|
'web',
|
||||||
'url':
|
'url':
|
||||||
format_lazy('https://diaspora.{host}',
|
format_lazy('https://diaspora.{host}',
|
||||||
host=get_configured_domain_name())
|
host=diaspora.get_configured_domain_name() if
|
||||||
|
diaspora.is_setup() else "<please-setup-domain-name>")
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user