Apply consistent Python and Django coding standards
This commit is contained in:
1 parent
1d0b5adeee
commit
d7314fa927
61 files changed
+1829
-603
No files matched your search
@@ -22,34 +22,66 @@ class DirectAdminWebRestoreTests(SimpleTestCase):
|
||||
self.state = root / "state"
|
||||
self.state.mkdir()
|
||||
self.marker = self.state / "42.json"
|
||||
self.marker.write_text(json.dumps(self.site.manifest()), encoding="utf-8")
|
||||
self.marker.write_text(
|
||||
json.dumps(self.site.manifest()), encoding="utf-8"
|
||||
)
|
||||
(self.state / "apply.lock").touch()
|
||||
self.account = root / "web/42"
|
||||
self.public = self.account / "public"
|
||||
self.public.mkdir(parents=True)
|
||||
self.enterContext(patch("coulobre.web_node_apply.STATE_DIRECTORY", self.state))
|
||||
self.enterContext(
|
||||
patch("coulobre.web_node_apply.STATE_DIRECTORY", self.state)
|
||||
)
|
||||
self.enterContext(
|
||||
patch("coulobre.web_node_apply.WEB_ROOT", self.account.parent)
|
||||
)
|
||||
self.enterContext(patch("coulobre.web_node_restore.os.geteuid", return_value=0))
|
||||
self.enterContext(patch("coulobre.web_node_apply.require_root_directory"))
|
||||
self.enterContext(
|
||||
patch("coulobre.web_node_apply.read_root_file", side_effect=Path.read_text)
|
||||
patch("coulobre.web_node_restore.os.geteuid", return_value=0)
|
||||
)
|
||||
self.enterContext(
|
||||
patch("coulobre.web_node_apply.require_root_directory")
|
||||
)
|
||||
self.enterContext(
|
||||
patch(
|
||||
"coulobre.web_node_apply.read_root_file",
|
||||
side_effect=Path.read_text,
|
||||
)
|
||||
)
|
||||
self.installation = self.enterContext(
|
||||
patch("coulobre.web_node_apply.check_installation", return_value=(1001, 33))
|
||||
patch(
|
||||
"coulobre.web_node_apply.check_installation",
|
||||
return_value=(1001, 33),
|
||||
)
|
||||
)
|
||||
self.owner = self.enterContext(
|
||||
patch("coulobre.web_node_restore.os.chown")
|
||||
)
|
||||
self.owner = self.enterContext(patch("coulobre.web_node_restore.os.chown"))
|
||||
|
||||
entries = [
|
||||
("backup/user.conf", b"username=client\ndomain=example.net\n", 0o600),
|
||||
(
|
||||
"backup/user.conf",
|
||||
b"username=client\ndomain=example.net\n",
|
||||
0o600,
|
||||
),
|
||||
("domains/example.net/public_html/index.php", b"demo", 0o755),
|
||||
("domains/example.net/public_html/.env", b"private", 0o644),
|
||||
("domains/example.net/public_html/app.ini", b"private", 0o600),
|
||||
("domains/example.net/public_html/assets/site.css", b"assets", 0o644),
|
||||
("domains/example.net/public_html/.secret/hidden.txt", b"private", 0o644),
|
||||
(
|
||||
"domains/example.net/public_html/assets/site.css",
|
||||
b"assets",
|
||||
0o644,
|
||||
),
|
||||
(
|
||||
"domains/example.net/public_html/.secret/hidden.txt",
|
||||
b"private",
|
||||
0o644,
|
||||
),
|
||||
("domains/example.net/public_html/logs", None, 0o700),
|
||||
("domains/example.net/public_html/logs/app.log", b"private", 0o644),
|
||||
(
|
||||
"domains/example.net/public_html/logs/app.log",
|
||||
b"private",
|
||||
0o644,
|
||||
),
|
||||
("domains/other.example/public_html/index.php", b"other", 0o644),
|
||||
]
|
||||
tar = BytesIO()
|
||||
@@ -124,7 +156,8 @@ class DirectAdminWebRestoreTests(SimpleTestCase):
|
||||
|
||||
with (
|
||||
patch(
|
||||
"coulobre.web_node_restore.copy_website", side_effect=write_to_live_root
|
||||
"coulobre.web_node_restore.copy_website",
|
||||
side_effect=write_to_live_root,
|
||||
),
|
||||
self.assertRaisesRegex(ValueError, "empty document root"),
|
||||
):
|
||||
@@ -149,7 +182,8 @@ class DirectAdminWebRestoreTests(SimpleTestCase):
|
||||
|
||||
def test_restore_checks_manifest_against_registered_site_first(self):
|
||||
self.marker.write_text(
|
||||
json.dumps(WebSite(42, "different.example").manifest()), encoding="utf-8"
|
||||
json.dumps(WebSite(42, "different.example").manifest()),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "different manifest"):
|
||||
|
||||
Reference in new issue
Block a user