Skip to content

Commit

Permalink
Added unit test 'commits.svg'; now passing linting check
Browse files Browse the repository at this point in the history
  • Loading branch information
nshan651 committed Oct 10, 2022
1 parent 708b9cb commit 4c22f99
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
5 changes: 3 additions & 2 deletions pybadges/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,12 @@ def badge(
raise ValueError(
'whole_link may not bet set with left_link, right_link, or center_link'
)

if center_image and not (right_image or right_text):
raise ValueError('cannot have a center_image without a right element')

if (center_image and not center_color) or (not center_image and center_color):
if (center_image and not center_color) or (not center_image and
center_color):
raise ValueError('must have both a center_image and a center_color')

if logo and embed_logo:
Expand Down
13 changes: 8 additions & 5 deletions pybadges/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ def main():
parser.add_argument(
'--right-image',
default=None,
help='the image to associate with the right-hand side of the badge')
help='the image to associate with the right-hand side of the badge')
parser.add_argument(
'--center-image',
default=None,
help='the image to associate with the center of the badge')
help='the image to associate with the center of the badge')
parser.add_argument(
'--embed-logo',
nargs='?',
Expand All @@ -135,7 +135,8 @@ def main():
type=lambda x: x.lower() in ['y', 'yes', 't', 'true', '1', ''],
const='yes',
default='no',
help='if the right image is specified then include the image data directly in '
help=
'if the right image is specified then include the image data directly in '
'the badge (this will prevent a URL fetch and may work around the '
'fact that some browsers do not fetch external image references); '
'only works if --logo is a HTTP/HTTPS URI or a file path')
Expand All @@ -145,7 +146,8 @@ def main():
type=lambda x: x.lower() in ['y', 'yes', 't', 'true', '1', ''],
const='yes',
default='no',
help='if the center image is specified then include the image data directly in '
help=
'if the center image is specified then include the image data directly in '
'the badge (this will prevent a URL fetch and may work around the '
'fact that some browsers do not fetch external image references); '
'only works if --logo is a HTTP/HTTPS URI or a file path')
Expand All @@ -156,7 +158,8 @@ def main():
version='%(prog)s {version}'.format(version=__version__))
args = parser.parse_args()

if (args.left_link or args.right_link or args.center_link) and args.whole_link:
if (args.left_link or args.right_link or
args.center_link) and args.whole_link:
print('argument --whole-link: cannot be set with ' +
'--left-link, --right-link, or --center_link',
file=sys.stderr)
Expand Down
1 change: 1 addition & 0 deletions tests/golden-images/commits.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions tests/test-badges.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,12 @@
"right_text": "231 passed, 1 failed, 1 skipped",
"left_color": "blue",
"right_color": "orange"
},
{
"file_name": "commits.svg",
"left_text": "commits",
"right_text": "250",
"center_image": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIgogICAgIHdpZHRoPSIxMDciIGhlaWdodD0iMTMiIHZpZXdCb3g9IjAgLTEyIDEwNyAxMyI+CjxkZWZzPgo8L2RlZnM+CjxwYXRoIGQ9Ik03LjAsLTIuNzQzNTAyMzE1NTM3MTcyNyBMNy45NTg3NjI4ODY1OTc5MzgsLTIuMTIxMjEzMzA0Mzk3MDk2NCBMOC45MTc1MjU3NzMxOTU4NzcsLTIuNDA5ODg0OTkzNTgyNDQgTDkuODc2Mjg4NjU5NzkzODE1LC0yLjc1MTk5MjYyMzQ3NzI4IEwxMC44MzUwNTE1NDYzOTE3NTMsLTIuODY0MjQ4NjIwOTk5NDIzIEwxMS43OTM4MTQ0MzI5ODk2OTEsLTIuNzQ4OTY4NzAyMjc0MDMzNyBMMTIuNzUyNTc3MzE5NTg3NjMsLTIuNTE4NzE4OTQxMDA1NTIxMyBMMTMuNzExMzQwMjA2MTg1NTY4LC0yLjI5ODcyNTU1NTExMjA2OCBMMTQuNjcwMTAzMDkyNzgzNTA2LC0yLjE4MDUyNzQ2ODU1MDQ2OC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