def test_insert_many_tsrv(self): item, geometries = self.setup_model(geomcount=1, valuecount=50000) timesteps, geomcount = item.getValues2().shape dates = item.getDates()[:, 1] sprint.sPrint('\n') sprint.sPrint('Inserting a simulation containing %d timesteps and %d ' 'geometries' % (timesteps, geomcount), sprint.MessageType.INFO) sprint.sPrint('\n') self.assertTrue(len(item.getDates2()) == len(item.getValues2())) self.assertTrue(len(item.getGeometries2()) == len(item.getValues2()[0])) description = 'Some description' name = 'test simulation with many result values' # build user object if not os.path.exists(os.environ['APP_USER_PATH']): self.assertTrue(1 == 0, 'No User.json found!') user_obj = user.json_to_dict(os.environ['APP_USER_PATH']) u = user_obj[user_obj.keys()[0]] # grab the first user self.emptysqlite.create_simulation(coupledSimulationName=name, user_obj=u, action_date=dt.now(), action_utc_offset=-7, ei=item, simulation_start=dates[0], simulation_end=dates[-1], timestep_value=1, timestep_unit='minutes', description=description, name=name) s = self.emptysqlite.read.getSimulations() self.assertTrue(len(s) == 1) actionid = s[0].ActionID factions = self.emptysqlite.cursor.execute('SELECT * FROM ' 'FeatureActions WHERE ' 'ActionID = %d' % actionid)\ .fetchall() sampling_feature_ids = [f[1] for f in factions] feature_action_ids = [f[0] for f in factions] results = self.emptysqlite.read.getResults(actionid=actionid) for i in range(len(results)): res = results[i] resgeom = res.FeatureActionObj.SamplingFeatureObj\ .FeatureGeometryWKT resvalues = self.emptysqlite.read.getResultValues(res.ResultID) self.assertTrue(resgeom == geometries[i].ExportToWkt()) self.assertTrue(len(resvalues) == timesteps)
def refresh_user_account(self): self.account_combo.Clear() # Get users path = os.environ['APP_USER_PATH'] self.user_data = users.json_to_dict(path) account_names = [] for affiliation in self.user_data.itervalues(): account_names.append(affiliation.ID()) self.account_combo.AppendItems(account_names) self.account_combo.SetSelection(0)