diff --git a/.travis.yml b/.travis.yml index 4778562..1b72dac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,11 @@ language: python python: -- '2.7' -- '3.3' +- "2.6" +- "2.7" +- "3.2" +- "3.3" +- "3.4" +- "pypy" install: - pip install -r test_requirements.txt - pip install coveralls @@ -9,6 +13,7 @@ script: coverage run --source=pylast ./test_pylast.py after_success: coveralls after_script: +- coverage report - ./check.sh - pip install clonedigger - clonedigger pylast.py @@ -20,3 +25,10 @@ env: - secure: gDWNEYA1EUv4G230/KzcTgcmEST0nf2FeW/z/prsoQBu+TWw1rKKSJAJeMLvuI1z4aYqqNYdmqjWyNhhVK3p5wmFP2lxbhaBT1jDsxxFpePc0nUkdAQOOD0yBpbBGkqkjjxU34HjTX2NFNEbcM3izVVE9oQmS5r4oFFNJgdL91c= - secure: RpsZblHFU7a5dnkO/JUgi70RkNJwoUh3jJqVo1oOLjL+lvuAmPXhI8MDk2diUk43X+XCBFBEnm7UCGnjUF+hDnobO4T+VrIFuVJWg3C7iKIT+YWvgG6A+CSeo/P0I0dAeUscTr5z4ylOq3EDx4MFSa8DmoWMmjKTAG1GAeTlY2k= - 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" diff --git a/pylast.py b/pylast.py index 03c7767..8d82548 100644 --- a/pylast.py +++ b/pylast.py @@ -204,7 +204,7 @@ class _Network(object): """ def __str__(self): - return "The %s Network" % self.name + return "%s Network" % self.name def get_artist(self, artist_name): """ @@ -854,9 +854,6 @@ class LastFMNetwork(_Network): "'%s'" % self.username, "'%s'" % self.password_hash))) - def __str__(self): - return "Last.fm Network" - def get_lastfm_network( api_key="", api_secret="", session_key="", username="", @@ -953,9 +950,6 @@ class LibreFMNetwork(_Network): "'%s'" % self.username, "'%s'" % self.password_hash))) - def __str__(self): - return "Libre.fm Network" - def get_librefm_network( api_key="", api_secret="", session_key="", username="", diff --git a/test_pylast.py b/test_pylast.py index b3b4da1..a2cfc24 100755 --- a/test_pylast.py +++ b/test_pylast.py @@ -53,6 +53,7 @@ class TestPyLast(unittest.TestCase): api_key=API_KEY, api_secret=API_SECRET, username=self.username, password_hash=password_hash) + def test_scrobble(self): # Arrange artist = "Test Artist" @@ -1538,6 +1539,84 @@ class TestPyLast(unittest.TestCase): 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__': parser = argparse.ArgumentParser( description="Integration (not unit) tests for pylast.py", @@ -1545,6 +1624,9 @@ if __name__ == '__main__': parser.add_argument( '-1', '--single', help="Run a single test") + parser.add_argument( + '-r', '--repeat', + help="Repeat a single test (100 times) until failure") parser.add_argument( '-m', '--matching', help="Run tests with this in the name") @@ -1556,6 +1638,17 @@ if __name__ == '__main__': suite.addTest(TestPyLast(args.single)) 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: suite = unittest.TestSuite()