1
0
Fork 0
mirror of https://github.com/matomo-org/matomo-icons.git synced 2024-09-19 17:03:45 +02:00

add test for missing social and searchEngine

This commit is contained in:
Lukas Winkler 2017-11-16 21:55:39 +01:00
parent 709581aefd
commit 80e8427253
4 changed files with 50 additions and 12 deletions

View file

@ -12,6 +12,7 @@ addons:
before_install: before_install:
- git clone https://github.com/piwik/piwik-package.git tmp/piwik-package - git clone https://github.com/piwik/piwik-package.git tmp/piwik-package
- composer install
script: script:
- 'shellcheck *.sh' - 'shellcheck *.sh'

View file

@ -1,5 +1,7 @@
{ {
"require-dev": { "require-dev": {
},
"require": {
"piwik/searchengine-and-social-list": "^1.3" "piwik/searchengine-and-social-list": "^1.3"
} }
} }

12
composer.lock generated
View file

@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "db041c0dc9f99f4a36466c5d5fff4493", "content-hash": "91c091e41d6398ebc9858b24132b66af",
"packages": [ "packages": [
{ {
"name": "piwik/searchengine-and-social-list", "name": "piwik/searchengine-and-social-list",
"version": "1.3.5", "version": "1.3.10",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/piwik/searchengine-and-social-list.git", "url": "https://github.com/piwik/searchengine-and-social-list.git",
"reference": "8302a7414bd48f44916bd4858859607838ac2526" "reference": "4ee85edc474a5e65cc785df470164037aaebc317"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/piwik/searchengine-and-social-list/zipball/8302a7414bd48f44916bd4858859607838ac2526", "url": "https://api.github.com/repos/piwik/searchengine-and-social-list/zipball/4ee85edc474a5e65cc785df470164037aaebc317",
"reference": "8302a7414bd48f44916bd4858859607838ac2526", "reference": "4ee85edc474a5e65cc785df470164037aaebc317",
"shasum": "" "shasum": ""
}, },
"type": "library", "type": "library",
@ -26,7 +26,7 @@
"Public Domain" "Public Domain"
], ],
"description": "Search engine and social network definitions used by Piwik", "description": "Search engine and social network definitions used by Piwik",
"time": "2016-11-09T20:36:59+00:00" "time": "2017-09-10T11:20:27+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [],

View file

@ -12,13 +12,14 @@
# #
# You should have received a copy of the GNU General Public License along with # You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>. # this program. If not, see <http://www.gnu.org/licenses/>.
import hashlib
from glob import glob
import os
import sys import sys
from PIL import Image from glob import glob
import hashlib
import os
import re import re
import fnmatch import yaml
from PIL import Image
ignored_source_files = [ ignored_source_files = [
"src/flags/un.svg", "src/flags/un.svg",
@ -49,6 +50,21 @@ min_image_size = 48
placeholder_icon_hash = "398a623a3b0b10eba6d1884b0ff1713ee12aeafaa8efaf67b60a4624f4dce48c" placeholder_icon_hash = "398a623a3b0b10eba6d1884b0ff1713ee12aeafaa8efaf67b60a4624f4dce48c"
searchEnginesFile = "vendor/piwik/searchengine-and-social-list/SearchEngines.yml"
socialsEnginesFile = "vendor/piwik/searchengine-and-social-list/Socials.yml"
def load_yaml(file):
with open(file, 'r') as stream:
return yaml.load(stream)
def image_exists(pathslug):
for filetype in ["svg", "png", "gif", "jpg", "ico"]:
if os.path.isfile(pathslug + "." + filetype):
return True
return False
def test_if_all_icons_are_converted(): def test_if_all_icons_are_converted():
global error global error
@ -158,6 +174,24 @@ def test_if_icons_are_indicated_to_be_improvable():
print("{icon} could be improved".format(icon=file[:-5])) print("{icon} could be improved".format(icon=file[:-5]))
def look_for_search_and_social_icon(source, mode, outputdir):
for i, element in source.items():
if mode == "searchengines":
search_engine = element[0]
urls = search_engine["urls"]
else:
urls = element
url = next((url for url in urls if "{}" not in url and "/" not in url), False)
if url and not image_exists(outputdir + url):
print(url)
def test_if_all_search_and_social_sites_have_an_icon():
look_for_search_and_social_icon(load_yaml(searchEnginesFile), "searchengines", "src/searchEngines/")
look_for_search_and_social_icon(load_yaml(socialsEnginesFile), "socials", "src/socials/")
if __name__ == "__main__": if __name__ == "__main__":
error = False error = False
@ -174,9 +208,10 @@ if __name__ == "__main__":
test_if_icons_are_indicated_to_be_missing() test_if_icons_are_indicated_to_be_missing()
test_if_icons_are_indicated_to_be_improvable() test_if_icons_are_indicated_to_be_improvable()
test_if_icons_are_large_enough() test_if_icons_are_large_enough()
test_if_all_search_and_social_sites_have_an_icon()
print("travis_fold:end:small_icons") print("travis_fold:end:small_icons")
test_if_build_script_is_deleting_all_unneeded_files() test_if_build_script_is_deleting_all_unneeded_files()
else: else:
print() print()
# test_if_icons_are_large_enough() test_if_all_search_and_social_sites_have_an_icon()
sys.exit(error) sys.exit(error)