Beispiel #1
0
 def test_base_invocation(self):
     base_dir = mkdtemp()
     project_dir = os.path.join(base_dir, "example_prj")
     original_dir = os.getcwd()
     os.chdir(base_dir)
     with patch("sys.stdout", self.stdout):
         with patch("sys.stderr", self.stderr):
             sys.argv = ["main"] + ["--cms-version=stable", "example_prj"]
             main.execute()
             self.assertTrue(
                 os.path.exists(os.path.join(project_dir, "static")))
             self.assertTrue(
                 os.path.exists(
                     os.path.join(project_dir, "requirements.txt")))
             self.assertTrue(
                 os.path.exists(
                     os.path.join(project_dir, "example_prj", "static")))
             with open(os.path.join(project_dir,
                                    "requirements.txt")) as req_file:
                 text = req_file.read()
                 self.assertTrue(text.find("djangocms-text-ckeditor") > -1)
             self.assertTrue((
                 'Get into "%s" directory and type "python manage.py runserver" to start your project'
                 % project_dir) in self.stdout.getvalue())
     os.chdir(project_dir)
     with patch("sys.stdout", self.stdout):
         out = subprocess.check_output([
             "sqlite3", "project.db",
             'SELECT COUNT(*) FROM auth_user WHERE username="******"'
         ])
         self.assertEqual(bytes(out), bytes(b"1\n"))
     os.chdir(original_dir)
     rmtree(base_dir)
Beispiel #2
0
    def test_requirements_invocation(self):
        dj_version, dj_match = get_stable_django(latest=True)

        with patch("sys.stdout", self.stdout):
            with patch("sys.stderr", self.stderr):
                sys.argv = ["main"] + [
                    "--db=sqlite://localhost/test.db",
                    "-len",
                    "--cms-version=stable",
                    "-R",
                    "-q",
                    "-u",
                    "-p" + self.project_dir,
                    "example_prj",
                ]
                main.execute()
        stdout = self.stdout.getvalue()
        self.assertTrue(stdout.find(dj_match) > -1)
        self.assertFalse(stdout.find("django-reversion") > -1)
        self.assertTrue(stdout.find("djangocms-text-ckeditor") > -1)
        self.assertTrue(stdout.find("djangocms-admin-style") > -1)
        self.assertTrue(stdout.find("djangocms-bootstrap4") > -1)
        self.assertTrue(stdout.find("djangocms-file") > -1)
        self.assertTrue(stdout.find("djangocms-flash") == -1)
        self.assertTrue(stdout.find("djangocms-googlemap") > -1)
        self.assertTrue(stdout.find("djangocms-inherit") == -1)
        self.assertTrue(stdout.find("djangocms-link") > -1)
        self.assertTrue(stdout.find("djangocms-picture") > -1)
        self.assertTrue(stdout.find("djangocms-style") > -1)
        self.assertTrue(stdout.find("cmsplugin-filer") == -1)
        self.assertTrue(stdout.find("djangocms-teaser") == -1)
        self.assertTrue(stdout.find("djangocms-video") > -1)
Beispiel #3
0
 def test_requirements_invocation(self):
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             sys.argv = ['main'] + [
                 '--db=sqlite://localhost/test.db', '-len',
                 '--cms-version=stable', '-R', '-q', '-u',
                 '-p' + self.project_dir, 'example_prj'
             ]
             main.execute()
     stdout = self.stdout.getvalue()
     if sys.version_info < (2, 7):
         self.assertTrue(stdout.find('Django<1.7') > -1)
         self.assertTrue(stdout.find('django-reversion>=1.8,<1.8.6') > -1)
     else:
         self.assertTrue(stdout.find('Django<1.9') > -1)
         self.assertTrue(stdout.find('django-reversion>=1.8.7') > -1)
     self.assertTrue(stdout.find('djangocms-text-ckeditor') > -1)
     self.assertTrue(stdout.find('djangocms-admin-style') > -1)
     self.assertTrue(stdout.find('djangocms-column') > -1)
     self.assertTrue(stdout.find('djangocms-file') > -1)
     self.assertTrue(stdout.find('djangocms-flash') == -1)
     self.assertTrue(stdout.find('djangocms-googlemap') > -1)
     self.assertTrue(stdout.find('djangocms-inherit') > -1)
     self.assertTrue(stdout.find('djangocms-link') > -1)
     self.assertTrue(stdout.find('djangocms-picture') > -1)
     self.assertTrue(stdout.find('djangocms-style') > -1)
     self.assertTrue(stdout.find('djangocms-teaser') > -1)
     self.assertTrue(stdout.find('djangocms-video') > -1)
