More tests

This commit is contained in:
hugovk 2017-10-18 23:48:02 +03:00
parent f70254b947
commit f2b699a11f
3 changed files with 88 additions and 0 deletions

View file

@ -11,6 +11,26 @@ from .test_pylast import PyLastTestCase
class TestPyLastLibrary(PyLastTestCase):
def test_repr(self):
# Arrange
library = pylast.Library(user=self.username, network=self.network)
# Act
representation = repr(library)
# Assert
self.assertTrue(representation.startswith("pylast.Library("))
def test_str(self):
# Arrange
library = pylast.Library(user=self.username, network=self.network)
# Act
string = str(library)
# Assert
self.assertTrue(string.endswith("'s Library"))
def test_library_is_hashable(self):
# Arrange
library = pylast.Library(user=self.username, network=self.network)
@ -25,6 +45,17 @@ class TestPyLastLibrary(PyLastTestCase):
# Act/Assert
self.helper_validate_cacheable(library, "get_artists")
def test_get_user(self):
# Arrange
library = pylast.Library(user=self.username, network=self.network)
user_to_get = self.network.get_user(self.username)
# Act
library_user = library.get_user()
# Assert
self.assertEqual(library_user, user_to_get)
if __name__ == '__main__':
unittest.main(failfast=True)

View file

@ -30,6 +30,20 @@ class TestPyLastWithLibreFm(unittest.TestCase):
# Assert
self.assertEqual(name, "Radiohead")
def test_repr(self):
# Arrange
secrets = load_secrets()
username = secrets["username"]
password_hash = secrets["password_hash"]
network = pylast.LibreFMNetwork(
password_hash=password_hash, username=username)
# Act
representation = repr(network)
# Assert
self.assertTrue(representation.startswith("pylast.LibreFMNetwork("))
if __name__ == '__main__':
unittest.main(failfast=True)

View file

@ -14,6 +14,49 @@ from .test_pylast import PyLastTestCase
class TestPyLastUser(PyLastTestCase):
def test_repr(self):
# Arrange
username = "RJ"
user = self.network.get_user(username)
# Act
representation = repr(user)
# Assert
self.assertTrue(
representation.startswith(representation), "pylast.User('RJ',")
def test_str(self):
# Arrange
username = "RJ"
user = self.network.get_user(username)
# Act
string = str(user)
# Assert
self.assertEqual(string, "RJ")
def test_equality(self):
# Arrange
username = "RJ"
user = self.network.get_user(username)
not_a_user = self.network
# Act / Assert
self.assertNotEqual(user, not_a_user)
def test_get_name(self):
# Arrange
username = "RJ"
user = self.network.get_user(username)
# Act
name = user.get_name(properly_capitalized=True)
# Assert
self.assertEqual(name, "RJ")
def test_get_user_registration(self):
# Arrange
username = "RJ"