Refactor network names. Add some tag tests. Add stress test option. Add extra Python versions as allowed failures to Travis.
This commit is contained in:
parent
e28e2ef0d0
commit
adbe8a8500
16
.travis.yml
16
.travis.yml
|
@ -1,7 +1,11 @@
|
||||||
language: python
|
language: python
|
||||||
python:
|
python:
|
||||||
- '2.7'
|
- "2.6"
|
||||||
- '3.3'
|
- "2.7"
|
||||||
|
- "3.2"
|
||||||
|
- "3.3"
|
||||||
|
- "3.4"
|
||||||
|
- "pypy"
|
||||||
install:
|
install:
|
||||||
- pip install -r test_requirements.txt
|
- pip install -r test_requirements.txt
|
||||||
- pip install coveralls
|
- pip install coveralls
|
||||||
|
@ -9,6 +13,7 @@ script: coverage run --source=pylast ./test_pylast.py
|
||||||
after_success:
|
after_success:
|
||||||
coveralls
|
coveralls
|
||||||
after_script:
|
after_script:
|
||||||
|
- coverage report
|
||||||
- ./check.sh
|
- ./check.sh
|
||||||
- pip install clonedigger
|
- pip install clonedigger
|
||||||
- clonedigger pylast.py
|
- clonedigger pylast.py
|
||||||
|
@ -20,3 +25,10 @@ env:
|
||||||
- secure: gDWNEYA1EUv4G230/KzcTgcmEST0nf2FeW/z/prsoQBu+TWw1rKKSJAJeMLvuI1z4aYqqNYdmqjWyNhhVK3p5wmFP2lxbhaBT1jDsxxFpePc0nUkdAQOOD0yBpbBGkqkjjxU34HjTX2NFNEbcM3izVVE9oQmS5r4oFFNJgdL91c=
|
- secure: gDWNEYA1EUv4G230/KzcTgcmEST0nf2FeW/z/prsoQBu+TWw1rKKSJAJeMLvuI1z4aYqqNYdmqjWyNhhVK3p5wmFP2lxbhaBT1jDsxxFpePc0nUkdAQOOD0yBpbBGkqkjjxU34HjTX2NFNEbcM3izVVE9oQmS5r4oFFNJgdL91c=
|
||||||
- secure: RpsZblHFU7a5dnkO/JUgi70RkNJwoUh3jJqVo1oOLjL+lvuAmPXhI8MDk2diUk43X+XCBFBEnm7UCGnjUF+hDnobO4T+VrIFuVJWg3C7iKIT+YWvgG6A+CSeo/P0I0dAeUscTr5z4ylOq3EDx4MFSa8DmoWMmjKTAG1GAeTlY2k=
|
- secure: RpsZblHFU7a5dnkO/JUgi70RkNJwoUh3jJqVo1oOLjL+lvuAmPXhI8MDk2diUk43X+XCBFBEnm7UCGnjUF+hDnobO4T+VrIFuVJWg3C7iKIT+YWvgG6A+CSeo/P0I0dAeUscTr5z4ylOq3EDx4MFSa8DmoWMmjKTAG1GAeTlY2k=
|
||||||
- secure: T5OKyd5Bs0nZbUr+YICbThC5GrFq/kUjX8FokzCv7NWsYaUWIwEmMXXzoYALoB3A+rAglOx6GABaupoNKKg3tFQyxXphuMKpZ8MasMAMFjFW0d7wsgGy0ylhVwrgoKzDbCQ5FKbohC+9ltLs+kKMCQ0L+MI70a/zTfF4/dVWO/o=
|
- secure: T5OKyd5Bs0nZbUr+YICbThC5GrFq/kUjX8FokzCv7NWsYaUWIwEmMXXzoYALoB3A+rAglOx6GABaupoNKKg3tFQyxXphuMKpZ8MasMAMFjFW0d7wsgGy0ylhVwrgoKzDbCQ5FKbohC+9ltLs+kKMCQ0L+MI70a/zTfF4/dVWO/o=
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
allow_failures:
|
||||||
|
- python: "2.6"
|
||||||
|
- python: "3.2"
|
||||||
|
- python: "3.4"
|
||||||
|
- python: "pypy"
|
||||||
|
|
|
@ -204,7 +204,7 @@ class _Network(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "The %s Network" % self.name
|
return "%s Network" % self.name
|
||||||
|
|
||||||
def get_artist(self, artist_name):
|
def get_artist(self, artist_name):
|
||||||
"""
|
"""
|
||||||
|
@ -854,9 +854,6 @@ class LastFMNetwork(_Network):
|
||||||
"'%s'" % self.username,
|
"'%s'" % self.username,
|
||||||
"'%s'" % self.password_hash)))
|
"'%s'" % self.password_hash)))
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return "Last.fm Network"
|
|
||||||
|
|
||||||
|
|
||||||
def get_lastfm_network(
|
def get_lastfm_network(
|
||||||
api_key="", api_secret="", session_key="", username="",
|
api_key="", api_secret="", session_key="", username="",
|
||||||
|
@ -953,9 +950,6 @@ class LibreFMNetwork(_Network):
|
||||||
"'%s'" % self.username,
|
"'%s'" % self.username,
|
||||||
"'%s'" % self.password_hash)))
|
"'%s'" % self.password_hash)))
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return "Libre.fm Network"
|
|
||||||
|
|
||||||
|
|
||||||
def get_librefm_network(
|
def get_librefm_network(
|
||||||
api_key="", api_secret="", session_key="", username="",
|
api_key="", api_secret="", session_key="", username="",
|
||||||
|
|
|
@ -53,6 +53,7 @@ class TestPyLast(unittest.TestCase):
|
||||||
api_key=API_KEY, api_secret=API_SECRET,
|
api_key=API_KEY, api_secret=API_SECRET,
|
||||||
username=self.username, password_hash=password_hash)
|
username=self.username, password_hash=password_hash)
|
||||||
|
|
||||||
|
|
||||||
def test_scrobble(self):
|
def test_scrobble(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
artist = "Test Artist"
|
artist = "Test Artist"
|
||||||
|
@ -1538,6 +1539,84 @@ class TestPyLast(unittest.TestCase):
|
||||||
self.assertIsInstance(users[0], pylast.User)
|
self.assertIsInstance(users[0], pylast.User)
|
||||||
|
|
||||||
|
|
||||||
|
def test_tag_artist(self):
|
||||||
|
# Arrange
|
||||||
|
artist = self.network.get_artist("Test Artist")
|
||||||
|
# artist.clear_tags()
|
||||||
|
|
||||||
|
# Act
|
||||||
|
artist.add_tag("testing")
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
tags = artist.get_tags()
|
||||||
|
self.assertGreater(len(tags), 0)
|
||||||
|
found = False
|
||||||
|
for tag in tags:
|
||||||
|
if tag.name == "testing":
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
self.assertTrue(found)
|
||||||
|
|
||||||
|
def test_remove_tag_of_type_text(self):
|
||||||
|
# Arrange
|
||||||
|
tag = "testing" # text
|
||||||
|
artist = self.network.get_artist("Test Artist")
|
||||||
|
artist.add_tag(tag)
|
||||||
|
|
||||||
|
# Act
|
||||||
|
artist.remove_tag(tag)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
tags = artist.get_tags()
|
||||||
|
found = False
|
||||||
|
for tag in tags:
|
||||||
|
if tag.name == "testing":
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
self.assertFalse(found)
|
||||||
|
|
||||||
|
|
||||||
|
def test_remove_tag_of_type_tag(self):
|
||||||
|
# Arrange
|
||||||
|
tag = pylast.Tag("testing", self.network) # Tag
|
||||||
|
artist = self.network.get_artist("Test Artist")
|
||||||
|
artist.add_tag(tag)
|
||||||
|
|
||||||
|
# Act
|
||||||
|
artist.remove_tag(tag)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
tags = artist.get_tags()
|
||||||
|
found = False
|
||||||
|
for tag in tags:
|
||||||
|
if tag.name == "testing":
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
self.assertFalse(found)
|
||||||
|
|
||||||
|
|
||||||
|
def test_remove_tags(self):
|
||||||
|
# Arrange
|
||||||
|
tags = ["testing1", "testing2"]
|
||||||
|
artist = self.network.get_artist("Test Artist")
|
||||||
|
artist.add_tags(tags)
|
||||||
|
|
||||||
|
# Act
|
||||||
|
artist.remove_tags(tags)
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
tags = artist.get_tags()
|
||||||
|
found = False
|
||||||
|
for tag in tags:
|
||||||
|
if tag.name == "testing1" or tag.name == "testing2":
|
||||||
|
found = True
|
||||||
|
break
|
||||||
|
self.assertFalse(found)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="Integration (not unit) tests for pylast.py",
|
description="Integration (not unit) tests for pylast.py",
|
||||||
|
@ -1545,6 +1624,9 @@ if __name__ == '__main__':
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-1', '--single',
|
'-1', '--single',
|
||||||
help="Run a single test")
|
help="Run a single test")
|
||||||
|
parser.add_argument(
|
||||||
|
'-r', '--repeat',
|
||||||
|
help="Repeat a single test (100 times) until failure")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-m', '--matching',
|
'-m', '--matching',
|
||||||
help="Run tests with this in the name")
|
help="Run tests with this in the name")
|
||||||
|
@ -1556,6 +1638,17 @@ if __name__ == '__main__':
|
||||||
suite.addTest(TestPyLast(args.single))
|
suite.addTest(TestPyLast(args.single))
|
||||||
unittest.TextTestRunner().run(suite)
|
unittest.TextTestRunner().run(suite)
|
||||||
|
|
||||||
|
elif args.repeat:
|
||||||
|
suite = unittest.TestSuite()
|
||||||
|
|
||||||
|
suite.addTest(TestPyLast(args.repeat))
|
||||||
|
for i in range(100):
|
||||||
|
print("Attempt " + str(i+1))
|
||||||
|
result = unittest.TextTestRunner().run(suite)
|
||||||
|
problems = len(result.errors) + len(result.failures)
|
||||||
|
if problems:
|
||||||
|
break
|
||||||
|
|
||||||
elif args.matching:
|
elif args.matching:
|
||||||
suite = unittest.TestSuite()
|
suite = unittest.TestSuite()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue