Skip to content

Commit

Permalink
Add some tests for plugins, episodes, middleware and gloss
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmiller committed Feb 26, 2016
1 parent 14251e4 commit c41b122
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 4 deletions.
4 changes: 2 additions & 2 deletions opal/core/glossolalia/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def list(self, *args, **kwargs):
serialised = queryset.values(*GlossolaliaSubscription.SERIALISED_FIELDS)
return Response(serialised)

def update(self, request, pk=None):
pass
def update(self, request, pk=None): pass


router.register('glossolalia', GlossolaliaViewSet)
8 changes: 8 additions & 0 deletions opal/core/glossolalia/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,11 @@ def test_change_calls_send_upstream(self, sender):
# test unsubscribe

# test get list-api

class SendUpstreamMessageTestCase(TestCase):

@patch('opal.core.glossolalia.triggers.requests.post')
def test_post(self, post):
triggers._send_upstream_message('myevent', {})
payload = dict(servicetype="OPAL", event="myevent", name=triggers.NAME)
post.assert_called_with(triggers.ENDPOINT, data=payload)
3 changes: 1 addition & 2 deletions opal/core/glossolalia/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def unsubscribe(episode):
subscribe_to_type(episode, GlossolaliaSubscription.CORE_DEMOGRAPHICS)


def demographics_query(hospital_number):
pass
def demographics_query(hospital_number): pass


def admit(episode):
Expand Down
10 changes: 10 additions & 0 deletions opal/tests/test_core_episodes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
Unittests for opal.core.episodes
"""
from opal.core import test

from opal.core import episodes

class EpisodeTypesTestCas(test.OpalTestCase):
def test_episode_types(self):
self.assertIn(episodes.InpatientEpisode, episodes.episode_types())
13 changes: 13 additions & 0 deletions opal/tests/test_core_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
Unittests for opal.core.plugins
"""
from opal.core.test import OpalTestCase

from opal.core import plugins

class OpalPluginTestCase(OpalTestCase):
def test_list_schemas(self):
self.assertEqual({}, plugins.OpalPlugin().list_schemas())

def test_flows(self):
self.assertEqual({}, plugins.OpalPlugin().flows())
15 changes: 15 additions & 0 deletions opal/tests/test_middleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
Unittests for opal.middleware
"""
from opal.core.test import OpalTestCase

from opal import middleware

class AngularCSRFRenameTestCase(OpalTestCase):
def test_process_request(self):
mw = middleware.AngularCSRFRename()
request = self.rf.get('/hai')
request.META['HTTP_X_XSRF_TOKEN'] = 'foo'
mw.process_request(request)
self.assertEqual(request.META['HTTP_X_CSRFTOKEN'], 'foo')
self.assertEqual(request.META.get('HTTP_X_XSRF_TOKEN', None), None)

0 comments on commit c41b122

Please sign in to comment.