Example #1
0
    def test_activity_json (self):
        """Test Period producing JSON"""

        correct_json = """
[
    {
        "id": 12,
        "name": "Fulano LarguiƱo",
        "period": {
            "end": "2012-11-01T00:00:00",
            "start": "2011-12-01T00:00:00"
        }
    },
    {
        "id": 3,
        "name": "Mengana Corta",
        "period": {
            "end": "2013-02-03T00:00:00",
            "start": "2010-02-03T00:00:00"
        }
    }
]
"""

        rowlabels = ["person_id", "name", "firstdate", "lastdate"]
        list = ActivityList((KeyedTuple([12, "Fulano LarguiƱo",
                                         datetime(2011,12,1),
                                         datetime(2012,11,1)],
                                        labels = rowlabels),
                             KeyedTuple([3, "Mengana Corta",
                                         datetime(2010,2,3),
                                         datetime(2013,2,3)],
                                        labels = rowlabels)))
        activity_json = encode(list, unpicklable=False)
        self.assertTrue( equalJSON( activity_json, correct_json ))
Example #2
0
    def test_period_json (self):
        """Test Period producing JSON"""

        correct_json = """
{
    "end": "2012-11-01T00:00:00",
    "start": "2011-12-01T00:00:00"
}
"""
        period = Period(datetime(2011,12,1), datetime(2012,11,1))
        period_json = encode(period, unpicklable=False)
        self.assertTrue( equalJSON(period_json, correct_json))