Beispiel #4
0
 def test_requirements_invocation(self):
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             sys.argv = ['main'] + ['--db=sqlite://localhost/test.db',
                                    '-len', '--cms-version=stable', '-R',
                                    '-q', '-u', '-p'+self.project_dir,
                                    'example_prj']
             main.execute()
     stdout = self.stdout.getvalue()
     if sys.version_info < (2, 7):
         self.assertTrue(stdout.find('Django<1.7') > -1)
         self.assertTrue(stdout.find('django-reversion>=1.8,<1.8.6') > -1)
     else:
         self.assertTrue(stdout.find('Django<1.9') > -1)
         self.assertTrue(stdout.find('django-reversion>=1.8.7') > -1)
     self.assertTrue(stdout.find('djangocms-text-ckeditor') > -1)
     self.assertTrue(stdout.find('djangocms-admin-style') > -1)
     self.assertTrue(stdout.find('djangocms-column') > -1)
     self.assertTrue(stdout.find('djangocms-file') > -1)
     self.assertTrue(stdout.find('djangocms-flash') > -1)
     self.assertTrue(stdout.find('djangocms-googlemap') > -1)
     self.assertTrue(stdout.find('djangocms-inherit') > -1)
     self.assertTrue(stdout.find('djangocms-link') > -1)
     self.assertTrue(stdout.find('djangocms-picture') > -1)
     self.assertTrue(stdout.find('djangocms-style') > -1)
     self.assertTrue(stdout.find('djangocms-teaser') > -1)
     self.assertTrue(stdout.find('djangocms-video') > -1)
Beispiel #5
0
    def test_two_langs_invocation(self):
        dj_version, dj_match = get_stable_django()

        with patch("sys.stdout", self.stdout):
            with patch("sys.stderr", self.stderr):
                sys.argv = ["main"] + [
                    "--db=sqlite://localhost/test.db",
                    "-len-GB",
                    "-lfr-fr",
                    "--cms-version=stable",
                    "--verbose",
                    "--django=%s" % dj_version,
                    "-q",
                    "-u",
                    "-p" + self.project_dir,
                    "example_prj",
                ]
                try:
                    main.execute()
                    # Checking we successfully completed the whole process
                    self.assertTrue((
                        'Get into "%s" directory and type "python manage.py runserver" to start your project'
                        % self.project_dir) in self.stdout.getvalue())
                except Exception as e:
                    print(e)
Beispiel #6
0
 def test_cleanup(self):
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             with self.assertRaises((CalledProcessError, EnvironmentError)):
                 sys.argv = ['main'] + ['--db=postgres://user:pwd@host/dbname',
                                        '-len', '--no-db-driver',
                                        '-q', '-u', '-p'+self.project_dir,
                                        'example_prj']
                 main.execute()
     self.assertFalse(os.path.exists(self.project_dir))
Beispiel #7
0
 def test_two_langs_invocation(self):
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             sys.argv = ['main'] + ['--db=sqlite://localhost/test.db',
                                    '-len', '-lfr', '--cms-version=stable',
                                    '-q', '-u', '-p'+self.project_dir,
                                    'example_prj']
             main.execute()
             # Checking we successfully completed the whole process
             self.assertTrue(("Get into '%s' directory and type 'python manage.py runserver' to start your project" % self.project_dir) in self.stdout.getvalue())
Beispiel #8
0
 def test_develop(self):
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             sys.argv = ['main'] + ['--db=sqlite://localhost/test.db',
                                    '-len', '--cms-version=develop', '--django=%s' % dj_ver,
                                    '-q', '-u', '-p'+self.project_dir,
                                    'example_prj']
             main.execute()
             # Checking we successfully completed the whole process
             self.assertTrue(('Get into "%s" directory and type "python manage.py runserver" to start your project' % self.project_dir) in self.stdout.getvalue())
