Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
synw committed Jun 17, 2018
1 parent 6388b5e commit f39d56e
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 3 deletions.
10 changes: 8 additions & 2 deletions mqueue/tests/__init__.py
Expand Up @@ -4,12 +4,18 @@
from .apps import MqueueTestApps
from .utils import MqueueTestUtils
from .hooks.redis import MqueueTestRedisHook
from .watchers import MqueueTestWatchers
#from .graphql_api import MqueueTestGraphqlApi


class MqueueTest(MqueueTestAdmin,
MqueueTestCreate,
MqueueTestManagers,
MqueueTestApps,
MqueueTestUtils,
MqueueTestRedisHook):
pass
MqueueTestWatchers,
# MqueueTestGraphqlApi
):

def test_mqueue_logging(self):
from mqueue.logging import DEV_LOGGING, LOGGING_WARNING
26 changes: 26 additions & 0 deletions mqueue/tests/graphql_api.py
@@ -0,0 +1,26 @@
from django.test import TestCase
from .base import MqueueBaseTest
from graphene.test import Client
from mqueue.schema import schema
from mqueue.models import MEvent


client = Client(schema)


class MqueueTestGraphqlApi(MqueueBaseTest):

def test_graphql_query(self):
self.reset()
MEvent.objects.create(name="Test public event", scope="public")
query = '''query publicEvents(first:10) {
edges {
node {
name
event_class
}
}
}
'''
res = [{"name": "Test public event"}]
self.assertEqual(client.execute(query), res)
7 changes: 7 additions & 0 deletions mqueue/tests/runtests.py
Expand Up @@ -16,6 +16,9 @@
CUSTOM_INSTALLED_APPS = (
'mqueue',
'django.contrib.admin',
"graphene_django",
"graphql_utils",
"django_filters",
)

ALWAYS_INSTALLED_APPS = (
Expand Down Expand Up @@ -75,6 +78,10 @@
},
},

GRAPHENE={
'SCHEMA': 'mqueue.schema.schema'
},

)

django.setup()
Expand Down
28 changes: 28 additions & 0 deletions mqueue/tests/watchers.py
@@ -0,0 +1,28 @@
from django.test import TestCase
from .base import MqueueBaseTest
from mqueue.models import MEvent
from mqueue.watchers import send_msg, login_action, logout_action, login_failed, init_watchers
from mqueue.conf import WATCH


class MqueueTestWatchers(MqueueBaseTest):

def test_send_msg(self):
instance = self.user
send_msg("test", instance, "Event string")

def test_login_action(self):
instance = self.user
login_action("test", instance)

def test_logout_action(self):
instance = self.user
logout_action("test", instance)

def test_login_failed(self):
instance = self.user
login_failed("test", "user")

def test_init_watchers_login(self):
with self.settings(MQUEUE_WATCH=["login", "logout", "login_failed"]):
init_watchers("login")
3 changes: 2 additions & 1 deletion setup.py
Expand Up @@ -25,7 +25,8 @@
'django<2',
'redis',
'influxdb',
'graphene',
'django-graphql-utils',
"graphene-django<2.0",
],
zip_safe=False
)
5 changes: 5 additions & 0 deletions tox.ini
@@ -1,6 +1,11 @@
[base]
deps =
django-extensions
redis
django-graphql-utils
graphene-django<2.0
graphene<2.0
django-filter

[testenv:django11]
deps =
Expand Down

0 comments on commit f39d56e

Please sign in to comment.