示例#1
0
 def test__normalize_dates(self):
     fake = FakeContext(self.good_storage)
     context = {
         'start': '2012/01/01',
         'end': '2014/01/01',
     }
     fake._normalize_dates(context)
     self.assertIn('live', context)
     self.assertIn('index', context)
     ok_(not context['live'])
     self.assertIsInstance(context['index'], pd.tseries.index.DatetimeIndex)
示例#2
0
 def test__normalize_dates(self):
     fake = FakeContext(self.good_storage)
     context = {
         'start': '2012/01/01',
         'end': '2014/01/01',
     }
     fake._normalize_dates(context)
     self.assertIn('live', context)
     self.assertIn('index', context)
     ok_(not context['live'])
     self.assertIsInstance(context['index'], pd.tseries.index.DatetimeIndex)
示例#3
0
 def test__normalize_boolean_data_types(self):
     boolean_data = {
         'unchanged_string': 'bazinga',
         'whatever_true': 'true',
         'whatever_false': 'false'
     }
     normalized_boolean_data = {
         'unchanged_string': 'bazinga',
         'whatever_true': True,
         'whatever_false': False
     }
     fake = FakeContext(self.good_storage)
     fake._normalize_data_types(boolean_data)
     self.assertDictEqual(boolean_data, normalized_boolean_data)
     self.assertIsInstance(normalized_boolean_data['whatever_true'], bool)
示例#4
0
 def test__normalize_boolean_data_types(self):
     boolean_data = {
         'unchanged_string': 'bazinga',
         'whatever_true': 'true',
         'whatever_false': 'false'
     }
     normalized_boolean_data = {
         'unchanged_string': 'bazinga',
         'whatever_true': True,
         'whatever_false': False
     }
     fake = FakeContext(self.good_storage)
     fake._normalize_data_types(boolean_data)
     self.assertDictEqual(boolean_data, normalized_boolean_data)
     self.assertIsInstance(
         normalized_boolean_data['whatever_true'], bool)
示例#5
0
 def test__normalize_numeric_data_types(self):
     float_data = {
         'unchanged_string': 'bazinga',
         'whatever_integer': '125',
         'whatever_float': '3.25',
         'whatever_negative_float': '-28.369'
     }
     normalized_float_data = {
         'unchanged_string': 'bazinga',
         'whatever_integer': 125,
         'whatever_float': 3.25,
         'whatever_negative_float': -28.369
     }
     fake = FakeContext(self.good_storage)
     fake._normalize_data_types(float_data)
     self.assertDictEqual(float_data, normalized_float_data)
     self.assertIsInstance(normalized_float_data['whatever_float'], float)
     self.assertIsInstance(normalized_float_data['whatever_integer'], int)
示例#6
0
 def test__normalize_numeric_data_types(self):
     float_data = {
         'unchanged_string': 'bazinga',
         'whatever_integer': '125',
         'whatever_float': '3.25',
         'whatever_negative_float': '-28.369'
     }
     normalized_float_data = {
         'unchanged_string': 'bazinga',
         'whatever_integer': 125,
         'whatever_float': 3.25,
         'whatever_negative_float': -28.369
     }
     fake = FakeContext(self.good_storage)
     fake._normalize_data_types(float_data)
     self.assertDictEqual(float_data, normalized_float_data)
     self.assertIsInstance(
         normalized_float_data['whatever_float'], float)
     self.assertIsInstance(
         normalized_float_data['whatever_integer'], int)
示例#7
0
 def test__normalize_empty_data_types(self):
     empty_data = {}
     fake = FakeContext(self.good_storage)
     fake._normalize_data_types(empty_data)
     self.assertDictEqual(empty_data, {})
示例#8
0
 def test__normalize_empty_data_types(self):
     empty_data = {}
     fake = FakeContext(self.good_storage)
     fake._normalize_data_types(empty_data)
     self.assertDictEqual(empty_data, {})
示例#9
0
 def test_initialize_fake_context(self):
     fake = FakeContext(self.good_storage)
     ok_(hasattr(fake, 'log'))
     self.assertListEqual(sorted(['uri', 'path', 'params']),
                          sorted(fake.storage.keys()))