Beispiel #9
0
 def test_cleanup(self):
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             with self.assertRaises((CalledProcessError, EnvironmentError)):
                 sys.argv = ['main'] + ['--db=postgres://user:pwd@host/dbname',
                                        '-len', '--no-db-driver',
                                        '-q', '-u', '-p'+self.project_dir,
                                        'example_prj']
                 main.execute()
     self.assertFalse(os.path.exists(self.project_dir))
Beispiel #10
0
 def test_cleanup(self):
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             with self.assertRaises((CalledProcessError, EnvironmentError)):
                 sys.argv = ['main'] + ['--db=sqlite://localhost/test.db',
                                        '-len', '--cms-version=2.4',
                                        '--django=1.7',
                                        '-q', '-u', '-p'+self.project_dir,
                                        'example_prj']
                 main.execute()
     self.assertFalse(os.path.exists(self.project_dir))
Beispiel #11
0
 def test_two_langs_invocation(self):
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             sys.argv = ['main'] + ['--db=sqlite://localhost/test.db',
                                    '-len', '-lfr', '--cms-version=stable',
                                    '--django=%s' % dj_ver,
                                    '-q', '-u', '-p'+self.project_dir,
                                    'example_prj']
             main.execute()
             # Checking we successfully completed the whole process
             self.assertTrue(('Get into "%s" directory and type "python manage.py runserver" to start your project' % self.project_dir) in self.stdout.getvalue())
Beispiel #12
0
 def test_two_langs_invocation(self):
     dj_version, dj_match = get_latest_django(latest_stable=True)
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             sys.argv = ['main'] + ['--db=sqlite://localhost/test.db',
                                    '-len-GB', '-lfr-fr', '--cms-version=stable',
                                    '--django=%s' % dj_version,
                                    '-q', '-u', '-p'+self.project_dir,
                                    'example_prj']
             main.execute()
             # Checking we successfully completed the whole process
             self.assertTrue(('Get into "%s" directory and type "python manage.py runserver" to start your project' % self.project_dir) in self.stdout.getvalue())
Beispiel #13
0
 def test_no_cleanup(self):
     with patch("sys.stdout", self.stdout):
         with patch("sys.stderr", self.stderr):
             with self.assertRaises((CalledProcessError, EnvironmentError)):
                 sys.argv = ["main"] + [
                     "--db=postgres://user:pwd@host/dbname",
                     "-len",
                     "--no-db-driver",
                     "-q",
                     "-u",
                     "-p" + self.project_dir,
                     "example_prj",
                 ]
                 main.execute()
     self.assertTrue(os.path.exists(self.project_dir))
Beispiel #14
0
 def test_main_invocation(self):
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             sys.argv = ['main'] + ['--db=sqlite://localhost/test.db',
                                    '-len', '--cms-version=stable', '--django=%s' % dj_ver,
                                    '-q', '-u', '-p'+self.project_dir,
                                    'example_prj']
             main.execute()
             self.assertTrue(os.path.exists(os.path.join(self.project_dir, 'static')))
             self.assertTrue(os.path.exists(os.path.join(self.project_dir, 'requirements.txt')))
             self.assertTrue(os.path.exists(os.path.join(self.project_dir, 'example_prj', 'static')))
             with open(os.path.join(self.project_dir, 'requirements.txt'), 'r') as req_file:
                 text = req_file.read()
                 self.assertTrue(text.find('djangocms-text-ckeditor') > -1)
             # Checking we successfully completed the whole process
             self.assertTrue(('Get into "%s" directory and type "python manage.py runserver" to start your project' % self.project_dir) in self.stdout.getvalue())
Beispiel #15
0
 def test_noi18n_urls(self):
     base_dir = mkdtemp()
     project_dir = os.path.join(base_dir, 'example_prj')
     original_dir = os.getcwd()
     os.chdir(base_dir)
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             sys.argv = ['main'] + ['--i18n=no', 'example_prj']
             main.execute()
             self.assertTrue(
                 os.path.exists(
                     os.path.join(project_dir, 'example_prj', 'urls.py')))
             with open(os.path.join(project_dir, 'example_prj', 'urls.py'),
                       'r') as urls_file:
                 urls = urls_file.read()
                 self.assertTrue(
                     urls.find('urlpatterns += i18n_patterns(') == -1)
     os.chdir(original_dir)
     rmtree(base_dir)
