File: django-admin

package info (click to toggle)
python-django-import-export 4.3.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,300 kB
  • sloc: python: 11,650; makefile: 180; sh: 63; javascript: 50
file content (49 lines) | stat: -rwxr-xr-x 1,054 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh

set -eu

write_to_file() {
    cat >> "$1"
    echo "[---- $1 ----]"
    cat -n "$1"
    echo "[------------]"
}

cd ${AUTOPKGTEST_TMP:-/tmp}
rm -rf myproject

set -x

django-admin startproject myproject
cd myproject

./manage.py startapp myapp

write_to_file myapp/models.py <<MODELS
class Thing(models.Model):
    name = models.CharField(max_length=60)
MODELS

write_to_file myapp/admin.py <<ADMIN
from myapp import models
from import_export.admin import ImportExportModelAdmin

@admin.register(models.Thing)
class ThingAdmin(ImportExportModelAdmin):
    pass
ADMIN

write_to_file myapp/tests.py <<TESTS
from django.contrib.auth.models import User

class TestAdmin(TestCase):
    def test_admin_with_import_export(self):
        admin = User.objects.create(username="admin", is_superuser=True, is_staff=True)
        self.client.force_login(admin)
        self.client.get("/admin/myapp/thing/")
TESTS

echo 'INSTALLED_APPS += ["import_export", "myapp",]' | tee --append myproject/settings.py

./manage.py makemigrations
./manage.py test -v2