def setUp(self): self.VRM = VRM_Account.objects.create(vrm_user_id='*****@*****.**', vrm_password="******") # Setup Influx self._influx_db_name = 'test_db' self.i = Influx(database=self._influx_db_name) try: self.i.create_database(self._influx_db_name) #Generate random data points for 24h except: self.i.delete_database(self._influx_db_name) sleep(1) self.i.create_database(self._influx_db_name) pass self.location = Geoposition(52.5, 24.3) dt = timezone.make_aware(timezone.datetime(2015, 12, 11, 22, 0)) self.site = Sesh_Site.objects.create(site_name=u"Test_aggregate", comission_date=dt, location_city=u"kigali", location_country=u"rwanda", vrm_account=self.VRM, installed_kw=123.0, position=self.location, system_voltage=12, number_of_panels=12, vrm_site_id=213, battery_bank_capacity=12321, has_genset=True, has_grid=True) self.no_points = create_test_data(self.site, start=self.site.comission_date, end=dt + timedelta(hours=48), interval=30) #create test user self.test_user = Sesh_User.objects.create_user(username="******", email="*****@*****.**", password="******") #assign a user to the sites assign_perm("view_Sesh_Site", self.test_user, self.site)
def setUp(self): self.VRM = VRM_Account.objects.create(vrm_user_id='*****@*****.**',vrm_password="******") # Setup Influx self._influx_db_name = 'test_db' self.i = Influx(database=self._influx_db_name) try: self.i.create_database(self._influx_db_name) #Generate random data points for 24h except: self.i.delete_database(self._influx_db_name) sleep(1) self.i.create_database(self._influx_db_name) pass self.location = Geoposition(52.5,24.3) dt = timezone.make_aware(timezone.datetime(2015, 12, 11, 22, 0)) self.site = Sesh_Site.objects.create(site_name=u"Test_aggregate", comission_date = dt, location_city = u"kigali", location_country=u"rwanda", vrm_account = self.VRM, installed_kw=123.0, position=self.location, system_voltage=12, number_of_panels=12, vrm_site_id=213, battery_bank_capacity=12321, has_genset=True, has_grid=True) self.no_points = create_test_data(self.site, start = self.site.comission_date, end = dt + timedelta( hours = 48), interval = 30, random = False) #create test user self.test_user = Sesh_User.objects.create_user(username="******",email="*****@*****.**",password="******") #assign a user to the sites assign_perm("view_Sesh_Site",self.test_user,self.site)
def setUp(self): self.VRM = VRM_Account.objects.create(vrm_user_id='*****@*****.**',vrm_password="******") # Setup Influx self.i = Influx() self.i.create_database('test_db') self._influx_db_name = 'test_db' self.i = Influx(database=self._influx_db_name) self.no_points = 288 self.location = Geoposition(52.5,24.3) self.site = Sesh_Site.objects.create(site_name=u"Test_aggregate", comission_date=timezone.datetime(2015, 12, 11, 22, 0), location_city=u"kigali", location_country=u"rwanda", vrm_account = self.VRM, installed_kw=123.0, position=self.location, system_voltage=12, number_of_panels=12, vrm_site_id=213, battery_bank_capacity=12321, has_genset=True, has_grid=True) self.test_user = Sesh_User.objects.create_user("john doe","*****@*****.**","asdasd12345") #assign a user to the sites try: self.i.create_database(self._influx_db_name) #Generate random data points for 24h self.no_points = create_test_data(self.site) except Exception,e: self.i.delete_database(self._influx_db_name) sleep(1) self.i.create_database(self._influx_db_name) print e pass