Skip to content

Commit 0d98835

Browse files
committed
token attempt at getting tests working
1 parent 5b4f384 commit 0d98835

File tree

2 files changed

+29
-35
lines changed

2 files changed

+29
-35
lines changed

chapter_21_server_side_debugging.asciidoc

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,10 @@ Let's try to deploy our site.
2828
Along the way we'll catch an unexpected bug (that's what staging is for!),
2929
and then we'll have to figure out a way of managing the database on the test server:
3030

31-
* TODO: ansible instead of fab
32-
3331
[role="against-server small-code"]
3432
[subs="specialcharacters,quotes"]
3533
----
3634
$ pass:quotes[*ansible-playbook --user=elspeth -i staging.ottg.co.uk, infra/ansible-provision.yaml -vv*]
37-
$ *fab deploy:[email protected]*
3835
3936
PLAYBOOK: ansible-provision.yaml ***********************************************
4037
1 plays in infra/ansible-provision.yaml
@@ -47,7 +44,7 @@ Here's what happens when we run the functional tests:
4744
[role="small-code"]
4845
[subs="specialcharacters,macros"]
4946
----
50-
$ pass:quotes[*TEST_SERVER=staging.ottg.co.uk python manage.py test functional_tests*]
47+
$ pass:quotes[*TEST_SERVER=staging.ottg.co.uk python src/manage.py test functional_tests*]
5148
5249
======================================================================
5350
ERROR: test_logged_in_users_lists_are_saved_as_my_lists
@@ -179,7 +176,7 @@ Now if we rerun our FTs, we see a change:
179176
[role="small-code"]
180177
[subs="specialcharacters,macros"]
181178
----
182-
$ pass:quotes[*TEST_SERVER=staging.ottg.co.uk python manage.py test functional_tests*]
179+
$ pass:quotes[*TEST_SERVER=staging.ottg.co.uk python src/manage.py test functional_tests*]
183180
184181
[...]
185182
Traceback (most recent call last):
@@ -390,7 +387,7 @@ that can actually check for logins that work, involving real emails!
390387
[role="small-code"]
391388
[subs="specialcharacters,macros"]
392389
----
393-
$ pass:quotes[*TEST_SERVER=staging.ottg.co.uk python manage.py test functional_tests.test_login*]
390+
$ pass:quotes[*TEST_SERVER=staging.ottg.co.uk python src/manage.py test functional_tests.test_login*]
394391
[...]
395392
OK
396393
----
@@ -420,7 +417,7 @@ so the "My Lists" test fails:
420417
[role="skipme small-code"]
421418
[subs="specialcharacters,macros"]
422419
----
423-
$ pass:quotes[*TEST_SERVER=staging.ottg.co.uk python manage.py test functional_tests*]
420+
$ pass:quotes[*TEST_SERVER=staging.ottg.co.uk python src/manage.py test functional_tests*]
424421
425422
ERROR: test_logged_in_users_lists_are_saved_as_my_lists
426423
(functional_tests.test_my_lists.MyListsTest)
@@ -511,7 +508,7 @@ and the management command prints it out at the command line. Try it out:
511508
[role="skipme"]
512509
[subs="specialcharacters,macros"]
513510
----
514-
$ pass:quotes[*python manage.py create_session [email protected]*]
511+
$ pass:quotes[*python src/manage.py create_session [email protected]*]
515512
Unknown command: 'create_session'
516513
----
517514

@@ -539,7 +536,7 @@ Now it works:
539536

540537
[subs="specialcharacters,macros"]
541538
----
542-
$ pass:quotes[*python manage.py create_session [email protected]*]
539+
$ pass:quotes[*python src/manage.py create_session [email protected]*]
543540
qnslckvp2aga7tm6xuivyb0ob1akzzwl
544541
----
545542

@@ -739,21 +736,19 @@ break anything:
739736

740737
[subs="specialcharacters,macros"]
741738
----
742-
$ pass:quotes[*python manage.py test functional_tests.test_my_lists*]
739+
$ pass:quotes[*python src/manage.py test functional_tests.test_my_lists*]
743740
[...]
744741
OK
745742
----
746743

747744

748-
Next, against the server. We push our code up first:
745+
Next, against the server.
749746

750747

751748
[role="against-server"]
752749
[subs="specialcharacters,quotes"]
753750
----
754-
$ *git push* # you'll need to commit changes first.
755-
$ *cd deploy_tools*
756-
$ *fab deploy [email protected]*
751+
$ pass:quotes[*ansible-playbook --user=elspeth -i staging.ottg.co.uk, infra/ansible-provision.yaml -vv*]
757752
----
758753

