Skip to content
Snippets Groups Projects
Commit af59445f authored by Mark Skipper's avatar Mark Skipper
Browse files

Refactor tests

parent 939ccb6c
No related branches found
No related tags found
No related merge requests found
......@@ -7,11 +7,6 @@ class Message(object):
def create(cls, message):
models.Message(**message).save()
@classmethod
def list(cls):
# TODO: probably use a DRF serializer here instead of .values()?
return models.Message.objects.values().iterator()
# TODO rename this class?
Item = Message
......@@ -9,6 +9,7 @@ from data_layer import models
class HandlerTests(TestCase):
# Remove these tests and move to API
def test_message_create(self):
now = timezone.now().replace(
microsecond=0 # MySQL discards microseconds
......@@ -20,14 +21,3 @@ class HandlerTests(TestCase):
outmessage = models.Message.objects.get()
self.assertEqual(outmessage.body, "Text")
self.assertEqual(outmessage.timestamp, now)
def test_message_list_empty(self):
messages = handlers.Message.list()
self.assertEqual(len(list(messages)), 0)
def test_message_list_one(self):
models.Message(body="Test").save()
[message] = handlers.Message.list()
self.assertEqual(message['body'], "Test")
import pytest
@pytest.mark.xfail
def test_create_message_creates_item():
# now = timezone.now().replace(
# microsecond=0 # MySQL discards microseconds
# )
# item = {'body': "Text", 'timestamp': now}
# dl.create_message(item)
# create.assert_called_with(message)
assert False
......@@ -7,21 +7,14 @@ from transport import data_layer_transport as dl
@pytest.mark.django_db
def test_get_messages_exists():
messages = dl.get_messages()
assert messages == []
def test_get_items_exists():
items = dl.get_messages()
assert items == []
@pytest.mark.django_db
def test_get_messages_returns_items():
def test_get_items_returns_items():
item = ItemFactory(body="test")
messages = dl.get_messages()
[message] = messages
assert message['body'] == 'test'
@pytest.mark.xfail
def test_store_message_uses_create():
#message = {}
#:l.create_message(message)
#create.assert_called_with(message)
assert False
items = dl.get_messages()
[item] = items
assert item['body'] == 'test'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment