Skip to content

Commit e8b22a9

Browse files
committed
tests for 21 passing, such as they are
1 parent 5ea71f6 commit e8b22a9

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

chapter_21_server_side_debugging.asciidoc

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -665,16 +665,16 @@ cryptographically valid for the server:
665665
[source,python]
666666
----
667667
def _get_server_env_vars(host):
668-
env_lines = run(f'cat ~/sites/{host}/.env').splitlines() #<1>
669-
return dict(l.split('=') for l in env_lines if l)
668+
env_lines = run(f"cat ~/sites/{host}/.env").splitlines() # <1>
669+
return dict(l.split("=") for l in env_lines if l)
670670
671671
672672
def create_session_on_server(host, email):
673673
manage_dot_py = _get_manage_dot_py(host)
674-
with settings(host_string=f'elspeth@{host}'):
674+
with settings(host_string=f"elspeth@{host}"):
675675
env_vars = _get_server_env_vars(host)
676-
with shell_env(**env_vars): #<2>
677-
session_key = run(f'{manage_dot_py} create_session {email}') #<3>
676+
with shell_env(**env_vars): # <2>
677+
session_key = run(f"{manage_dot_py} create_session {email}") # <3>
678678
return session_key.strip()
679679
----
680680
====
@@ -735,6 +735,7 @@ In any case, let's see if it works. First, locally, to check that we didn't
735735
break anything:
736736

737737

738+
[role="dofirst-ch21l022"]
738739
[subs="specialcharacters,macros"]
739740
----
740741
$ pass:quotes[*python src/manage.py test functional_tests.test_my_lists*]
@@ -833,8 +834,8 @@ Before we finish, let's update our deployment fabfile so that it can
833834
automatically add the `EMAIL_PASSWORD` to the _.env_ file on the server:
834835

835836

836-
[role="sourcecode dofirst-ch21l022"]
837-
.deploy_tools/fabfile.py (ch18l021)
837+
[role="sourcecode skipme"]
838+
.src/deploy_tools/fabfile.py (ch18l021)
838839
====
839840
[source,python]
840841
----
@@ -843,16 +844,16 @@ import os
843844
844845
845846
def _create_or_update_dotenv():
846-
append('.env', 'DJANGO_DEBUG_FALSE=y')
847-
append('.env', f'SITENAME={env.host}')
848-
current_contents = run('cat .env')
849-
if 'DJANGO_SECRET_KEY' not in current_contents:
850-
new_secret = ''.join(random.SystemRandom().choices(
851-
'abcdefghijklmnopqrstuvwxyz0123456789', k=50
852-
))
853-
append('.env', f'DJANGO_SECRET_KEY={new_secret}')
854-
email_password = os.environ['EMAIL_PASSWORD'] #<1>
855-
append('.env', f'EMAIL_PASSWORD={email_password}') #<1>
847+
append(".env", "DJANGO_DEBUG_FALSE=y")
848+
append(".env", f"SITENAME={env.host}")
849+
current_contents = run("cat .env")
850+
if "DJANGO_SECRET_KEY" not in current_contents:
851+
new_secret = "".join(
852+
random.SystemRandom().choices("abcdefghijklmnopqrstuvwxyz0123456789", k=50)
853+
)
854+
append(".env", f"DJANGO_SECRET_KEY={new_secret}")
855+
email_password = os.environ["EMAIL_PASSWORD"] # <1>
856+
append(".env", f"EMAIL_PASSWORD={email_password}") # <1>
856857
----
857858
====
858859

tests/test_chapter_21_server_side_debugging.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_listings_and_commands_and_output(self):
6262

6363
self.sourcetree.tidy_up_after_patches()
6464
self.sourcetree.run_command('git add . && git commit -m"final commit ch17"')
65-
self.check_final_diff(ignore=["moves"])
65+
self.check_final_diff(ignore=["moves", "YAHOO_PASSWORD"])
6666
# if DO_SERVER_COMMANDS:
6767
# subprocess.check_call(["vagrant", "snapshot", "save", "SERVER_DEBUGGED"])
6868

0 commit comments

Comments
 (0)