Ejemplo n.º 1
0
    def test_export_dedupe(self):

        out = StringIO()

        cleanup_db()

        updated_at = datetime.strptime("2017:12:01", "%Y:%m:%d")
        updated_at = timezone.make_aware(updated_at)

        test = TestDupe(dummy_id='xyz', updated_at=updated_at)
        test.save()

        updated_at = datetime.strptime("2017:12:02", "%Y:%m:%d")
        updated_at = timezone.make_aware(updated_at)

        test = TestDupe(dummy_id='xyz', updated_at=updated_at)
        test.save(force_insert=True)

        call_command('export_data_csv',
                     'tests',
                     'default',
                     'TestDupe',
                     'deleteme.csv',
                     '--dedupe_key=dummy_id',
                     '--order_by=updated_at',
                     stdout=out)

        self.assertEqual(out.getvalue(), 'Wrote 1 lines to deleteme.csv\n')

        os.remove('deleteme.csv')
Ejemplo n.º 2
0
    def test_import(self):

        out = StringIO()

        self.create_csv()
        cleanup_db()

        call_command('import_image_metadata',
                     self.FILENAME,
                     'photo_survey',
                     stdout=out)

        os.remove(self.FILENAME)
Ejemplo n.º 3
0
    def test_import_missing_parcelmetadata(self):

        out = StringIO()

        self.create_csv()

        parcel = ParcelMetadata.objects.using('photo_survey').first()

        cleanup_db()

        parcel.parcel_id = 'removed'
        parcel.save(using='photo_survey')

        call_command('import_image_metadata',
                     self.FILENAME,
                     'photo_survey',
                     stdout=out)

        os.remove(self.FILENAME)
Ejemplo n.º 4
0
 def setUp(self):
     cleanup_db()