def tearDown(self): for g in glob.glob('test-*'): os.remove(g) try: Scenario.drop_collection() except: pass
def setUp(self): try: Scenario.drop_collection() except: pass self.client = app.test_client() # send requests to server that will edit test/data/parameter.nc raw_data = ''' { "name": "test-scenario-1", "veg_map_by_hru": { "bare_ground": [0, 1, 2, 3, 5, 10, 11], "grasses": [4, 6, 7, 17, 18, 19], "shrubs": [9, 12, 13], "trees": [8, 14, 15, 16], "conifers": [] } } ''' raw_data2 = ''' { "name": "test-scenario-2", "veg_map_by_hru": { "bare_ground": [0, 10, 11], "grasses": [2, 3, 5, 7, 17, 18, 19], "shrubs": [9, 12, 13], "trees": [8, 14, 15, 16], "conifers": [4, 6, 1] } } ''' self.res1 = self.client.post('/api/scenarios', data=raw_data, headers={ 'Content-Type': 'application/json', 'Origin': '*'} ) self.res2 = self.client.post('/api/scenarios', data=raw_data2, headers={ 'Content-Type': 'application/json', 'Origin': '*'} ) self.r1_scenario = json.loads(json.loads(self.res1.data)['scenario']) self.r2_scenario = json.loads(json.loads(self.res2.data)['scenario']) self.id1 = self.r1_scenario['id'] self.id2 = self.r2_scenario['id']
def tearDown(self): try: Scenario.drop_collection() except: pass