Merge lp:~stevanr/linaro-license-protection/howto_refined_search into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Stevan Radaković
Status: Merged
Merged at revision: 149
Proposed branch: lp:~stevanr/linaro-license-protection/howto_refined_search
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 84 lines (+52/-0)
2 files modified
license_protected_downloads/render_text_files.py (+29/-0)
license_protected_downloads/tests/test_views.py (+23/-0)
To merge this branch: bzr merge lp:~stevanr/linaro-license-protection/howto_refined_search
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Review via email: mp+135472@code.launchpad.net

Description of the change

Add support for howto/HOWTO_* files and target/product/*/howto/HOWTO_* files.

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

Looks good, thanks for the fix: please make new test methods though.

review: Needs Fixing
150. By Stevan Radaković

Remove redundant tests. Add test method instead.

151. By Stevan Radaković

Split test method.

Revision history for this message
Данило Шеган (danilo) wrote :

Excellent, looks great. Thanks again.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'license_protected_downloads/render_text_files.py'
2--- license_protected_downloads/render_text_files.py 2012-10-24 16:08:44 +0000
3+++ license_protected_downloads/render_text_files.py 2012-11-21 18:00:29 +0000
4@@ -4,6 +4,10 @@
5 from django.conf import settings
6
7
8+HOWTO_PATH = "howto"
9+HOWTO_PRODUCT_PATH = "target/product"
10+
11+
12 class MultipleFilesException(Exception):
13 pass
14
15@@ -61,6 +65,14 @@
16 # LINUX_FILES exist in the same dir.
17
18 androidpaths = cls.dirEntries(path, files_list=settings.ANDROID_FILES)
19+
20+ howto_path = os.path.join(path, HOWTO_PATH)
21+ howto_product_path = cls.getHowtoProductPath(path)
22+ androidpaths += cls.dirEntries(howto_path,
23+ files_list=settings.ANDROID_FILES)
24+ androidpaths += cls.dirEntries(howto_product_path,
25+ files_list=settings.ANDROID_FILES)
26+
27 ubuntupaths = cls.dirEntries(path, files_list=settings.LINUX_FILES)
28 if len(androidpaths) > 0 and len(ubuntupaths) > 0:
29 # Files from ANDROID_FILES and LINUX_FILES exist in the same dir
30@@ -127,3 +139,20 @@
31 # hence there is an out of range exception
32 except IndexError:
33 return indices
34+
35+ @classmethod
36+ def getHowtoProductPath(cls, path):
37+ """ Return the 'target/product/*/howto/ path.
38+
39+ In case there is no such folder, return empty string.
40+ """
41+ howto_path = ""
42+ path = os.path.join(path, HOWTO_PRODUCT_PATH)
43+ if os.path.exists(path):
44+ for file in os.listdir(path):
45+ product_path = os.path.join(path, file)
46+ if os.path.isdir(product_path):
47+ howto_path = os.path.join(product_path, HOWTO_PATH)
48+ break
49+
50+ return howto_path
51
52=== modified file 'license_protected_downloads/tests/test_views.py'
53--- license_protected_downloads/tests/test_views.py 2012-11-07 18:13:07 +0000
54+++ license_protected_downloads/tests/test_views.py 2012-11-21 18:00:29 +0000
55@@ -730,6 +730,29 @@
56 self.assertEqual(response.status_code, 200)
57 self.assertContains(response, 'howto')
58
59+ def test_howtos_howto_dir(self):
60+ with temporary_directory() as serve_root:
61+ settings.SERVED_PATHS = [serve_root.root]
62+ serve_root.make_file(
63+ "build/9/build.tar.bz2", with_buildinfo=True)
64+ serve_root.make_file(
65+ "build/9/howto/HOWTO_releasenotes.txt", data=".h1 HowTo Test")
66+ response = self.client.get('/build/9/howto/')
67+ self.assertEqual(response.status_code, 200)
68+ self.assertContains(response, 'HowTo Test')
69+
70+ def test_howtos_product_dir(self):
71+ with temporary_directory() as serve_root:
72+ settings.SERVED_PATHS = [serve_root.root]
73+ serve_root.make_file(
74+ "build/9/build.tar.bz2", with_buildinfo=True)
75+ serve_root.make_file(
76+ "build/9/target/product/panda/howto/HOWTO_releasenotes.txt",
77+ data=".h1 HowTo Test")
78+ response = self.client.get('/build/9/target/product/panda/howto/')
79+ self.assertEqual(response.status_code, 200)
80+ self.assertContains(response, 'HowTo Test')
81+
82
83 if __name__ == '__main__':
84 unittest.main()

Subscribers

People subscribed via source and target branches