def setUp(self):
     self.dist_version = DIST_VERSION
     self.log_file = LOG_FILE
     self.log_level = LOG_LEVEL
     if os.path.exists(self.log_file):
         os.remove(self.log_file)
     remove_test_dir()
Пример #2
0
 def test_site_toggle_up(self):
     """
     tests that site_toggle_up_down removes the site_down.conf file from enabled sites, links the site.conf file to enabled
     sites and restarts nginx
     """
     self.make_site_confs("down")
     serve_django_static = ServeStatic(
         self.dist_version,
         self.app_home,
         self.log_file,
         self.log_level,
         git_repo=self.git_repo,
         nginx_conf=self.nginx_conf,
     )
     if self.dist_version == "14.04":
         cmd = ["service", "nginx", "restart"]
     elif self.dist_version == "16.04":
         cmd = ["systemctl", "restart", "nginx"]
     msg = "%s is up" % self.app_name
     func = "site_down"
     args = ("up",)
     self.run_success([cmd], [msg], func, serve_django_static.site_toggle_up_down, args)
     self.assertTrue(os.path.islink(os.path.join(self.nginx_conf, "sites-enabled", "%s.conf" % self.app_name)))
     self.assertFalse(os.path.isfile(os.path.join(self.nginx_conf, "sites-enabled", "%s_down.conf" % self.app_name)))
     remove_test_dir()
     self.make_site_confs("down")
     self.run_error(cmd, func, serve_django_static.site_toggle_up_down, args)
Пример #3
0
 def setUp(self):
     self.dist_version = DIST_VERSION
     self.log_file = LOG_FILE
     self.log_level = LOG_LEVEL
     if self.dist_version == '14.04':
         self.run = subprocess.check_call
         subprocess.check_call = MagicMock()
     elif self.dist_version == '16.04':
         self.run = subprocess.run
         subprocess.run = MagicMock()
     if os.path.isfile(self.log_file):
         os.remove(self.log_file)
     remove_test_dir()
Пример #4
0
 def test_remove_test_dir_handles_nested_permission_errors(self):
     os.makedirs(os.path.join(TEST_DIR, 'dir1', 'dir2', 'dir3'))
     os.chmod(os.path.join(TEST_DIR, 'dir1', 'dir2'), stat.S_IWUSR)
     remove_test_dir()
     self.assertFalse(os.path.exists(TEST_DIR))
Пример #5
0
 def test_remove_test_dir_handles_permission_errors(self):
     os.makedirs(TEST_DIR)
     os.chmod(TEST_DIR, stat.S_IWUSR)
     remove_test_dir()
     self.assertFalse(os.path.exists(TEST_DIR))
Пример #6
0
 def test_remove_test_dir_handles_file_not_found_errors(self):
     remove_test_dir()
     self.assertFalse(os.path.exists(TEST_DIR))
Пример #7
0
 def test_remove_test_dir(self):
     os.makedirs(TEST_DIR, exist_ok=True)
     remove_test_dir()
     self.assertFalse(os.path.exists(TEST_DIR))