Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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, {})
Exemple #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, {})
Exemple #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()))