759754
And now we run the test:
@@ -762,7 +757,7 @@ And now we run the test:
762757
[role="against-server small-code"]
763758
[subs=""]
764759
----
765-
$ <strong>TEST_SERVER=staging.ottg.co.uk python manage.py test \
760+
$ <strong>TEST_SERVER=staging.ottg.co.uk python src/manage.py test \
766761
functional_tests.test_my_lists</strong>
767762
[...]
768763
@@ -785,7 +780,7 @@ Looking good! We can rerun all the tests to make sure...
785780
[role="against-server small-code"]
786781
[subs=""]
787782
----
788-
$ <strong>TEST_SERVER=staging.ottg.co.uk python manage.py test functional_tests</strong>
783+
$ <strong>TEST_SERVER=staging.ottg.co.uk python src/manage.py test functional_tests</strong>
789784
[...]
790785
791786
~/sites/staging.ottg.co.uk/.venv/bin/python

tests/test_chapter_21_server_side_debugging.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,22 @@ def test_listings_and_commands_and_output(self):
1818
self.assertEqual(self.listings[1].type, "output")
1919

2020
# skips
21-
self.skip_with_check(1, "if you haven't already")
22-
self.skip_with_check(45, "commit changes first")
21+
# self.skip_with_check(45, "commit changes first")
2322
if DO_SERVER_COMMANDS:
2423
self.replace_command_with_check(
2524
13,
2625
"EMAIL_PASSWORD=yoursekritpasswordhere",
2726
"EMAIL_PASSWORD=" + os.environ["EMAIL_PASSWORD"],
2827
)
2928

30-
fab_deploy_pos = 49
31-
assert "fab deploy" in self.listings[fab_deploy_pos]
29+
# deploy_pos = 49
30+
# assert "ansible-playbook" in self.listings[deploy_pos]
3231

3332
# prep
3433
self.start_with_checkout()
3534
self.prep_database()
3635

37-
vm_restore = "FABRIC_END"
36+
# vm_restore = "FABRIC_END"
3837

3938
# hack fast-forward
4039
if os.environ.get("SKIP"):
@@ -43,30 +42,30 @@ def test_listings_and_commands_and_output(self):
4342
"git checkout {}".format(self.sourcetree.get_commit_spec("ch17l004"))
4443
)
4544

46-
if DO_SERVER_COMMANDS:
47-
subprocess.check_call(["vagrant", "snapshot", "restore", vm_restore])
45+
# if DO_SERVER_COMMANDS:
46+
# subprocess.check_call(["vagrant", "snapshot", "restore", vm_restore])
4847

4948
while self.pos < len(self.listings):
5049
print(self.pos)
51-
if self.pos == fab_deploy_pos + 1 and DO_SERVER_COMMANDS:
52-
print("hacking in code update on server")
53-
self.run_server_command(
54-
"cd /home/elspeth/sites/staging.ottg.co.uk"
55-
" && git checkout chapter_21_server_side_debugging"
56-
" && git reset --hard origin/chapter_21_server_side_debugging",
57-
)
58-
self.run_server_command(
59-
"sudo systemctl restart gunicorn-staging.ottg.co.uk"
60-
)
50+
# if self.pos == deploy_pos + 1 and DO_SERVER_COMMANDS:
51+
# print("hacking in code update on server")
52+
# self.run_server_command(
53+
# "cd /home/elspeth/sites/staging.ottg.co.uk"
54+
# " && git checkout chapter_21_server_side_debugging"
55+
# " && git reset --hard origin/chapter_21_server_side_debugging",
56+
# )
57+
# self.run_server_command(
58+
# "sudo systemctl restart gunicorn-staging.ottg.co.uk"
59+
# )
6160
self.recognise_listing_and_process_it()
6261

6362
self.assert_all_listings_checked(self.listings)
6463

6564
self.sourcetree.tidy_up_after_patches()
6665
self.sourcetree.run_command('git add . && git commit -m"final commit ch17"')
6766
self.check_final_diff(ignore=["moves"])
68-
if DO_SERVER_COMMANDS:
69-
subprocess.check_call(["vagrant", "snapshot", "save", "SERVER_DEBUGGED"])
67+
# if DO_SERVER_COMMANDS:
68+
# subprocess.check_call(["vagrant", "snapshot", "save", "SERVER_DEBUGGED"])
7069

7170

7271
if __name__ == "__main__":

0 commit comments

Comments
 (0)