Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: tests/test_generate_pages.py

Issue 29887585: Issue #5352 - generate_static_pages cannot deal with directories being turned into regular pages (Closed)
Patch Set: Created Sept. 21, 2018, 1:35 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/test_generate_pages.py
diff --git a/tests/test_generate_pages.py b/tests/test_generate_pages.py
new file mode 100644
index 0000000000000000000000000000000000000000..34ec3b3c2a403e3e2406d7730c90f8defdbf99ef
--- /dev/null
+++ b/tests/test_generate_pages.py
@@ -0,0 +1,60 @@
+# This file is part of the Adblock Plus web scripts,
Vasily Kuznetsov 2018/09/24 11:58:47 This file contains the tests specifically for this
Tudor Avram 2018/09/24 16:10:00 Done.
+# Copyright (C) 2006-present eyeo GmbH
+#
+# Adblock Plus is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3 as
+# published by the Free Software Foundation.
+#
+# Adblock Plus is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+import pytest
Vasily Kuznetsov 2018/09/24 11:58:47 The import order should be stdlib, 3-rd party libs
Tudor Avram 2018/09/24 14:04:51 Done.
+
+import os
+
+
+@pytest.fixture(scope='session')
+def target_dir_with_file(temp_site):
Vasily Kuznetsov 2018/09/24 11:58:47 Here and in the following fixture, it seems like y
Tudor Avram 2018/09/24 14:04:51 Done.
+ target_dir = os.path.join(os.path.dirname(temp_site), 'out_file')
+ os.makedirs(os.path.join(target_dir, 'en'))
+
+ with open(os.path.join(target_dir, 'en', 'foo'), 'w') as f:
+ f.write('test\n')
+
+ yield target_dir
+
+
+@pytest.fixture(scope='session')
+def target_dir_with_dir(temp_site):
+ target_dir = os.path.join(os.path.dirname(temp_site), 'out_dir')
+ os.makedirs(os.path.join(target_dir, 'en', 'translate'))
+
+ yield target_dir
+
+
+@pytest.mark.script_launch_mode('subprocess')
+def test_generate_dir_instead_of_file(temp_site, target_dir_with_file,
+ script_runner):
+ cmd = ['python', '-m', 'cms.bin.generate_static_pages', str(temp_site),
+ str(target_dir_with_file)]
+
+ script_runner.run(*cmd)
+
+ print(os.listdir(os.path.join(target_dir_with_file, 'en', 'foo')))
Vasily Kuznetsov 2018/09/24 11:58:47 Do we need this print once the test is passing?
Tudor Avram 2018/09/24 14:04:51 oops, no. Forgot to remove it. Done.
+
+ assert os.path.isdir(os.path.join(target_dir_with_file, 'en', 'foo'))
+
+
+@pytest.mark.script_launch_mode('subprocess')
+def test_generate_file_instead_of_dir(temp_site, target_dir_with_dir,
+ script_runner):
+ cmd = ['python', '-m', 'cms.bin.generate_static_pages', str(temp_site),
+ str(target_dir_with_dir)]
+
+ script_runner.run(*cmd)
+
+ assert os.path.isfile(os.path.join(target_dir_with_dir, 'en', 'translate'))

Powered by Google App Engine
This is Rietveld