Esempio n. 1
0
 def _test_set_datetime(self, fn, filter_name):
     # Type error exception test
     self.assertRaises(TypeError, fn, self.dummy_str)
     # Filter value test
     fn(self.dummy_datetime)
     self.assertEquals(self.api_request.get_filters()[filter_name],
                       utils.format_datetime(self.dummy_datetime))
Esempio n. 2
0
 def test_default_filters(self):
     '''Tests the default filters key/value.'''
     utcnow = datetime.datetime.utcnow()
     start = datetime.datetime(utcnow.year, utcnow.month, 1)
     default_key_value = {
         APIFilters.IS_COST: True,
         APIFilters.AGGREGATE: 'data',
         APIFilters.GROUP_BY: 'Product',
         APIFilters.CONSOLIDATE: 'monthly',
         APIFilters.START: utils.format_datetime(start),
         APIFilters.END: utils.format_datetime(utcnow),
         APIFilters.BREAKDOWN: True,
         APIFilters.SHOW_SPS: False,
         APIFilters.FACTOR_SPS: False,
     }
     assert APIFilters.default_filters() == default_key_value
Esempio n. 3
0
 def test_format_datetime(self):
     '''Tests that the datetime formatter utils function returns the right
     format.
     '''
     utcnow = datetime.datetime.utcnow()
     datetime_format = '%Y-%m-%d %I%p'
     self.assertEquals(utcnow.strftime(datetime_format),
                       utils.format_datetime(utcnow))