[#1532] ticket:50 fix test case
diff --git a/Allura/allura/templates/widgets/project_summary.html b/Allura/allura/templates/widgets/project_summary.html
index 83c3234..6cb9839 100644
--- a/Allura/allura/templates/widgets/project_summary.html
+++ b/Allura/allura/templates/widgets/project_summary.html
@@ -1,17 +1,17 @@
{% if display_mode == 'list' %}
<div class="list card{% if show_proj_icon%} proj_icon{% endif %}"
{%- if columns == 2 %} style="width: 330px"{% elif columns == 3 %} style="width: 220px"{% endif %}>
- {% if show_proj_icon == True and icon_url %}
- {% if accolades and show_awards_banner == True %}
+ {% if accolades and show_awards_banner == True %}
<div class="box notch sponsor">
<div class="feature">{{accolades[0].award.short}}</div>
- <img src="{{icon_url}}" alt="{{value.name}} Logo"/>
+ {% if show_proj_icon == True and icon_url %}<img src="{{icon_url}}" alt="{{value.name}} Logo"/>{% endif %}
</div>
- {% else %}
+ {% else %}
+ {% if show_proj_icon == True and icon_url %}
<div class="box">
<img src="{{icon_url}}" alt="{{value.name}} Logo"/>
</div>
- {% endif %}
+ {% endif %}
{% endif %}
<h2><a href="{{value.url()}}">{{value.name}}</a></h2>
<p class="desc">{% if value.summary %}{{value.summary}}{% else %}{{h.text.truncate(value.short_description, 50)}}{% endif %}</p>
@@ -19,17 +19,17 @@
</div>
{% else %}
<div class="border card">
- {% if show_proj_icon == True and icon_url %}
- {% if accolades and show_awards_banner == True %}
+ {% if accolades and show_awards_banner == True %}
<div class="box notch sponsor">
<div class="feature">{{accolades[0].award.short}}</div>
- <img src="{{icon_url}}" alt="{{value.name}} Logo"/>
+ {% if show_proj_icon == True and icon_url %}<img src="{{icon_url}}" alt="{{value.name}} Logo"/>{% endif %}
</div>
- {% else %}
+ {% else %}
+ {% if show_proj_icon == True and icon_url %}
<div class="box">
<img src="{{icon_url}}" alt="{{value.name}} Logo"/>
</div>
- {% endif %}
+ {% endif %}
{% endif %}
<h2><a href="{{value.url()}}">{{value.name}}</a></h2>
<p class="desc">{% if value.summary %}{{value.summary}}{% else %}{{h.text.truncate(value.short_description, 50)}}{% endif %}</p>
diff --git a/Allura/allura/tests/functional/test_root.py b/Allura/allura/tests/functional/test_root.py
index 6d89187..411d998 100644
--- a/Allura/allura/tests/functional/test_root.py
+++ b/Allura/allura/tests/functional/test_root.py
@@ -33,7 +33,6 @@
assert_equal(response.html.find('h2',{'class':'dark title'}).contents[0].strip(), 'All Projects')
projects = response.html.findAll('div',{'class':'border card'})
assert projects[0].find('a').get('href') == '/adobe/adobe-1/'
- assert projects[0].find('img').get('alt') == 'adobe-1 Logo'
cat_links = response.html.find('div',{'id':'sidebar'}).findAll('li')
assert len(cat_links) == 4
assert cat_links[0].find('a').get('href') == '/browse/clustering'
@@ -52,20 +51,19 @@
fax_cat = M.ProjectCategory.query.find(dict(label='Fax')).first()
M.Project.query.find(dict(name='adobe-1')).first().category_id = com_cat._id
response = self.app.get('/browse')
- assert len(response.html.findAll('img',{'alt':'adobe-1 Logo'})) == 1
- assert len(response.html.findAll('img',{'alt':'adobe-2 Logo'})) == 1
+ assert len(response.html.findAll('a',{'href':'/adobe/adobe-1/'})) == 1
+ assert len(response.html.findAll('a',{'href':'/adobe/adobe-2/'})) == 1
response = self.app.get('/browse/communications')
- assert len(response.html.findAll('img',{'alt':'adobe-1 Logo'})) == 1
- assert len(response.html.findAll('img',{'alt':'adobe-2 Logo'})) == 0
+ assert len(response.html.findAll('a',{'href':'/adobe/adobe-1/'})) == 1
+ assert len(response.html.findAll('a',{'href':'/adobe/adobe-2/'})) == 0
response = self.app.get('/browse/communications/fax')
- assert len(response.html.findAll('img',{'alt':'adobe-1 Logo'})) == 0
- assert len(response.html.findAll('img',{'alt':'adobe-2 Logo'})) == 0
+ assert len(response.html.findAll('a',{'href':'/adobe/adobe-1/'})) == 0
+ assert len(response.html.findAll('a',{'href':'/adobe/adobe-2/'})) == 0
def test_neighborhood_index(self):
response = self.app.get('/adobe/')
projects = response.html.findAll('div',{'class':'border card'})
assert len(projects) == 2
- assert projects[0].find('img').get('alt') == 'adobe-1 Logo'
cat_links = response.html.find('div',{'id':'sidebar'}).findAll('ul')[1].findAll('li')
assert len(cat_links) == 3, cat_links
assert cat_links[0].find('a').get('href') == '/adobe/browse/clustering'
@@ -77,14 +75,14 @@
M.Project.query.find(dict(name='adobe-1')).first().category_id = com_cat._id
M.Project.query.find(dict(name='adobe-2')).first().category_id = fax_cat._id
response = self.app.get('/adobe/browse')
- assert len(response.html.findAll('img',{'alt':'adobe-1 Logo'})) == 1
- assert len(response.html.findAll('img',{'alt':'adobe-2 Logo'})) == 1
+ assert len(response.html.findAll('a',{'href':'/adobe/adobe-1/'})) == 1
+ assert len(response.html.findAll('a',{'href':'/adobe/adobe-2/'})) == 1
response = self.app.get('/adobe/browse/communications')
- assert len(response.html.findAll('img',{'alt':'adobe-1 Logo'})) == 1
- assert len(response.html.findAll('img',{'alt':'adobe-2 Logo'})) == 1
+ assert len(response.html.findAll('a',{'href':'/adobe/adobe-1/'})) == 1
+ assert len(response.html.findAll('a',{'href':'/adobe/adobe-2/'})) == 1
response = self.app.get('/adobe/browse/communications/fax')
- assert len(response.html.findAll('img',{'alt':'adobe-1 Logo'})) == 0
- assert len(response.html.findAll('img',{'alt':'adobe-2 Logo'})) == 1
+ assert len(response.html.findAll('a',{'href':'/adobe/adobe-1/'})) == 0
+ assert len(response.html.findAll('a',{'href':'/adobe/adobe-2/'})) == 1
@td.with_wiki
def test_markdown_to_html(self):
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 0557672..ccc673c 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -1,4 +1,5 @@
import re
+import os, allura
from urllib import quote
from bson import ObjectId
@@ -37,10 +38,35 @@
@with_setup(setUp)
def test_macros():
+ file_name = 'neo-icon-set-454545-256x350.png'
+ file_path = os.path.join(allura.__path__[0],'nf','allura','images',file_name)
+ curr_project = c.project
+
p_nbhd = M.Neighborhood.query.get(name='Projects')
p_test = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
+ c.project = p_test
+ icon_file = open(file_path)
+ M.ProjectFile.save_image(
+ file_name, icon_file, content_type='image/png',
+ square=True, thumbnail_size=(48,48),
+ thumbnail_meta=dict(project_id=c.project._id,category='icon'))
+ icon_file.close()
p_test2 = M.Project.query.get(shortname='test2', neighborhood_id=p_nbhd._id)
+ c.project = p_test2
+ icon_file = open(file_path)
+ M.ProjectFile.save_image(
+ file_name, icon_file, content_type='image/png',
+ square=True, thumbnail_size=(48,48),
+ thumbnail_meta=dict(project_id=c.project._id,category='icon'))
+ icon_file.close()
p_sub1 = M.Project.query.get(shortname='test/sub1', neighborhood_id=p_nbhd._id)
+ c.project = p_sub1
+ icon_file = open(file_path)
+ M.ProjectFile.save_image(
+ file_name, icon_file, content_type='image/png',
+ square=True, thumbnail_size=(48,48),
+ thumbnail_meta=dict(project_id=c.project._id,category='icon'))
+ icon_file.close()
p_test.labels = [ 'test', 'root' ]
p_sub1.labels = [ 'test', 'sub1' ]
# Make one project private
@@ -85,7 +111,12 @@
assert '<img alt="test2 Logo"' in r, r
assert '<img alt="test Logo"' not in r, r
assert '<img alt="sub1 Logo"' not in r, r
+ r = g.markdown_wiki.convert('[[projects show_proj_icon=True]]')
+ assert '<img alt="test Logo"' in r
+ r = g.markdown_wiki.convert('[[projects show_proj_icon=False]]')
+ assert '<img alt="test Logo"' not in r
+ c.project = curr_project
r = g.markdown_wiki.convert('[[project_admins]]')
assert r == '<div class="markdown_content"><p><a href="/u/test-admin/">Test Admin</a><br /></p></div>'
r = g.markdown_wiki.convert('[[download_button]]')
@@ -215,12 +246,6 @@
r = g.markdown_wiki.convert('[[projects display_mode=list columns=3]]')
assert two_column_style not in r
- # test project icon
- r = g.markdown_wiki.convert('[[projects display_mode=list show_proj_icon=True]]')
- assert 'test Logo' in r
- r = g.markdown_wiki.convert('[[projects display_mode=list show_proj_icon=False]]')
- assert 'test Logo' not in r
-
# test project download button
r = g.markdown_wiki.convert('[[projects display_mode=list show_download_button=True]]')
assert 'download-button' in r