def test_data(self): """ Test the returned results for a fully populated dictionary """ rate_limit = { "URI": "*", "regex": ".*", "value": 10, "verb": "POST", "remaining": 2, "unit": "MINUTE", "resetTime": 1311272226 } view = views.LimitView(rate_limit) self.assertIsNotNone(view) data = view.data() expected = { 'limit': { 'regex': '.*', 'nextAvailable': '2011-07-21T18:17:06Z', 'uri': '*', 'value': 10, 'verb': 'POST', 'remaining': 2, 'unit': 'MINUTE' } } self.assertEqual(expected, data)
def test_empty_data(self): """ Test the default returned results if an empty dictionary is given """ rate_limit = {} view = views.LimitView(rate_limit) self.assertIsNotNone(view) data = view.data() expected = {'limit': {'regex': '', 'nextAvailable': '1970-01-01T00:00:00Z', 'uri': '', 'value': '', 'verb': '', 'remaining': 0, 'unit': ''}} self.assertEqual(expected, data)