Example #1
0
    def test_transform_treasuries_data(self):
        '''
        Test the transformation of the raw data received from the fed
        treasury website into the form we use downstream
        '''
        test_data = os.path.join(self.data_folder,
                'test_transform_treasuries_data.data.py')
        data = utils.deserialise_obj(test_data)
        result = data_loader.transform_treasuries_data(data)

        test_result = os.path.join(self.data_folder, 
                'test_transform_treasuries_data.result.py')
        base_result = utils.deserialise_obj(test_result)

        self.assertEqual(result, base_result)
Example #2
0
    def test_transform_google_timeseries(self):
        """
        Test the transformation of the raw data received from google
        into the form we use downstream
        """
        test_data = os.path.join(self.data_folder,
                                 'test_transform_google_timeseries.data.py')
        data = utils.deserialise_obj(test_data)
        result = data_loader.transform_google_timeseries(data)

        test_result = os.path.join(self.data_folder,
                                   'test_transform_google_timeseries.result.py')
        base_result = utils.deserialise_obj(test_result)

        self.assertEqual(result, base_result)
Example #3
0
def get_from_cache(id):
    '''
    Check whether the series with the input id is present in the cache
    '''
    if id is None:
        return False

    cache_file = get_cache_filename(id)
    if os.path.exists(cache_file):
        return utils.deserialise_obj(cache_file)

    return False 
Example #4
0
 def test_serialise_deserialise_obj(self):
     '''
     This tests the round trip: serialise an object then deserialise
     it and check we get back what we started with
     It's intended as a test for the two functions: 
         utils.serialise_obj
         utils.deserialise_obj
     '''
     data = {
             'a': [5.97, 2.97, 8.2502, 4],
             'b': 'hello',
             'c': True
             }
     fd, tmpfile = tempfile.mkstemp(suffix='.py')
     try:
         utils.serialise_obj(data, tmpfile)
         result = utils.deserialise_obj(tmpfile)
     finally:
         os.remove(tmpfile)
     self.assertEqual(data, result)