Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 47 lines (41 sloc) 1.646 kb
317c65bb »
2012-02-07 adding 1st test to ircarchive
1 from datetime import datetime
2 from unittest import TestCase
3
4 from google.appengine.api import memcache
5 from google.appengine.ext import db
6 from google.appengine.ext import testbed
7
8 from models import Message
9
10 class MessageModelTestCase(TestCase):
11
12 def setUp(self):
13 self.testbed = testbed.Testbed()
14 self.testbed.activate()
15 self.testbed.init_datastore_v3_stub()
16 self.sample_msg = """{
17 "transport_name": "irc",
18 "in_reply_to": null,
19 "from_addr": "user1",
20 "timestamp": "2012-01-03 11:29:57.0",
21 "to_addr": "#channel",
22 "content": "user2: Woot. I'll restart vumibot.",
23 "message_version": "20110921",
24 "transport_type": "irc",
25 "transport_metadata": {},
26 "helper_metadata": {
27 "irc": {
28 "transport_nickname": "vumibot",
29 "irc_addressed_to_transport": false,
30 "irc_full_sender": "user1!~client@somedomain.net",
31 "irc_command": "PRIVMSG",
32 "irc_full_recipient": "#channel",
33 "irc_channel": "#channel",
34 "irc_server": "irc.freenode.net:6667"
35 }
36 },
37 "session_event": null,
38 "message_id": "19d41fbd03224eef85eb29c6c97ee28b",
39 "message_type": "user_message"
40 }"""
41
42 def tearDown(self):
43 self.testbed.deactivate()
44
45 def test_parse_timestamp(self):
46 msg = Message.log_common_message_format(self.sample_msg)
47 self.assertEqual(msg.timestamp, datetime(2012,1,3,11,29,57))
Something went wrong with that request. Please try again.