예제 #1
0
def _apod_handler(dt,
                  use_concept_tags=False,
                  use_default_today_date=False,
                  thumbs=False):
    """
    Accepts a parameter dictionary. Returns the response object to be
    served through the API.
    """
    try:

        page_props = parse_apod(dt, use_default_today_date, thumbs)
        if not page_props:
            return None
        LOG.debug('managed to get apod page characteristics')

        if use_concept_tags:
            if ALCHEMY_API_KEY is None:
                page_props[
                    'concepts'] = 'concept_tags functionality turned off in current service'
            else:
                page_props['concepts'] = get_concepts(
                    request, page_props['explanation'], ALCHEMY_API_KEY)

        return page_props

    except Exception as e:

        LOG.error('Internal Service Error :' + str(type(e)) + ' msg:' + str(e))
        # return code 500 here
        return _abort(500, 'Internal Service Error', usage=False)
예제 #2
0
    def _test_harness(self, test_title, data):
        
        print ("Testing "+test_title)
               
        # make the call
        values = utility.parse_apod(data['datetime'])

        # Test returned properties
        for prop in values.keys(): 
            if prop == "copyright":
                print(str(values['copyright']))
            self.assertEqual(values[prop], data[prop], "Test of property: "+prop)