This repository has been archived by the owner on Mar 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_new_project.py
49 lines (34 loc) · 1.51 KB
/
test_new_project.py
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
import os
import shutil
from django.conf import settings
from django.test import override_settings
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from tprs.models import Project
from . import new_project as script
@override_settings(MEDIA_ROOT=os.path.join(settings.BASE_DIR, 'test-media'))
class ClientTests(StaticLiveServerTestCase):
def setUp(self):
shutil.copytree(
os.path.join(settings.BASE_DIR, 'testdata'),
os.path.join(settings.MEDIA_ROOT, 'testdata'))
def tearDown(self):
shutil.rmtree(settings.MEDIA_ROOT)
def test_run(self):
PROJ_NAME = 'new-project'
testdata_dir = os.path.join(settings.BASE_DIR, 'testdata')
self.assertEqual(Project.objects.filter(name=PROJ_NAME).count(), 0)
self.assertEquals(0, script.main([
'new_project.py',
'--project-name', PROJ_NAME,
'--top', os.path.join(testdata_dir, 'plcg_sh2_wt.top'),
'--mdp', os.path.join(testdata_dir, 'plcg_sh2_wt.mdp'),
'--gro', os.path.join(testdata_dir, 'plcg_sh2_wt.gro'),
'--gromppery', self.live_server_url]))
self.assertEqual(Project.objects.filter(name=PROJ_NAME).count(), 1)
proj = Project.objects.get(name=PROJ_NAME)
for filetype in ['top', 'mdp', 'gro']:
self.assertEqual(
os.path.basename(getattr(proj, filetype).name),
'.'.join([PROJ_NAME, filetype]))
# should be able to grompp
proj.grompp()