Exemplo n.º 1
0
    def test_casestudies_of_profile(self):
        casestudy_hh = CaseStudyFactory(name='Hamburg')
        casestudy_ams = CaseStudyFactory(name='Amsterdam')
        casestudies = [casestudy_hh, casestudy_ams]
        user = ProfileFactory()
        user_in_hh = UserInCasestudyFactory(user=user,
                                            casestudy=casestudy_hh)
        user_in_ams = UserInCasestudyFactory(user=user,
                                             casestudy=casestudy_ams)

        # assert that the user has the correct casestudies assigned
        self.assertEqual([(cs.id, cs.name) for cs in user.casestudies.all()],
                         [(cs.id, cs.name) for cs in casestudies])
Exemplo n.º 2
0
    def setUp(self):
        super().setUp()
        self.obj = PublicationInCasestudyFactory(
            casestudy=self.uic.casestudy,
            publication__id=self.publication,
            publication__type__title=self.pup_type)

        # create a user with 2 casestudies
        self.user = ProfileFactory(user__id=self.user_id,
                                   user__username='******')
        self.uic1 = UserInCasestudyFactory(user=self.user,
                                           casestudy__id=self.casestudy1)
        self.uic2 = UserInCasestudyFactory(user=self.user,
                                           casestudy__id=self.casestudy2)
Exemplo n.º 3
0
 def setUpClass(cls):
     super().setUpClass()
     cls.uic = UserInCasestudyFactory(id=cls.userincasestudy,
                                      user__user__id=cls.user,
                                      user__user__username='******',
                                      casestudy__id=cls.casestudy)
     cls.kic = KeyflowInCasestudyFactory(id=cls.keyflow,
                                         casestudy=cls.uic.casestudy)
Exemplo n.º 4
0
    def test_01_implementation(self):

        user = UserInCasestudyFactory(casestudy=self.keyflow.casestudy,
                                      user__user__username='******')
        strategy = StrategyFactory(keyflow=self.keyflow, user=user)
        implementation = SolutionInStrategyFactory(solution=self.solution,
                                                   strategy=strategy)

        answer = ImplementationQuantity(question=self.beer_question,
                                        implementation=implementation,
                                        value=1)
Exemplo n.º 5
0
    def test_strategyfractionflows(self):
        #solutioncategory_id = 21
        #solution_id = 1
        strategy_id = 1

        ## generate a new solution category with a solution
        #solutioncategory = SolutionCategoryFactory(id=solutioncategory_id)
        #solution = SolutionFactory(id=solution_id,
        #solution_category=solutioncategory,
        #name='Test Solution')

        # generate a new strategy category with a solution
        user = UserInCasestudyFactory(casestudy=self.kic_obj.casestudy,
                                      user__user__username='******')
        strategy = StrategyFactory(id=strategy_id,
                                   keyflow=self.kic_obj,
                                   user=user,
                                   name='Test Strategy')

        # generate 2 new strategyfractions
        strategyfraction1 = StrategyFractionFlowFactory(
            strategy=strategy,
            fractionflow=self.fractionflow1,
            amount=self.new_amount1)
        strategyfraction2 = StrategyFractionFlowFactory(
            strategy=strategy,
            fractionflow=self.fractionflow2,
            amount=self.new_amount2)

        flows = FractionFlow.objects.filter(
            Q(keyflow=self.keyflowincasestudy)
            & (Q(f_strategyfractionflow__isnull=True)
               | Q(f_strategyfractionflow__strategy=strategy_id))).annotate(
                   actual_amount=Coalesce('f_strategyfractionflow__amount',
                                          'amount'))
        assert flows.get(
            flow_id=self.flowid1).actual_amount == self.new_amount1
        assert flows.get(
            flow_id=self.flowid2).actual_amount == self.new_amount2
        assert flows.get(flow_id=self.flowid3).actual_amount == \
               FractionFlow.objects.get(flow_id=self.flowid3).amount
Exemplo n.º 6
0
    def test_01_implementation(self):

        ## implement the solution as a user would ##

        user = UserInCasestudyFactory(casestudy=self.keyflow.casestudy,
                                      user__user__username='******')
        strategy = StrategyFactory(keyflow=self.keyflow, user=user)
        implementation = SolutionInStrategyFactory(solution=self.solution,
                                                   strategy=strategy)

        implementation_area = ImplementationAreaFactory(
            implementation=implementation,
            geom=MultiPolygon(
                Polygon(((0.0, 0.0), (0.0, 20.0), (56.0, 20.0), (56.0, 0.0),
                         (0.0, 0.0)))),
            possible_implementation_area=self.possible_implementation_area)

        # answer the question
        # Note CF: the diagram says 250 * 5 cubic meters, don't know what fungus
        # insulation weighs
        answer = ImplementationQuantity(question=self.fungus_question,
                                        implementation=implementation,
                                        value=25)