Skip to content

Commit 9d51112

Browse files
committed
Added test to verify multiple databases work for copy_from
1 parent 1100dc6 commit 9d51112

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

setup.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ def run(self):
2222
'USER': 'postgres',
2323
'ENGINE': 'django.db.backends.postgresql_psycopg2'
2424
},
25+
'alternative': {
26+
'NAME': 'test_alternative',
27+
'USER': 'postgres',
28+
'ENGINE': 'django.db.backends.postgresql_psycopg2'
29+
},
2530
'sqlite': {
2631
'NAME': 'sqlite',
2732
'ENGINE': 'django.db.backends.sqlite3'
@@ -35,8 +40,8 @@ def run(self):
3540

3641
setup(
3742
name='django-postgres-copy',
38-
version='2.0.0',
39-
description="Quickly move comma-delimited data in and out of a Django model using PostgreSQL's COPY command.",
43+
version='0.2.3',
44+
description="Quickly load comma-delimited data into a Django model using PostgreSQL's COPY command",
4045
author='Ben Welsh',
4146
author_email='ben.welsh@gmail.com',
4247
url='http://django-postgres-copy.californiacivicdata.org/',
@@ -52,11 +57,9 @@ def run(self):
5257
'Programming Language :: Python :: 3.6',
5358
'Framework :: Django',
5459
'Framework :: Django :: 1.8',
60+
'Framework :: Django :: 1.9',
5561
'Framework :: Django :: 1.10',
5662
'Framework :: Django :: 1.11',
5763
'License :: OSI Approved :: MIT License',
58-
'Intended Audience :: Developers',
59-
'Topic :: Database',
60-
'Topic :: Database :: Database Engines/Servers'
6164
],
6265
)

tests/tests.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,20 @@ def test_hooks(self):
416416

417417
c.drop(cursor)
418418
cursor.close()
419+
420+
421+
class MultiDbTest(BaseTest):
422+
423+
def test_simple_save(self):
424+
MockObject.objects.from_csv(
425+
self.name_path,
426+
dict(name='NAME', number='NUMBER', dt='DATE'),
427+
using='alternative'
428+
)
429+
self.assertEqual(MockObject.objects.count(), 0)
430+
self.assertEqual(MockObject.objects.using('alternative').count(), 3)
431+
self.assertEqual(MockObject.objects.using('alternative').get(name='BEN').number, 1)
432+
self.assertEqual(
433+
MockObject.objects.using('alternative').get(name='BEN').dt,
434+
date(2012, 1, 1)
435+
)

0 commit comments

Comments
 (0)