Commit b9629bc5 authored by inkhey's avatar inkhey

add monster id sample

parent a2a4b9c6
......@@ -32,3 +32,13 @@ Bird avatar [by David Revoy](http://www.peppercarrot.com):
)
avatar = theme.generate_avatar(token="just a random string")
theme.save_on_disk(avatar, path="/tmp/saved_file.png")
Monster avatar [by Andreas Gohr's](https://www.splitbrain.org/blog/2007-01/20_monsterid_as_gravatar_fallback):
from pioupiou import FolderAvatarTheme
theme = FolderAvatarTheme(
"sample/monster_id",
layers_name=["legs", "hair", "arms", "body", "eyes", "mouth"],
)
avatar = theme.generate_avatar(token="just a random string")
theme.save_on_disk(avatar, path="/tmp/saved_file.png")
MIT License
Copyright (c) 2007 Andreas Gohr
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
......@@ -9,24 +9,42 @@ from pioupiou import FolderAvatarTheme
class TestFolderAvatarTheme(object):
@pytest.mark.parametrize(
"folder_path, layers_name, token, saved_file_path",
"folder_path, layers_name, token, saved_file_path, height, width",
[
(
"sample/cat_revoy",
["body", "fur", "eyes", "mouth", "accessorie"],
"just a random string",
"/tmp/saved_cat_avatar.png",
256,
256,
),
(
"sample/bird_revoy",
["tail", "hoop", "body", "wing", "eyes", "bec", "accessorie"],
"just a random string",
"/tmp/saved_bird_avatar.png",
256,
256,
),
(
"sample/monster_id",
["legs", "hair", "arms", "body", "eyes", "mouth"],
"just a random string",
"/tmp/saved_monster_avatar.png",
120,
120,
),
],
)
def test_avatar_generation_on_disk(
self, folder_path: str, layers_name: typing.List[str], token: str, saved_file_path: str
self,
folder_path: str,
layers_name: typing.List[str],
token: str,
saved_file_path: str,
height: int,
width: int,
):
theme = FolderAvatarTheme(folder_path=folder_path, layers_name=layers_name)
avatar = theme.generate_avatar(token=token)
......@@ -34,5 +52,5 @@ class TestFolderAvatarTheme(object):
assert os.path.exists(saved_file_path) is True
assert os.path.getsize(saved_file_path) > 0
with Image.open(saved_file_path) as avatar:
assert avatar.height == 256
assert avatar.width == 256
assert avatar.height == height
assert avatar.width == width
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment