Skip to content
Snippets Groups Projects
Commit 0f04cde4 authored by roadscape's avatar roadscape
Browse files

pytest config, utils-account test

parent b003798e
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,7 @@ test: test-without-build build
test-without-build: test-without-lint test-pylint
test-without-lint:
py.test tests
py.test --cov=hive
test-pylint:
py.test --pylint -m pylint $(PROJECT_NAME)
......
......@@ -19,11 +19,12 @@ aiomysql = "*"
[dev-packages]
ipython = "*"
"ipython" = "*"
"pep8" = "*"
pytest = "*"
"pytest-console-scripts" = "*"
"pytest" = "*"
"pytest-cov" = "*"
"pytest-docker" = "*"
"pytest-pylint" = "*"
yapf = "*"
"pytest-console-scripts" = "*"
"yapf" = "*"
"autopep8" = "*"
if [ -z "$1" ]
then
pylint hive/**/*.py -f colorized -r n --disable=fixme
pylint hive/**/*.py -f colorized -r n
grep -r --color=always 'pylint: disable' hive
else
pylint $1 -f colorized -r n --disable=fixme
pylint $1 -f colorized -r n
grep -r --color=always 'pylint: disable' $1
fi
......@@ -116,7 +116,9 @@ disable=
using-cmp-argument,
setslice-method,
oct-method,
coerce-method
coerce-method,
#custom
fixme
[REPORTS]
......
......@@ -18,7 +18,7 @@ ignore = E501
[tool:pytest]
norecursedirs=dist docs build .tox deploy
addopts = --pylint
adopts = --pylint
[coverage:run]
......
......@@ -14,13 +14,15 @@ setup(
long_description=open('README.md').read(),
packages=find_packages(exclude=['scripts']),
setup_requires=['pytest-runner'],
tests_require=['pytest',
'pep8',
'pytest-pylint',
'yapf',
'git-pylint-commit-hook',
'pytest-console-scripts'],
tests_require=[
'pytest',
'pytest-cov',
'pytest-pylint',
'pytest-console-scripts',
'git-pylint-commit-hook',
'pep8',
'yapf',
],
install_requires=[
'aiopg',
'jsonrpcserver',
......
import json
from hive.utils.account import safe_profile_metadata
def test_valid_account():
raw_profile = dict(
name='Leonardo Da Vinci',
about='Renaissance man, vegetarian, inventor of the helicopter in 1512 and painter of the Mona Lisa.',
location='Florence',
website='http://www.davincilife.com/',
cover_image='https://steemitimages.com/0x0/https://pbs.twimg.com/profile_banners/816255358066946050/1483447009/1500x500',
profile_image='https://www.parhlo.com/wp-content/uploads/2016/01/tmp617041537745813506.jpg',
)
account = {'name': 'foo', 'json_metadata': json.dumps(dict(profile=raw_profile))}
safe_profile = safe_profile_metadata(account)
for key, safe_value in safe_profile.items():
assert raw_profile[key] == safe_value
def test_invalid_account():
raw_profile = dict(
name='NameIsTooBigByOneChar',
location='Florence\x00',
website='davincilife.com/',
cover_image='example.com/avatar.jpg',
profile_image='https://example.com/valid-url-but-longer-than-1024-chars' + 'x' * 1024,
)
account = {'name': 'foo', 'json_metadata': json.dumps(dict(profile=raw_profile))}
safe_profile = safe_profile_metadata(account)
assert safe_profile['name'] == 'NameIsTooBigByOne...'
assert safe_profile['about'] == ''
assert safe_profile['location'] == ''
assert safe_profile['website'] == 'http://davincilife.com/' # TODO: should normalize to https?
assert safe_profile['cover_image'] == ''
assert safe_profile['profile_image'] == ''
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment