42 |
42 |
43 if not hasattr(TestCase, 'assertItemsEqual'): |
43 if not hasattr(TestCase, 'assertItemsEqual'): |
44 assertItemsEqual = TestCase.assertCountEqual |
44 assertItemsEqual = TestCase.assertCountEqual |
45 |
45 |
46 def test_newcube(self): |
46 def test_newcube(self): |
47 expected = ['i18n', 'hooks.py', 'setup.py', 'views.py', 'test', |
47 expected_project_content = ['setup.py', 'test', 'MANIFEST.in', |
48 'migration', 'entities.py', 'MANIFEST.in', 'schema.py', |
48 'cubicweb_foo', |
49 'cubicweb-foo.spec', '__init__.py', 'debian', 'data', |
49 'cubicweb-foo.spec', 'debian', 'README', |
50 '__pkginfo__.py', 'README', 'tox.ini'] |
50 'tox.ini'] |
|
51 expected_package_content = ['i18n', 'hooks.py', 'views.py', |
|
52 'migration', 'entities.py', 'schema.py', |
|
53 '__init__.py', 'data', '__pkginfo__.py'] |
51 tmpdir = tempfile.mkdtemp(prefix="temp-cwctl-newcube") |
54 tmpdir = tempfile.mkdtemp(prefix="temp-cwctl-newcube") |
52 try: |
55 try: |
53 retcode, stdout = newcube(tmpdir, 'foo') |
56 retcode, stdout = newcube(tmpdir, 'foo') |
54 self.assertEqual(retcode, 0, msg=to_unicode(stdout)) |
57 self.assertEqual(retcode, 0, msg=to_unicode(stdout)) |
55 self.assertItemsEqual(os.listdir(osp.join(tmpdir, 'foo')), expected) |
58 project_dir = osp.join(tmpdir, 'cubicweb-foo') |
|
59 project_content = os.listdir(project_dir) |
|
60 package_dir = osp.join(project_dir, 'cubicweb_foo') |
|
61 package_content = os.listdir(package_dir) |
|
62 self.assertItemsEqual(project_content, expected_project_content) |
|
63 self.assertItemsEqual(package_content, expected_package_content) |
56 finally: |
64 finally: |
57 shutil.rmtree(tmpdir, ignore_errors=True) |
65 shutil.rmtree(tmpdir, ignore_errors=True) |
58 self.assertEqual(retcode, 0, msg=stdout) |
|
59 |
66 |
60 def test_flake8(self): |
67 def test_flake8(self): |
61 """Ensure newcube built from skeleton is flake8-compliant""" |
68 """Ensure newcube built from skeleton is flake8-compliant""" |
62 tmpdir = tempfile.mkdtemp(prefix="temp-cwctl-newcube-flake8") |
69 tmpdir = tempfile.mkdtemp(prefix="temp-cwctl-newcube-flake8") |
63 try: |
70 try: |
64 newcube(tmpdir, 'foo') |
71 newcube(tmpdir, 'foo') |
65 cmd = [sys.executable, '-m', 'flake8', osp.join(tmpdir, 'foo')] |
72 cmd = [sys.executable, '-m', 'flake8', |
|
73 osp.join(tmpdir, 'cubicweb-foo', 'cubicweb_foo')] |
66 proc = Popen(cmd, stdout=PIPE, stderr=STDOUT) |
74 proc = Popen(cmd, stdout=PIPE, stderr=STDOUT) |
67 retcode = proc.wait() |
75 retcode = proc.wait() |
68 finally: |
76 finally: |
69 shutil.rmtree(tmpdir, ignore_errors=True) |
77 shutil.rmtree(tmpdir, ignore_errors=True) |
70 self.assertEqual(retcode, 0, |
78 self.assertEqual(retcode, 0, |