Esempio n. 1
0
    def test_create_models(self):
        """
        Test of xml_importer.create_models.
        """
        xml_data = xmltodict.parse(self.sample_xml)
        b_data = xml_importer.building_data(xml_data)

        # no audit logs should exist yet, testing this way because it
        # is hard to assert what the content_object of an AuditLog is
        logs = AuditLog.objects.all()
        self.assertEqual(logs.count(), 0)
        cb = xml_importer.create_models(b_data, self.import_file)
        logs = AuditLog.objects.all()
        self.assert_models_created()
        self.assertEqual(logs.count(), 1)

        log = logs.first()
        self.assertEqual(log.user, self.user)
        self.assertEqual(log.organization, self.org)
Esempio n. 2
0
    def test_building_data(self):
        """
        Test of xml_importer.building_data.
        """
        xml_data = xmltodict.parse(self.sample_xml)


        expected_meter_data = {
            'currency': '840',
            'power_of_ten_multiplier': '-3',
            'uom': '169'
        }

        reading_expected = [
            {
                'cost': '190923',
                'value': '2083',
                'start_time': '1357027200',
                'duration': '86400'
            },
            {
                'cost': '190923',
                'value': '2083',
                'start_time': '1357113600',
                'duration': '86400'
            }
        ]

        expected_block_data = {
            'start_time': '1357027200',
            'duration': '31622400',
            'readings': reading_expected
        }

        expected = {
            'address': '635 ELM ST EL CERRITO CA 94530-3120',
            'service_category': '1',
            'meter': expected_meter_data,
            'interval': expected_block_data
        }

        data = xml_importer.building_data(xml_data)
        self.assertEqual(data, sample_building_data)