def setUp(self): # create dependecies of timeseries. self.stype = StationType.objects.create(descr='stype') self.stype.save() self.organization = Organization.objects.create(name='org') self.organization.save() self.var = Variable.objects.create(descr='var') self.var.save() self.unit = UnitOfMeasurement.objects.create(symbol='+') self.unit.variables.add(self.var) self.unit.save() self.tz = TimeZone.objects.create(code='UTC', utc_offset='0') self.tz.save() self.station = Station.objects.create( name='station', owner=self.organization, approximate=False, is_active=True, is_automatic=True, point=fromstr('POINT(24.67890 38.12345)'), srid=4326, altitude=219.22) self.station.save() self.ts = Timeseries(name="tstest", gentity=self.station, time_zone=self.tz, unit_of_measurement=self.unit, variable=self.var) self.ts.save() self.user = User.objects.create_user('test', '*****@*****.**', 'test') self.user.save()
def setUp(self): # Create the editors group permitted = ["eventtype", "filetype", "garea", "gentityaltcode", "gentityaltcodetype", "gentityevent", "gentityfile", "gline", "instrument", "instrumenttype", "overseer", "politicaldivision", "station", "stationtype", "timeseries", "timestep", "timezone", "unitofmeasurement", "userprofile", "variable", "waterbasin", "waterdivision", "person", "organization", "gentitygenericdatatype"] editors = Group(name='editors') editors.save() for x in ('add', 'change', 'delete'): for y in permitted: editors.permissions.add( Permission.objects.get(codename=x + '_' + y, content_type__app_label='hcore')) # create user and add him to editors group. this'll be the # creator/owner to check permissions self.user = User.objects.create_user('opentest', '*****@*****.**', 'opentest') # another user who won't have permissions over the tested objects to # verify that permission handling works as expected. self.user2 = User.objects.create_user('fail', '*****@*****.**', 'fail') self.editors = Group.objects.get(name='editors') self.editors.user_set.add(self.user) self.editors.user_set.add(self.user2) # create a station, instrument and timeseries to check permissions self.stype = StationType.objects.create(descr='stype') self.itype = InstrumentType.objects.create(descr='itype') self.organization = Organization.objects.create(name='org') self.var = Variable.objects.create(descr='var') self.unit = UnitOfMeasurement.objects.create(symbol='+') self.unit.variables.add(self.var) self.tz = TimeZone.objects.create(code='UTC', utc_offset='0') self.station = Station.objects.create(name='station', owner=self.organization, approximate=False, is_active=True, is_automatic=True) self.ts = Timeseries(name="tstest", gentity=self.station, time_zone=self.tz, unit_of_measurement=self.unit, variable=self.var) self.ts.save()
def setUp(self): # create dependecies of timeseries. self.stype = StationType.objects.create(descr='stype') self.stype.save() self.organization = Organization.objects.create(name='org') self.organization.save() self.var = Variable.objects.create(descr='var') self.var.save() self.unit = UnitOfMeasurement.objects.create(symbol='+') self.unit.variables.add(self.var) self.unit.save() self.tz = TimeZone.objects.create(code='UTC', utc_offset='0') self.tz.save() self.station = Station.objects.create(name='station', owner=self.organization) self.station.save() self.ts = Timeseries(name="tstest", gentity=self.station, time_zone=self.tz, unit_of_measurement=self.unit, variable=self.var) self.ts.save() self.user = User.objects.create_user('test', '*****@*****.**', 'test') self.user.save()