Exemple #1
0
    def test_none_period(self):
        """ Запрос по периоду, в котором не было/нет орума """
        orum = Orum.objects.create(point=self.point, installation_in_period=self.periods[1])
        setting = OrumSetting(type=self.types[1], orum=orum, power=3, ratio=1, installation_orum=self.periods[2])
        setting.removed_orum = self.periods[5]
        setting.save()

        self.assertEqual(orum.get_kwh_in(self.periods[1]), None)
        self.assertEqual(orum.get_kwh_in(self.periods[5]), None)
        self.assertEqual(orum.get_kwh_in(self.periods[6]), None)
Exemple #2
0
    def test_get_setting_in(self):
        """
        Проверяет правильность получения объекта setting
        """
        orum = Orum.objects.create(point=self.point, installation_in_period=self.periods[1])

        setting = OrumSetting(type=self.types[2], orum=orum, power=3, hours=2, ratio=0.5)
        setting.installation_orum = self.periods[5]
        setting.removed_orum = self.periods[7]
        setting.save()
        setting = OrumSetting(type=self.types[2], orum=orum, power=3, hours=2, ratio=0.5)
        setting.installation_orum = self.periods[2]
        setting.removed_orum = self.periods[5]
        setting.save()

        self.assertEqual(orum.get_setting_in(self.periods[3]), setting)
        self.assertIsNone(orum.get_setting_in(self.periods[1]))
        self.assertIsNone(orum.get_setting_in(self.periods[7]))
        self.assertIsNone(orum.get_setting_in(self.periods[8]))
Exemple #3
0
        TD_ORUMCALC
    where
        TD_ORUMCALC.id_setuporum = %s
    """

    orumcalc.execute(select2 % so_id)
    orum_min.execute(sel_min % so_id)
    orum_max.execute(sel_max % so_id)

    try:
        min_p = int(orum_min.next()[0])
        max_p = int(orum_max.next()[0])

        orum = Orum.objects.create(type=OrumType.objects.get(pk=so_type))

        setting = OrumSetting(orum=orum, power=power, hours=hours, ratio=ratio)
        setting.installation_orum = Period.objects.get(pk=(min_p+9))
        if max_p < 58:
            setting.removed_orum = Period.objects.get(pk=(max_p+10))
        setting.save()

        for row_calc in orumcalc:
            date_use = row_calc[0]
            correction = row_calc[1]
            period = int(row_calc[2])

            if correction:
                OrumCorrection.objects.create(orum=orum, period=Period.objects.get(pk=(period+9)), kwh=Decimal(correction))

            if date_use and formula in (2, 3):
                OrumDateUse.objects.create(orum=orum, period=Period.objects.get(pk=(period+9)), date_use=date_use)
            if orum is None:
                orum = Orum.objects.create(
                    point=point,
                    installation_in_period=period_ins,
                )

            if max_p < 58:
                orum.removed_in_period = period_rem
            else:
                orum.removed_in_period = None
            orum.save()

            setting = OrumSetting(
                type=OrumType.objects.get(pk=so_type),
                orum=orum,
                power=power,
                hours=hours,
                ratio=ratio,
            )
            setting.installation_orum = period_ins
            setting.removed_orum = period_rem
            setting.save()

            # print 'point: %s' % t2_point[8]

            for row_calc in orumcalc:
                date_use = row_calc[0]
                correction = row_calc[1]
                period = int(row_calc[2])

                if correction: