Esempio n. 1
0
    def test_remove_static_adds_static_paths_if_missing(self):
        """
        tests that remove_static adds static paths if missing and writes to log
        """
        serve_django_static = ServeStatic(
            self.dist_version, self.app_home, self.log_file, self.log_level, git_repo=self.git_repo
        )
        serve_django_static.remove_static(self.down_path, self.static_path, self.media_path, self.uwsgi_path)

        fds = [self.down_path, self.static_path, self.media_path, self.uwsgi_path]
        for f in fds:
            self.assertTrue(os.path.exists(f), "%s not present" % f)
            self.log("INFO: added missing path %s" % f)
Esempio n. 2
0
    def test_remove_static(self, own_app_mock, clone_app_mock):
        """
        tests that remove_static removes the static directories and files, writes to log
        """
        user = "******"
        os.makedirs(self.static_path)
        os.makedirs(self.media_path)
        os.makedirs(self.uwsgi_path)
        os.makedirs(self.down_path)
        os.makedirs(os.path.join(self.app_home, self.app_name, self.app_name))
        os.makedirs(os.path.join(os.path.dirname(self.app_home), "conf.d"))
        conf = [
            {"file": "settings.json", "move_to": os.path.join(self.app_home, self.app_name)},
            {"file": "settings_admin.py", "move_to": os.path.join(self.app_home, self.app_name, self.app_name)},
            {"file": "%s_uwsgi.ini" % self.app_name, "move_to": self.app_home},
        ]
        for f in conf:
            with open(os.path.join(os.path.dirname(self.app_home), "conf.d", f["file"]), "w") as config:
                config.write("%s file\n" % f["file"])
        if self.dist_version == "14.04":
            self.python_version = "python3.4"
        elif self.dist_version == "16.04":
            self.python_version = "python3.5"
        os.makedirs(os.path.join(self.venv, "lib", self.python_version, "site-packages"))

        serve_django_static = ServeStatic(
            self.dist_version,
            self.app_home,
            self.log_file,
            self.log_level,
            git_repo=self.git_repo,
            sys_deps_file=self.sys_deps_file,
            reqs_file=self.reqs_file,
            venv=self.venv,
        )
        serve_django_static.serve_static(user, user, self.down_path, self.static_path, self.media_path, self.uwsgi_path)

        serve_django_static.remove_static(self.down_path, self.static_path, self.media_path, self.uwsgi_path)

        fds = [
            {"path": self.down_path, "file": "index.html"},
            {"path": self.static_path, "file": "static_file"},
            {"path": self.media_path, "file": "media_file"},
            {"path": self.uwsgi_path, "file": "uwsgi_params"},
        ]
        for f in fds:
            self.assertTrue(os.path.exists(f["path"]), "%s was removed" % f["path"])
            self.assertFalse(os.path.exists(os.path.join(f["path"], f["file"])), "%s was not removed" % f["file"])
            self.log("INFO: removed files in %s" % f["path"])