예제 #1
0
    def test_run(self):
        r = Run(num_agents=100, ticks=10)
        out = r.run()
        self.assertTrue(r is not None)
        self.assertEqual(out.ticks, 10)
        self.assertEqual(out.params['num_agents'], 100)
        self.assertEqual(len(out.data), out.ticks)

        r = Run(num_agents=10, ticks=100)
        out = r.run()
        self.assertEqual(out.ticks, 100)
        self.assertEqual(out.params['num_agents'], 10)
        self.assertEqual(len(out.data), out.ticks)
예제 #2
0
    def test_run(self):
        r = Run(num_agents=100, ticks=10)
        out = r.run()
        self.assertTrue(r is not None)
        self.assertEqual(out.ticks, 10)
        self.assertEqual(out.params['num_agents'], 100)
        self.assertEqual(len(out.data), out.ticks)

        r = Run(num_agents=10, ticks=100)
        out = r.run()
        self.assertEqual(out.ticks, 100)
        self.assertEqual(out.params['num_agents'], 10)
        self.assertEqual(len(out.data), out.ticks)
예제 #3
0
 def test_serialization(self):
     u = User.objects.create(username='******')
     rr = RunRecord.objects.create(user=u)
     r = Run(ticks=100)
     rr.from_run(r)
     out = r.run()
     ror = RunOutputRecord.objects.create(run=rr)
     ror.from_runoutput(out)
     out2 = ror.get_runoutput()
     self.assertEqual(out.ticks, out2.ticks)
예제 #4
0
 def test_serialization(self):
     u = User.objects.create(username='******')
     rr = RunRecord.objects.create(user=u)
     r = Run(ticks=100)
     rr.from_run(r)
     out = r.run()
     ror = RunOutputRecord.objects.create(run=rr)
     ror.from_runoutput(out)
     out2 = ror.get_runoutput()
     self.assertEqual(out.ticks, out2.ticks)
예제 #5
0
 def test_run_json(self):
     u = User.objects.create(username='******')
     rr = RunRecord.objects.create(user=u)
     r = Run(ticks=10, number_agents=10)
     rr.from_run(r)
     ror = RunOutputRecord.objects.create(run=rr)
     out = r.run()
     ror.from_runoutput(out)
     response = self.c.get("/run/%d/json/" % rr.id)
     self.assertEquals(response.status_code, 200)
     self.assertTrue("agents_mass" in response.content)
예제 #6
0
 def test_compare_runs(self):
     u = User.objects.create(username='******')
     rr = RunRecord.objects.create(user=u)
     r = Run(ticks=10, number_agents=10)
     rr.from_run(r)
     ror = RunOutputRecord.objects.create(run=rr)
     out = r.run()
     ror.from_runoutput(out)
     response = self.c.get("/run/compare/?run_%d=on" % rr.id)
     self.assertEquals(response.status_code, 200)
     self.assertTrue("makeGraph" in response.content)
예제 #7
0
파일: test_views.py 프로젝트: ccnmtl/capsim
 def test_run(self):
     u = User.objects.create(username='******')
     rr = RunRecord.objects.create(user=u)
     r = Run(ticks=10, number_agents=10)
     rr.from_run(r)
     ror = RunOutputRecord.objects.create(run=rr)
     out = r.run()
     ror.from_runoutput(out)
     response = self.c.get("/run/%d/" % rr.id)
     self.assertEquals(response.status_code, 200)
     self.assertContains(response, "<h2>Saved Run: ")
예제 #8
0
파일: test_views.py 프로젝트: ccnmtl/capsim
 def test_run_json(self):
     u = User.objects.create(username='******')
     rr = RunRecord.objects.create(user=u)
     r = Run(ticks=10, number_agents=10)
     rr.from_run(r)
     ror = RunOutputRecord.objects.create(run=rr)
     out = r.run()
     ror.from_runoutput(out)
     response = self.c.get("/run/%d/json/" % rr.id)
     self.assertEquals(response.status_code, 200)
     self.assertContains(response, "agents_mass")
예제 #9
0
파일: test_views.py 프로젝트: ccnmtl/capsim
 def test_compare_runs(self):
     u = User.objects.create(username='******')
     rr = RunRecord.objects.create(user=u)
     r = Run(ticks=10, number_agents=10)
     rr.from_run(r)
     ror = RunOutputRecord.objects.create(run=rr)
     out = r.run()
     ror.from_runoutput(out)
     response = self.c.get("/run/compare/?run_%d=on" % rr.id)
     self.assertEquals(response.status_code, 200)
     self.assertContains(response, "makeGraph")
예제 #10
0
 def test_run(self):
     u = User.objects.create(username='******')
     rr = RunRecord.objects.create(user=u)
     r = Run(ticks=10, number_agents=10)
     rr.from_run(r)
     ror = RunOutputRecord.objects.create(run=rr)
     out = r.run()
     ror.from_runoutput(out)
     response = self.c.get("/run/%d/" % rr.id)
     self.assertEquals(response.status_code, 200)
     self.assertTrue("<h2>Saved Run: " in response.content)
예제 #11
0
파일: views.py 프로젝트: ccnmtl/capsim
    def post(self, request):
        form = RunForm(request.POST)
        if form.is_valid():
            parameters = dict()
            for f in ALL_FIELDS:
                parameters[f] = form.cleaned_data[f]

            r = Run(**parameters)
            rr = RunRecord()
            rr.user = request.user
            rr.from_run(r)
            out = r.run()

            ror = RunOutputRecord(run=rr)
            skew_params = dict(mass=0., intake=0., expenditure=0.)

            if waffle.flag_is_active(request, 'demo_mode'):
                skew_params = apply_skews(request, skew_params)
            ror.from_runoutput(out, skew_params)
            return HttpResponseRedirect(rr.get_absolute_url())
        return render(
            request, self.template_name,
            dict(form=form, interventions=Intervention.objects.all(),
                 parameters=Parameter.objects.all()))
예제 #12
0
파일: views.py 프로젝트: mrcrymnd/capsim
    def post(self, request):
        form = RunForm(request.POST)
        if form.is_valid():
            parameters = dict()
            for f in ALL_FIELDS:
                parameters[f] = form.cleaned_data[f]

            r = Run(**parameters)
            rr = RunRecord()
            rr.user = request.user
            rr.from_run(r)
            out = r.run()

            ror = RunOutputRecord(run=rr)
            skew_params = dict(mass=0., intake=0., expenditure=0.)

            if waffle.flag_is_active(request, 'demo_mode'):
                skew_params = apply_skews(request, skew_params)
            ror.from_runoutput(out, skew_params)
            return HttpResponseRedirect(rr.get_absolute_url())
        return render(
            request, self.template_name,
            dict(form=form, interventions=Intervention.objects.all(),
                 parameters=Parameter.objects.all()))
예제 #13
0
 def test_runoutputserialization(self):
     r = Run(num_agents=100, ticks=10)
     out = r.run()
     d = out.to_dict()
     self.assertTrue('data' in d)
     self.assertEqual(d['ticks'], 10)
예제 #14
0
 def test_runoutputserialization(self):
     r = Run(num_agents=100, ticks=10)
     out = r.run()
     d = out.to_dict()
     self.assertTrue('data' in d)
     self.assertEqual(d['ticks'], 10)