summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
authorZara Gebru <zgebru@thoughtworks.com>2016-12-02 15:25:23 +0100
committerZara Gebru <zgebru@thoughtworks.com>2016-12-02 15:25:23 +0100
commitb14833fbb56bcd5bff0750c16fd9214009b955be (patch)
treea1ec621dd5f76d756ac59b72a763a34a2c189387 /service/test
parent688a8b42e8ab7c6d4529b6dda66f40eead07ad02 (diff)
[refactor] move app dir into public dir
Diffstat (limited to 'service/test')
-rw-r--r--service/test/integration/test_static_files.py27
-rw-r--r--service/test/support/integration/app_test_client.py5
-rw-r--r--service/test/support/integration/multi_user_client.py4
-rw-r--r--service/test/unit/resources/test_auth.py6
-rw-r--r--service/test/unit/resources/test_root_resource.py6
5 files changed, 39 insertions, 9 deletions
diff --git a/service/test/integration/test_static_files.py b/service/test/integration/test_static_files.py
new file mode 100644
index 00000000..e3fa8af5
--- /dev/null
+++ b/service/test/integration/test_static_files.py
@@ -0,0 +1,27 @@
+#
+# Copyright (c) 2016 ThoughtWorks, Inc.
+#
+# Pixelated 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.
+#
+# Pixelated 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 Pixelated. If not, see <http://www.gnu.org/licenses/>.
+
+
+from twisted.internet.defer import inlineCallbacks
+from test.support.integration import SoledadTestBase
+
+
+class StaticFilesTest(SoledadTestBase):
+
+ @inlineCallbacks
+ def test_should_find_static_file(self):
+ _, request = yield self.app_test_client.get('/static/js/main.js', as_json=False, ajax=False)
+ self.assertEqual(200, request.responseCode)
diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py
index 4e3758c5..c611fbd0 100644
--- a/service/test/support/integration/app_test_client.py
+++ b/service/test/support/integration/app_test_client.py
@@ -38,7 +38,7 @@ from leap.soledad.client import Soledad
from leap.bitmask.mail.adaptors.soledad import SoledadMailAdaptor
from pixelated.adapter.mailstore.leap_attachment_store import LeapAttachmentStore
from pixelated.adapter.services.feedback_service import FeedbackService
-from pixelated.application import UserAgentMode, set_up_protected_resources
+from pixelated.application import UserAgentMode, set_up_protected_resources, get_static_folder, get_templates_folder
from pixelated.config.sessions import LeapSession
from pixelated.config.services import Services, ServicesFactory, SingleUserServicesFactory
from pixelated.config.site import PixelatedSite
@@ -218,10 +218,11 @@ class AppTestClient(object):
services = self._test_account.services
self.service_factory.add_session('someuserid', services)
- self.resource = RootResource(self.service_factory)
+ self.resource = RootResource(self.service_factory, get_templates_folder(), get_static_folder())
provider = mock()
self.resource.initialize(provider)
else:
+ # TODO: write test for me (=
self.service_factory = StubServicesFactory(self.accounts, mode)
provider = mock()
bonafide_checker = StubAuthenticator(provider)
diff --git a/service/test/support/integration/multi_user_client.py b/service/test/support/integration/multi_user_client.py
index 4b9b2864..d7ab77a0 100644
--- a/service/test/support/integration/multi_user_client.py
+++ b/service/test/support/integration/multi_user_client.py
@@ -19,7 +19,7 @@ from mockito import mock, when, any as ANY
from pixelated.authentication import Authenticator, Authentication
from twisted.internet import defer
-from pixelated.application import UserAgentMode, set_up_protected_resources
+from pixelated.application import UserAgentMode, set_up_protected_resources, get_static_folder, get_templates_folder
from pixelated.config.services import ServicesFactory
from pixelated.config.sessions import LeapSessionFactory
@@ -46,7 +46,7 @@ class MultiUserClient(AppTestClient):
self.service_factory = ServicesFactory(UserAgentMode(is_single_user=False))
- root_resource = RootResource(self.service_factory)
+ root_resource = RootResource(self.service_factory, get_templates_folder(), get_static_folder())
leap_provider = mock()
self.credentials_checker = StubSRPChecker(leap_provider)
self.resource = set_up_protected_resources(root_resource, leap_provider, self.service_factory)
diff --git a/service/test/unit/resources/test_auth.py b/service/test/unit/resources/test_auth.py
index f4012b1b..7112ed96 100644
--- a/service/test/unit/resources/test_auth.py
+++ b/service/test/unit/resources/test_auth.py
@@ -1,4 +1,6 @@
from mockito import mock, when, any as ANY
+
+from pixelated.application import get_templates_folder, get_static_folder
from pixelated.resources.auth import SessionChecker, PixelatedRealm, PixelatedAuthSessionWrapper
from pixelated.resources.login_resource import LoginResource
from pixelated.resources.root_resource import RootResource
@@ -40,8 +42,8 @@ class TestPixelatedAuthSessionWrapper(unittest.TestCase):
session_checker = SessionChecker(services_factory)
self.portal = Portal(self.realm_mock, [session_checker, AllowAnonymousAccess()])
self.user_uuid_mock = mock()
- self.root_resource = RootResource(services_factory)
- self.anonymous_resource = RootResource(services_factory, public=True)
+ self.root_resource = RootResource(services_factory, get_templates_folder(), get_static_folder())
+ self.anonymous_resource = RootResource(services_factory, get_templates_folder(), get_static_folder(), public=True)
self.session_wrapper = PixelatedAuthSessionWrapper(self.portal, self.root_resource, self.anonymous_resource)
self.request = DummyRequest([])
diff --git a/service/test/unit/resources/test_root_resource.py b/service/test/unit/resources/test_root_resource.py
index 9d738a83..e72efe59 100644
--- a/service/test/unit/resources/test_root_resource.py
+++ b/service/test/unit/resources/test_root_resource.py
@@ -5,7 +5,7 @@ from mock import MagicMock, patch
from mockito import mock, when, any as ANY
import pixelated
-from pixelated.application import UserAgentMode
+from pixelated.application import UserAgentMode, get_templates_folder, get_static_folder
from pixelated.resources import IPixelatedSession, UnAuthorizedResource
from pixelated.resources.features_resource import FeaturesResource
from pixelated.resources.login_resource import LoginResource
@@ -22,7 +22,7 @@ from pixelated.resources.root_resource import InboxResource, RootResource, MODE_
class TestPublicRootResource(unittest.TestCase):
def setUp(self):
- self.public_root_resource = RootResource(mock(), public=True)
+ self.public_root_resource = RootResource(mock(), get_templates_folder(), get_static_folder(), public=True)
self.web = DummySite(self.public_root_resource)
@patch('pixelated.resources.mails_resource.events.register')
@@ -105,7 +105,7 @@ class TestRootResource(unittest.TestCase):
when(self.services_factory).services(ANY()).thenReturn(self.services)
self.mail_service.account_email = self.MAIL_ADDRESS
- self.root_resource = RootResource(self.services_factory)
+ self.root_resource = RootResource(self.services_factory, get_templates_folder(), get_static_folder())
self.web = DummySite(self.root_resource)
@patch('pixelated.resources.mails_resource.events.register')