from django.test import TestCase

# Create your tests here.

@@ -31,30 +31,934 @@
 se%0A%0A
-# Create your tests here.
+from models import *%0A%0Aclass SubscriptionTests(TestCase):%0A%0A    @classmethod%0A    def setUpTestData(cls):%0A        sub = MQTTSubscription(server='localhost', topic='#')%0A        sub.save()%0A        cls.sub = sub%0A%0A    def test_callback_function(self):%0A        sub = type(self).sub%0A%0A        # Create a message to save%0A        class ToyMessage():%0A            def __init__(self, topic, payload):%0A                self.topic = topic%0A                self.payload = payload%0A%0A        test_topic = 'test'%0A        test_payload = '123abc'%0A        test_msg = ToyMessage(test_topic, test_payload)%0A%0A        # Save the message using the callback function%0A        sub._record_message_callback(client=None, userdata=None, message=test_msg)%0A%0A        # Get the newest message in the database and check for equality%0A        msg = MQTTMessage.objects.last()%0A        self.assertEqual(msg.topic, test_topic)%0A        self.assertEqual(msg.payload, test_payload)
 %0A

Add test of callback function.