def test_not_create_energy_transductor_no_transductor_model(self):
        size = len(EnergyTransductor.objects.all())

        energy_transductor = EnergyTransductor()
        energy_transductor.serial_number = '12345678'
        energy_transductor.ip_address = ''
        energy_transductor.broken = False
        energy_transductor.active = True
        energy_transductor.installation_date = datetime.now()

        with self.assertRaises(IntegrityError):
            energy_transductor.save()
    def test_not_create_energy_transductor_wrong_serial_number(self):
        size = len(EnergyTransductor.objects.all())

        transductor = EnergyTransductor()
        transductor.serial_number = '123456789'
        transductor.ip_address = '1.1.1.1'
        transductor.broken = False
        transductor.active = True
        transductor.model = "EnergyTransductor"
        transductor.installation_date = datetime.now()

        with self.assertRaises(DataError):
            transductor.save()
    def test_not_create_energy_transductor_no_geolocation_longitude(self):
        size = len(EnergyTransductor.objects.all())

        transductor = EnergyTransductor()
        transductor.serial_number = '123456789'
        transductor.ip_address = '1.1.1.1'
        transductor.broken = False
        transductor.active = True
        transductor.model = "EnergyTransductor"
        transductor.firmware_version = '12.1.3215'
        transductor.physical_location = 'predio 2 sala 44'
        transductor.geolocation_latitude = -24.4556
        transductor.installation_date = datetime.now()

        with self.assertRaises(DataError):
            transductor.save()
    def test_create_energy_transductor(self):
        size = len(EnergyTransductor.objects.all())

        energy_transductor = EnergyTransductor()
        energy_transductor.serial_number = '12345678'
        energy_transductor.ip_address = '1.1.1.1'
        energy_transductor.broken = False
        energy_transductor.active = True
        energy_transductor.model = "EnergyTransductor"
        energy_transductor.firmware_version = '12.1.3215'
        energy_transductor.physical_location = 'predio 2 sala 44'
        energy_transductor.geolocation_longitude = -24.4556
        energy_transductor.geolocation_latitude = -24.45996
        energy_transductor.installation_date = datetime.now()

        self.assertIsNone(energy_transductor.save())
        self.assertEqual(size + 1, len(EnergyTransductor.objects.all()))
Beispiel #5
0
    def setUp(self):
        t_model = TransductorModel()
        t_model.name = "TR 4020"
        t_model.transport_protocol = "UdpProtocol"
        t_model.serial_protocol = "ModbusRTU"
        t_model.register_addresses = [[4, 0], [68, 1]]
        t_model.measurements_type = "EnergyMeasurements"
        t_model.save()

        self.t_model = t_model

        transductor = EnergyTransductor()
        transductor.serie_number = "1"
        transductor.description = "Test"
        transductor.model = t_model
        transductor.ip_address = "111.111.111.111"
        transductor.broken = False
        transductor.save()

        self.transductor = transductor

        self.modbus_rtu = ModbusRTU(self.transductor)