Пример #1
0
	def test_asia_earthquakes(self):
		storage = web.Storage()
		storage.continent = 'AS'
		storage.natural_hazard='earthquake'
		query = Query(storage)
		countries = query.execute()
		self.assertIsInstance(countries, list)
Пример #2
0
	def test_enclave(self):
		storage = web.Storage()
		storage.enclave = 1
		query = Query(storage)
		countries = query.execute()
		self.assertIsInstance(countries, list)
		self.assertEqual(len(countries), 3)
Пример #3
0
	def test_africa_political_parties_greater_than_10(self):
		storage = web.Storage()
		storage.continent = 'AF'
		storage.political_party_count_gt_n = 10
		query = Query(storage)
		countries = query.execute()
		self.assertIsInstance(countries, list)
Пример #4
0
	def test_na_flag_contains_color_orange(self):
		storage = web.Storage()
		storage.continent = 'NA'
		storage.flag_contains_color = 'orange'
		query = Query(storage)
		countries = query.execute()
		self.assertIsInstance(countries, list)
		self.assertEqual(len(countries), 2)
Пример #5
0
async def download(
    # query = { 
    #     'query': {
    #         'range': {
    #             'timestamp': {
    #                 'format': 'strict_date_optional_time',
    #                 'gte': 'now-3M',
    #                 'lte': 'now'
    #             }
    #         }
    #     }
    # }
    query: Query = Query(
    query = {
        'range': {
            'timestamp': {
                'format': 'strict_date_optional_time',
                'gte': 'now-3M',
                'lte': 'now'
            }
        }
    })    
):
    es = Elasticsearch_API()
    response = {}

    # pprint(query)

    # try:
    # first get the es response
    response = await es.post(query)
    # pprint(response)
    await es.close()

    

    # print(response)
    # except:
    #     print("Elasticsearch post failed")

    # try:
    #     # parse the response
    #     response = transform.to_ocpapp(response)
    #     print(response)
    # except:
    #     print("Error parsing Elasticsearch response")
    # print(response)

    # pprint(response['hits']['hits'])
    # pprint(transform.extract_to_long_df(response['hits']['hits']))

    response = transform.to_ocpapp(response)
    # pprint(response)
    return response
Пример #6
0
	def test_capital_coordinates(self):
		storage = web.Storage()
		storage.capital_coordinates = 10
		query = Query(storage)
		result = query.execute()
		self.assertIsInstance(result, list)