コード例 #1
0
ファイル: tests.py プロジェクト: NAVADMC/ADSM
 def test_no_iterations_completed(self):
     iteration = 10
     days = 7
     for i in range(1, iteration + 1):
         for d in range(1, days + 1):
             DailyControls.objects.create(iteration=i, day=d, last_day=False)
     self.assertEqual(iterations_complete(), 0)
コード例 #2
0
ファイル: tests.py プロジェクト: NAVADMC/ADSM
 def test_two_iterations_completed_outbreak_end(self):
     self.settings.stop_criteria = "outbreak-end"
     self.settings.save()
     iteration = 10
     days = 7
     for i in range(1, iteration + 1):
         for d in range(1, days + 1):
             DailyControls.objects.create(iteration=i, day=d)
         if i <= 4:
             DailyControls.objects.create(iteration=i, day=8, outbreakDuration=8, last_day=True)
     self.assertEqual(iterations_complete(), 4)
コード例 #3
0
ファイル: views.py プロジェクト: NAVADMC/ADSM
def simulation_status(request):
    output_settings = OutputSettings.objects.get()
    status = {
        'is_simulation_stopped': is_simulation_stopped(),
        'simulation_has_started': SmSession.objects.get().simulation_has_started,
        'iterations_total': output_settings.iterations,
        'iterations_started': len(list_of_iterations()),
        'iterations_completed': iterations_complete(),
        'iteration_text': mark_safe(SmSession.objects.get().iteration_text),
    }
    return JsonResponse(status)
コード例 #4
0
ファイル: tests.py プロジェクト: NAVADMC/ADSM
 def test_two_iterations_completed_stop_days(self):
     self.settings.stop_criteria = "stop-days"
     self.settings.days = 8
     self.settings.save()
     iteration = 10
     days = 7
     for i in range(1, iteration + 1):
         for d in range(1, days + 1):
             DailyControls.objects.create(iteration=i, day=d)
         if i <= 2:
             DailyControls.objects.create(iteration=i, day=8, last_day=True)
     self.assertEqual(iterations_complete(), 2)
コード例 #5
0
ファイル: tests.py プロジェクト: NAVADMC/ADSM
 def test_two_iterations_completed_first_detection(self):
     self.settings.stop_criteria = "first-detection"
     self.settings.save()
     pigs, created = ProductionType.objects.get_or_create(name="pig")
     cats, created = ProductionType.objects.get_or_create(name="cat")
     iteration = 10
     days = 7
     for i in range(1, iteration + 1):
         for d in range(1, days + 1):
             DailyControls.objects.create(iteration=i, day=d)
             DailyByProductionType.objects.create(iteration=i, day=d, production_type=None)
             DailyByProductionType.objects.create(iteration=i, day=d, production_type=pigs)
             DailyByProductionType.objects.create(iteration=i, day=d, production_type=cats)
         if i <= 6:
             DailyControls.objects.create(iteration=i, day=8, diseaseDuration=8, last_day=True)
             DailyByProductionType.objects.create(iteration=i, day=d, production_type=None, firstDetection=1, last_day=True)
             DailyByProductionType.objects.create(iteration=i, day=d, production_type=pigs, firstDetection=1, last_day=True) # first detection happened in pigs
             DailyByProductionType.objects.create(iteration=i, day=d, production_type=cats, last_day=True)
     self.assertEqual(iterations_complete(), 6)
コード例 #6
0
ファイル: context_processor.py プロジェクト: NAVADMC/ADSM
def results_context(request):
    context = {}
    
    if not request.is_ajax() and ('results/' in request.path or 'setup/' in request.path):  # results specific context
        session = SmSession.objects.get()
        context.update({'simulation_has_started': session.simulation_has_started,
                        'outputs_exist': outputs_exist(),
                        'results_progress': iteration_progress() * 100,})

        try:
            version = ResultsVersion.objects.all().first().__str__()  # singleton doesn't always work on this model (legacy)
        except:
            version = "No version available"
        context.update({
                        'is_simulation_running': is_simulation_running(),
                        'is_simulation_stopped': is_simulation_stopped(),
                        'iterations_completed': iterations_complete(),
                        'version_number': version
    
        })
        context.update(excluded_headers())

    return context