Parent: [ddf08c] (diff)

Child: [9ef3a2] (diff)

Download this file

test_app.py    92 lines (68 with data), 3.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import re
from unittest import TestCase
from allura.app import Application
from allura import model
from allura.tests.unit import WithDatabase
from allura.tests.unit.patches import fake_app_patch
from allura.tests.unit.factories import create_project, create_app_config
class TestApplication(TestCase):
def test_validate_mount_point(self):
app = Application
mount_point = '1.2+foo_bar'
self.assertIsNone(app.validate_mount_point(mount_point))
app.relaxed_mount_points = True
self.assertIsNotNone(app.validate_mount_point(mount_point))
class TestInstall(WithDatabase):
patches = [fake_app_patch]
def test_that_it_creates_a_discussion(self):
original_discussion_count = self.discussion_count()
install_app()
assert self.discussion_count() == original_discussion_count + 1
def discussion_count(self):
return model.Discussion.query.find().count()
class TestDefaultDiscussion(WithDatabase):
patches = [fake_app_patch]
def setUp(self):
super(TestDefaultDiscussion, self).setUp()
install_app()
self.discussion = model.Discussion.query.get(
shortname='my_mounted_app')
def test_that_it_has_a_description(self):
description = self.discussion.description
assert description == 'Forum for my_mounted_app comments'
def test_that_it_has_a_name(self):
assert self.discussion.name == 'my_mounted_app Discussion'
def test_that_its_shortname_is_taken_from_the_project(self):
assert self.discussion.shortname == 'my_mounted_app'
class TestAppDefaults(WithDatabase):
patches = [fake_app_patch]
def setUp(self):
super(TestAppDefaults, self).setUp()
self.app = install_app()
def test_that_it_has_an_empty_sidebar_menu(self):
assert self.app.sidebar_menu() == []
def test_that_it_denies_access_for_everything(self):
assert not self.app.has_access(model.User.anonymous(), 'any.topic')
def install_app():
project = create_project('myproject')
app_config = create_app_config(project, 'my_mounted_app')
# XXX: Remove project argument to install; it's redundant
app = Application(project, app_config)
app.install(project)
return app