Exemple #1
0
class AuthTestCase(RemoteTestCase):

    def setUp(self):
        self.user = User(base_url=self.url)

    def test_login(self):

        # Login with correct credentials
        self.user.login("testuser", "testpassword")
        self.assertEqual(self.user.username, "testuser")
        self.assertEqual(self.user.password, "testpassword")
        self.user.logout()

        # Login with incorrect credentials
        try:
            self.user.login("testuser", "wrongpassword")
        except Exception as e:
            msg = "Login failed (2), check username and password."
            self.assertEqual(str(e), msg)
        else:
            self.assertFalse(True)
        finally:
            self.assertIsNone(self.user.username)

    def test_logout(self):
        self.user.login("testuser", "testpassword")
        self.user.logout()
        self.assertIsNone(self.user.username)
Exemple #2
0
 def __init__(self, host='localhost', port=8000):
     super(TPBApp, self).__init__()
     self.host = host
     self.port = port
     self.process = None
     self.users = []
     _user = User(base_url=self.url)
     _user.username = "******"
     _user.password = "******"
     _user.current_ip = "1.2.3.4"
     _user.current_language = "English"
     _user.status = "MEMBER"
     _user.sort_order = 5
     _user.torrents = 0
     _user.comments = 0
     self.users.append(_user)
     self.current_user = None
Exemple #3
0
class RetrieveTestCase(RemoteTestCase):

    def setUp(self):
        self.user = User(base_url=self.url)
        self.user.login("testuser", "testpassword")

    def test_retrieve_settings(self):
        self.user.retrieve_settings()
        self.assertIsNotNone(self.user.current_ip)
        self.assertIsNotNone(self.user.current_language)
        self.assertIsNotNone(self.user.sort_order)
        self.assertIsNotNone(self.user.status)
        self.assertIsNotNone(self.user.torrents)
        self.assertIsNotNone(self.user.comments)

    def tearDown(self):
        self.user.logout()
Exemple #4
0
 def setUp(self):
     self.user = User(base_url=self.url)
     self.user.login("testuser", "testpassword")
     self.user.retrieve_settings()
Exemple #5
0
class UpdateTestCase(RemoteTestCase):

    def setUp(self):
        self.user = User(base_url=self.url)
        self.user.login("testuser", "testpassword")
        self.user.retrieve_settings()

    def test_change_sort_order(self):
        sort_order = self.user.sort_order
        # Try to change it
        self.user.change_sort_order(1)
        self.user.retrieve_settings()
        # See if it sticks
        self.assertEqual(self.user.sort_order, 1)
        if sort_order == 1:
            # Do it again to see if it really changed
            self.user.change_sort_order(2)
            self.user.retrieve_settings()
            self.assertEqual(self.user.sort_order, 2)
        # Now change it back to what it was before
        self.user.change_sort_order(sort_order)

    def test_change_password(self):
        password = self.user.password
        # Try to change it
        self.user.change_password("newpassword")
        self.user.logout()
        # See if the new password works
        try:
            self.user.login("testuser", "newpassword")
        except:
            # The password wasn't changed.
            self.assertFalse(True)
        else:
            # Change it back
            self.user.change_password(password)

    def tearDown(self):
        self.user.logout()
Exemple #6
0
 def setUp(self):
     self.user = User(base_url=self.url)
     self.user.login("testuser", "testpassword")
Exemple #7
0
 def setUp(self):
     self.user = User(base_url=self.url)