示例#1
0
文件: tests.py 项目: rubenroy/TPB
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()
示例#2
0
文件: tests.py 项目: rubenroy/TPB
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()