Beispiel #16
0
 def test_main_invocation(self):
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             sys.argv = ['main'] + [
                 '--db=sqlite://localhost/test.db', '-len',
                 '--cms-version=stable',
                 '--django=%s' % dj_ver, '-q', '-u',
                 '-p' + self.project_dir, 'example_prj'
             ]
             main.execute()
             self.assertTrue(
                 os.path.exists(os.path.join(self.project_dir, 'static')))
             self.assertTrue(
                 os.path.exists(
                     os.path.join(self.project_dir, 'example_prj',
                                  'static')))
             # Checking we successfully completed the whole process
             self.assertTrue((
                 "Get into '%s' directory and type 'python manage.py runserver' to start your project"
                 % self.project_dir) in self.stdout.getvalue())
Beispiel #17
0
    def test_develop(self):
        dj_version, dj_match = get_stable_django(lts=True)

        with patch("sys.stdout", self.stdout):
            with patch("sys.stderr", self.stderr):
                sys.argv = ["main"] + [
                    "--db=sqlite://localhost/test.db",
                    "-len",
                    "--cms-version=develop",
                    "--django=%s" % dj_version,
                    "-q",
                    "-u",
                    "-p" + self.project_dir,
                    "example_prj",
                ]
                main.execute()
                # Checking we successfully completed the whole process
                self.assertTrue((
                    'Get into "%s" directory and type "python manage.py runserver" to start your project'
                    % self.project_dir) in self.stdout.getvalue())
Beispiel #18
0
 def manual_test_django_1_4(self):
     with patch("sys.stdout", self.stdout):
         with patch("sys.stderr", self.stderr):
             sys.argv = ["main"] + [
                 "--db=sqlite://localhost/test.db",
                 "-len",
                 "--django-version=1.4",
                 "-q",
                 "-u",
                 "-p" + self.project_dir,
                 "example_prj",
             ]
             main.execute()
             # Checking we successfully completed the whole process
             self.assertTrue(
                 (
                     "Get into '%s' directory and type 'python manage.py runserver' to start your project"
                     % self.project_dir
                 )
                 in self.stdout.getvalue()
             )
Beispiel #19
0
 def test_base_invocation(self):
     base_dir = mkdtemp()
     project_dir = os.path.join(base_dir, 'example_prj')
     original_dir = os.getcwd()
     os.chdir(base_dir)
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             sys.argv = ['main'] + ['example_prj']
             main.execute()
             self.assertTrue(os.path.exists(os.path.join(project_dir, 'static')))
             self.assertTrue(os.path.exists(os.path.join(project_dir, 'requirements.txt')))
             self.assertTrue(os.path.exists(os.path.join(project_dir, 'example_prj', 'static')))
             with open(os.path.join(project_dir, 'requirements.txt'), 'r') as req_file:
                 text = req_file.read()
                 self.assertTrue(text.find('djangocms-text-ckeditor') > -1)
             self.assertTrue(('Get into "%s" directory and type "python manage.py runserver" to start your project' % project_dir) in self.stdout.getvalue())
     os.chdir(project_dir)
     with patch('sys.stdout', self.stdout):
         out = subprocess.check_output(['sqlite3', 'project.db', 'SELECT COUNT(*) FROM auth_user WHERE username="******"'])
         self.assertEqual(binary_type(out), binary_type(b'1\n'))
     os.chdir(original_dir)
     rmtree(base_dir)
Beispiel #20
0
 def test_main_invocation(self):
     dj_version, dj_match = get_stable_django()
     base_dir = mkdtemp()
     project_dir = os.path.join(base_dir, "example_prj")
     original_dir = os.getcwd()
     os.chdir(base_dir)
     with patch("sys.stdout", self.stdout):
         with patch("sys.stderr", self.stderr):
             sys.argv = ["main"] + [
                 "--db=sqlite://localhost/test.db",
                 "-len",
                 "--cms-version=stable",
                 "--django=%s" % dj_version,
                 "-q",
                 "-u",
                 "--verbose",
                 "example_prj",
             ]
             main.execute()
             self.assertTrue(
                 os.path.exists(os.path.join(project_dir, "static")))
             self.assertTrue(
                 os.path.exists(
                     os.path.join(project_dir, "requirements.txt")))
             self.assertTrue(
                 os.path.exists(
                     os.path.join(project_dir, "example_prj", "static")))
             with open(os.path.join(project_dir,
                                    "requirements.txt")) as req_file:
                 text = req_file.read()
                 self.assertTrue(text.find("djangocms-text-ckeditor") > -1)
             # Checking we successfully completed the whole process
             self.assertTrue(
                 "Successfully installed " in self.stdout.getvalue())
             self.assertTrue((
                 'Get into "%s" directory and type "python manage.py runserver" to start your project'
                 % project_dir) in self.stdout.getvalue())
     os.chdir(original_dir)
     rmtree(base_dir)
