@@ -0,0 +1,2212 @@
+# -*- coding: utf-8 -*-%0Afrom __future__ import print_function%0Afrom __future__ import unicode_literals%0Afrom __future__ import division%0A%0Afrom django.conf import settings%0Afrom django.contrib.contenttypes.models import ContentType%0A%0Afrom treemap.models import Species, Instance, Tree, Plot, Audit, TreePhoto%0Afrom treemap.management.util import InstanceDataCommand%0A%0Afrom otm1_migrator.models import OTM1ModelRelic%0A%0A%0Aclass Command(InstanceDataCommand):%0A    def pseudo_assert_equals(self, item1, item2, description):%0A        isEqual = 'SUCCESS' if item1 == item2 else 'WARNING'%0A        self.stdout.write('testing assertion: %25s ... %25s - %25s / %25s'%0A                          %25 (description, isEqual, item1, item2))%0A%0A    def test_class(self, clz, instance_id=None):%0A        name = clz.__name__.lower()%0A        objects = clz.objects.all()%0A%0A        if instance_id:%0A            objects = objects.filter(instance_id=instance_id)%0A%0A        object_count = objects.count()%0A        object_relics = OTM1ModelRelic.objects.filter(%0A            otm2_model_name__iexact=name)%0A%0A        if instance_id:%0A            object_relics = object_relics.filter(instance_id=instance_id)%0A%0A        object_relic_count = object_relics.count()%0A%0A        self.pseudo_assert_equals(object_count, object_relic_count,%0A                                  'there are an equal number of '%0A                                  '%25s and %25s relics.'%0A                                  %25 (name, name))%0A%0A    def handle(self, *args, **options):%0A%0A        if settings.DEBUG:%0A            self.stdout.write('In order to run this command you must manually'%0A                              'set DEBUG=False in your settings file. '%0A                              'Unfortunately, django runs out of memory when '%0A                              'this command is run in DEBUG mode.')%0A            return 1%0A%0A        try:%0A            instance_id = options%5B'instance'%5D%0A            Instance.objects.get(pk=instance_id)%0A        except Instance.DoesNotExist:%0A            self.stdout.write('Invalid instance provided.')%0A            return 1%0A%0A        for clz in (Tree, Plot, Audit, TreePhoto, Species):%0A            self.test_class(clz, instance_id=instance_id)%0A%0A        self.test_class(ContentType)%0A

Add mgmt command for basic otm1 migration checks