Example #1
0
 def testGetAllMessages(self):
     status, result = views.getAllMessages()
     self.assertEqual(200, status)
     ms = json.loads(result)
     self.assertEqual(3, len(ms))
     self.assertEqual('u1=>u2', ms[0]['text'])
     self.assertEqual(self.u1.name, ms[0]['sender'])
     self.assertEqual(self.u2.name, ms[0]['recipient'])
Example #2
0
    def testGetAllMessagesLimit(self):
        n3, k3 = uuid.uuid4().hex, fakePublicKey()
        u3 = User.create(n3, k3)
        ms = [Message.create(u3, u3, uuid.uuid4().hex)
              for i in range(LIMITS['MESSAGES']+1)]
        status, result = views.getAllMessages()
        self.assertEqual(200, status)
        ms1 = json.loads(result)
        self.assertEqual(LIMITS['MESSAGES'], len(ms1))

        status, result = views.getMyMessages(n3)
        self.assertEqual(200, status)
        ms2 = json.loads(result)
        self.assertEqual(LIMITS['MESSAGES'], len(ms2))

        # Clean up
        for m in ms:
            m.delete()
        u3.delete()