Beispiel #21
0
 def test_noi18n_urls(self):
     base_dir = mkdtemp()
     project_dir = os.path.join(base_dir, 'example_prj')
     original_dir = os.getcwd()
     os.chdir(base_dir)
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             sys.argv = ['main'] + ['--i18n=no', 'example_prj']
             main.execute()
             self.assertTrue(
                 os.path.exists(
                     os.path.join(project_dir, 'example_prj', 'urls.py')
                 )
             )
             with open(os.path.join(project_dir, 'example_prj', 'urls.py'),
                       'r') as urls_file:
                 urls = urls_file.read()
                 self.assertTrue(
                     urls.find('urlpatterns += i18n_patterns(') == -1
                 )
     os.chdir(original_dir)
     rmtree(base_dir)
Beispiel #22
0
 def test_noi18n_urls(self):
     base_dir = mkdtemp()
     project_dir = os.path.join(base_dir, "example_prj")
     original_dir = os.getcwd()
     os.chdir(base_dir)
     with patch("sys.stdout", self.stdout):
         with patch("sys.stderr", self.stderr):
             sys.argv = ["main"] + [
                 "--i18n=no",
                 "--cms-version=stable",
                 "example_prj",
             ]
             main.execute()
             self.assertTrue(
                 os.path.exists(
                     os.path.join(project_dir, "example_prj", "urls.py")))
             with open(os.path.join(project_dir, "example_prj",
                                    "urls.py")) as urls_file:
                 urls = urls_file.read()
                 self.assertTrue(
                     urls.find("urlpatterns += i18n_patterns(") == -1)
     os.chdir(original_dir)
     rmtree(base_dir)
Beispiel #23
0
 def test_main_invocation(self):
     with patch("sys.stdout", self.stdout):
         with patch("sys.stderr", self.stderr):
             sys.argv = ["main"] + [
                 "--db=sqlite://localhost/test.db",
                 "-len",
                 "--cms-version=develop",
                 "-q",
                 "-u",
                 "-p" + self.project_dir,
                 "example_prj",
             ]
             main.execute()
             self.assertTrue(os.path.exists(os.path.join(self.project_dir, "static")))
             self.assertTrue(os.path.exists(os.path.join(self.project_dir, "example_prj", "static")))
             # Checking we successfully completed the whole process
             self.assertTrue(
                 (
                     "Get into '%s' directory and type 'python manage.py runserver' to start your project"
                     % self.project_dir
                 )
                 in self.stdout.getvalue()
             )
Beispiel #24
0
 def test_main_invocation(self):
     dj_version, dj_match = get_latest_django(latest_stable=True)
     base_dir = mkdtemp()
     project_dir = os.path.join(base_dir, 'example_prj')
     original_dir = os.getcwd()
     os.chdir(base_dir)
     with patch('sys.stdout', self.stdout):
         with patch('sys.stderr', self.stderr):
             sys.argv = ['main'] + ['--db=sqlite://localhost/test.db',
                                    '-len', '--cms-version=stable', '--django=%s' % dj_version,
                                    '-q', '-u', '--verbose',
                                    'example_prj']
             main.execute()
             self.assertTrue(os.path.exists(os.path.join(project_dir, 'static')))
             self.assertTrue(os.path.exists(os.path.join(project_dir, 'requirements.txt')))
             self.assertTrue(os.path.exists(os.path.join(project_dir, 'example_prj', 'static')))
             with open(os.path.join(project_dir, 'requirements.txt'), 'r') as req_file:
                 text = req_file.read()
                 self.assertTrue(text.find('djangocms-text-ckeditor') > -1)
             # Checking we successfully completed the whole process
             self.assertTrue('Successfully installed ' in self.stdout.getvalue())
             self.assertTrue(('Get into "%s" directory and type "python manage.py runserver" to start your project' % project_dir) in self.stdout.getvalue())
     os.chdir(original_dir)
     rmtree(base_dir)