How to use the smartmin.csv_imports.models.generate_file_path function in smartmin

To help you get started, we’ve selected a few smartmin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nyaruka / smartmin / smartmin / csv_imports / tests.py View on Github external
def test_generate_file_path(self):
        self.assertEquals(generate_file_path(ImportTask(), 'allo.csv'), 'csv_imports/allo.csv')
        self.assertEquals(generate_file_path(ImportTask(), 'allo.xlsx'), 'csv_imports/allo.xlsx')
        self.assertEquals(generate_file_path(ImportTask(), 'allo.foo.bar'), 'csv_imports/allo.foo.bar')

        long_name = 'foo' * 100

        test_file_name = '%s.xls.csv' % long_name
        self.assertEquals(len(generate_file_path(ImportTask(), test_file_name)), 100)
        self.assertEquals(generate_file_path(ImportTask(), test_file_name), 'csv_imports/%s.csv' % long_name[:84])

        test_file_name = '%s.abc.xlsx' % long_name
        self.assertEquals(len(generate_file_path(ImportTask(), test_file_name)), 100)
        self.assertEquals(generate_file_path(ImportTask(), test_file_name), 'csv_imports/%s.xlsx' % long_name[:83])
github nyaruka / smartmin / smartmin / csv_imports / tests.py View on Github external
def test_generate_file_path(self):
        self.assertEquals(generate_file_path(ImportTask(), 'allo.csv'), 'csv_imports/allo.csv')
        self.assertEquals(generate_file_path(ImportTask(), 'allo.xlsx'), 'csv_imports/allo.xlsx')
        self.assertEquals(generate_file_path(ImportTask(), 'allo.foo.bar'), 'csv_imports/allo.foo.bar')

        long_name = 'foo' * 100

        test_file_name = '%s.xls.csv' % long_name
        self.assertEquals(len(generate_file_path(ImportTask(), test_file_name)), 100)
        self.assertEquals(generate_file_path(ImportTask(), test_file_name), 'csv_imports/%s.csv' % long_name[:84])

        test_file_name = '%s.abc.xlsx' % long_name
        self.assertEquals(len(generate_file_path(ImportTask(), test_file_name)), 100)
        self.assertEquals(generate_file_path(ImportTask(), test_file_name), 'csv_imports/%s.xlsx' % long_name[:83])
github nyaruka / smartmin / smartmin / csv_imports / tests.py View on Github external
def test_generate_file_path(self):
        self.assertEquals(generate_file_path(ImportTask(), 'allo.csv'), 'csv_imports/allo.csv')
        self.assertEquals(generate_file_path(ImportTask(), 'allo.xlsx'), 'csv_imports/allo.xlsx')
        self.assertEquals(generate_file_path(ImportTask(), 'allo.foo.bar'), 'csv_imports/allo.foo.bar')

        long_name = 'foo' * 100

        test_file_name = '%s.xls.csv' % long_name
        self.assertEquals(len(generate_file_path(ImportTask(), test_file_name)), 100)
        self.assertEquals(generate_file_path(ImportTask(), test_file_name), 'csv_imports/%s.csv' % long_name[:84])

        test_file_name = '%s.abc.xlsx' % long_name
        self.assertEquals(len(generate_file_path(ImportTask(), test_file_name)), 100)
        self.assertEquals(generate_file_path(ImportTask(), test_file_name), 'csv_imports/%s.xlsx' % long_name[:83])
github nyaruka / smartmin / smartmin / csv_imports / tests.py View on Github external
def test_generate_file_path(self):
        self.assertEquals(generate_file_path(ImportTask(), 'allo.csv'), 'csv_imports/allo.csv')
        self.assertEquals(generate_file_path(ImportTask(), 'allo.xlsx'), 'csv_imports/allo.xlsx')
        self.assertEquals(generate_file_path(ImportTask(), 'allo.foo.bar'), 'csv_imports/allo.foo.bar')

        long_name = 'foo' * 100

        test_file_name = '%s.xls.csv' % long_name
        self.assertEquals(len(generate_file_path(ImportTask(), test_file_name)), 100)
        self.assertEquals(generate_file_path(ImportTask(), test_file_name), 'csv_imports/%s.csv' % long_name[:84])

        test_file_name = '%s.abc.xlsx' % long_name
        self.assertEquals(len(generate_file_path(ImportTask(), test_file_name)), 100)
        self.assertEquals(generate_file_path(ImportTask(), test_file_name), 'csv_imports/%s.xlsx' % long_name[:83])
github nyaruka / smartmin / smartmin / csv_imports / tests.py View on Github external
def test_generate_file_path(self):
        self.assertEquals(generate_file_path(ImportTask(), 'allo.csv'), 'csv_imports/allo.csv')
        self.assertEquals(generate_file_path(ImportTask(), 'allo.xlsx'), 'csv_imports/allo.xlsx')
        self.assertEquals(generate_file_path(ImportTask(), 'allo.foo.bar'), 'csv_imports/allo.foo.bar')

        long_name = 'foo' * 100

        test_file_name = '%s.xls.csv' % long_name
        self.assertEquals(len(generate_file_path(ImportTask(), test_file_name)), 100)
        self.assertEquals(generate_file_path(ImportTask(), test_file_name), 'csv_imports/%s.csv' % long_name[:84])

        test_file_name = '%s.abc.xlsx' % long_name
        self.assertEquals(len(generate_file_path(ImportTask(), test_file_name)), 100)
        self.assertEquals(generate_file_path(ImportTask(), test_file_name), 'csv_imports/%s.xlsx' % long_name[:83])
github nyaruka / smartmin / smartmin / csv_imports / migrations / 0002_auto_20161118_1920.py View on Github external
from django.db import migrations, models
import smartmin.csv_imports.models


class Migration(migrations.Migration):

    dependencies = [
        ('csv_imports', '0001_initial'),
    ]

    operations = [
        migrations.AlterField(
            model_name='importtask',
            name='csv_file',
            field=models.FileField(help_text='A comma delimited file of records to import', upload_to=smartmin.csv_imports.models.generate_file_path, verbose_name='Import file'),
        ),