Ejemplo n.º 1
0
    def test_parse_created_at(self):
        import pytz
        from datetime import datetime
        from carson.utils import parse_created_at

        self.assertEqual(
            parse_created_at("Wed May 23 06:01:13 +0000 2007"),
            datetime(2007, 5, 23, 6, 1, 13, tzinfo=pytz.utc))

        self.assertRaises(AssertionError,
                          parse_created_at, "Wed May 23 06:01:13 -7000 2007")
Ejemplo n.º 2
0
    def add(cls, tweet, twitter_ids):
        values = {
            "data": tweet,
            "timestamp": parse_created_at(tweet['created_at']),
            "status_id": tweet['id'],
        }

        twitter_id = tweet['user']['id']

        if twitter_id in twitter_ids:
            account = Account.objects.get(twitter_id=twitter_id)
        else:
            account = None

        values['account'] = account

        return cls.objects.create(**values)
Ejemplo n.º 3
0
    def add(cls, tweet, twitter_ids):
        values = {
            "data": tweet,
            "timestamp": parse_created_at(tweet['created_at']),
            "status_id": tweet['id'],
        }

        twitter_id = tweet['user']['id']

        if twitter_id in twitter_ids:
            account = Account.objects.get(twitter_id=twitter_id)
        else:
            account = None

        values['account'] = account

        return cls.objects.create(**values)