Beispiel #1
0
    def test_create_models(self):
        """
        Test of xml_importer.create_models.
        """
        xml_data = xmltodict.parse(self.import_file.file.read())
        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)
        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)
Beispiel #2
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)
        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)