コード例 #1
0
 def test_create_load_profile(self):
     """Ensure we can create a new load profile object."""
     _ = create_county(CountyTests.county_name, CountyTests.total_session,
                       CountyTests.total_energy, CountyTests.peak_energy)
     _ = create_load_forecast_config(
         LoadForecastConfigTests.config_name,
         LoadForecastConfigTests.aggregation_level,
         LoadForecastConfigTests.num_evs, LoadForecastConfigTests.choice,
         LoadForecastConfigTests.fast_percent,
         LoadForecastConfigTests.work_percent,
         LoadForecastConfigTests.res_percent,
         LoadForecastConfigTests.l1_percent,
         LoadForecastConfigTests.public_l2_percent)
     lf_config = LoadForecastConfig.objects.get()
     _ = create_load_profile_config(lf_config, LoadProfileConfigTests.poi,
                                    LoadProfileConfigTests.year,
                                    LoadProfileConfigTests.day_type)
     config = LoadProfileConfig.objects.get()
     response = create_load_profile(config, json.dumps(self.loads))
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(LoadProfile.objects.count(), 1)
     obj = LoadProfile.objects.get()
     self.assertEqual(obj.config.lf_config.config_name,
                      LoadForecastConfigTests.config_name)
     self.assertEqual(obj.config.poi, LoadProfileConfigTests.poi.name)
     self.assertEqual(json.loads(obj.loads), self.loads)
コード例 #2
0
 def test_create_load_forecast(self):
     """Ensure we can create a new EV load forecast object."""
     _ = create_county(CountyTests.county_name, CountyTests.total_session,
                       CountyTests.total_energy, CountyTests.peak_energy)
     _ = create_load_forecast_config(
         LoadForecastConfigTests.config_name,
         LoadForecastConfigTests.aggregation_level,
         LoadForecastConfigTests.num_evs, LoadForecastConfigTests.choice,
         LoadForecastConfigTests.fast_percent,
         LoadForecastConfigTests.work_percent,
         LoadForecastConfigTests.res_percent,
         LoadForecastConfigTests.l1_percent,
         LoadForecastConfigTests.public_l2_percent)
     config = LoadForecastConfig.objects.get()
     response = create_load_forecast(config,
                                     json.dumps(self.residential_l1_load),
                                     json.dumps(self.residential_l2_load),
                                     json.dumps(self.residential_mud_load),
                                     json.dumps(self.work_load),
                                     json.dumps(self.fast_load),
                                     json.dumps(self.public_l2_load),
                                     json.dumps(self.total_load))
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(LoadForecast.objects.count(), 1)
     obj = LoadForecast.objects.get()
     self.assertEqual(obj.config.config_name,
                      LoadForecastConfigTests.config_name)
     self.assertEqual(obj.config.aggregation_level,
                      LoadForecastConfigTests.aggregation_level.name)
     self.assertEqual(json.loads(obj.residential_l1_load),
                      self.residential_l1_load)
     self.assertEqual(json.loads(obj.total_load), self.total_load)
コード例 #3
0
ファイル: test_config.py プロジェクト: derins/SCRIPT-fork
 def test_create_load_forecast_config(self):
     """Ensure we can create a new config of load forecast object."""
     _ = create_county(CountyTests.county_name,
                         CountyTests.total_session,
                         CountyTests.total_energy,
                         CountyTests.peak_energy)
     response = create_load_forecast_config(self.config_name,
                                             self.aggregation_level,
                                             self.num_evs,
                                             self.choice,
                                             self.fast_percent,
                                             self.work_percent,
                                             self.res_percent,
                                             self.l1_percent,
                                             self.public_l2_percent)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(LoadForecastConfig.objects.count(), 1)
     obj = LoadForecastConfig.objects.get()
     self.assertEqual(obj.aggregation_level, self.aggregation_level.name)
     self.assertEqual(obj.choice, self.choice)
     self.assertEqual(obj.fast_percent, self.fast_percent)
コード例 #4
0
ファイル: test_config.py プロジェクト: derins/SCRIPT-fork
 def test_create_emission_config(self):
     """Ensure we can create a new config of emission object."""
     _ = create_county(CountyTests.county_name,
                         CountyTests.total_session,
                         CountyTests.total_energy,
                         CountyTests.peak_energy)
     _ = create_load_forecast_config(LoadForecastConfigTests.config_name,
                                     LoadForecastConfigTests.aggregation_level,
                                     LoadForecastConfigTests.num_evs,
                                     LoadForecastConfigTests.choice,
                                     LoadForecastConfigTests.fast_percent,
                                     LoadForecastConfigTests.work_percent,
                                     LoadForecastConfigTests.res_percent,
                                     LoadForecastConfigTests.l1_percent,
                                     LoadForecastConfigTests.public_l2_percent)
     response = create_emission_config(LoadForecastConfigTests.config_name, self.year)
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(EmissionConfig.objects.count(), 1)
     obj = EmissionConfig.objects.get()
     self.assertEqual(obj.lf_config.config_name, LoadForecastConfigTests.config_name)
     self.assertEqual(obj.year, self.year)
コード例 #5
0
 def test_create_cost_benefit(self):
     """Ensure we can create a new cost benefit object."""
     _ = create_county(CountyTests.county_name, CountyTests.total_session,
                       CountyTests.total_energy, CountyTests.peak_energy)
     _ = create_load_forecast_config(
         LoadForecastConfigTests.config_name,
         LoadForecastConfigTests.aggregation_level,
         LoadForecastConfigTests.num_evs, LoadForecastConfigTests.choice,
         LoadForecastConfigTests.fast_percent,
         LoadForecastConfigTests.work_percent,
         LoadForecastConfigTests.res_percent,
         LoadForecastConfigTests.l1_percent,
         LoadForecastConfigTests.public_l2_percent)
     lf_config = LoadForecastConfig.objects.get()
     _ = create_cost_benefit_config(lf_config, CostBenefitConfigTests.year)
     config = CostBenefitConfig.objects.get()
     response = create_cost_benefit(config, json.dumps(self.cost_benefit))
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(CostBenefit.objects.count(), 1)
     obj = CostBenefit.objects.get()
     self.assertEqual(obj.config.year, CostBenefitConfigTests.year)
     self.assertEqual(json.loads(obj.cost_benefit), self.cost_benefit)
コード例 #6
0
 def test_create_net_present_value(self):
     """Ensure we can create a new net present value object."""
     _ = create_county(CountyTests.county_name, CountyTests.total_session,
                       CountyTests.total_energy, CountyTests.peak_energy)
     _ = create_load_forecast_config(
         LoadForecastConfigTests.config_name,
         LoadForecastConfigTests.aggregation_level,
         LoadForecastConfigTests.num_evs, LoadForecastConfigTests.choice,
         LoadForecastConfigTests.fast_percent,
         LoadForecastConfigTests.work_percent,
         LoadForecastConfigTests.res_percent,
         LoadForecastConfigTests.l1_percent,
         LoadForecastConfigTests.public_l2_percent)
     lf_config = LoadForecastConfig.objects.get()
     _ = create_net_present_value_config(lf_config,
                                         NetPresentValueConfigTests.year)
     config = NetPresentValueConfig.objects.get()
     response = create_net_present_value(config,
                                         json.dumps(self.net_present_value))
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(NetPresentValue.objects.count(), 1)
     obj = NetPresentValue.objects.get()
     self.assertEqual(obj.config.year, NetPresentValueConfigTests.year)
     self.assertEqual(json.loads(obj.npv), self.net_present_value)