Esempio n. 1
0
    def test_auth_logout(self, *args):
        c = Client()

        c.call.return_value = Response(200, 'sess LOGIN ACCEPTED')

        c.auth('user', 'pass')

        # First item is list of positional arguments
        call_command, call_params = c.call.call_args[0]

        self.assertEqual(call_command, 'AUTH')

        for param in ('user', 'pass', 'protover', 'client', 'clientver'):
            self.assertIn(param, call_params)

        self.assertEqual(call_params['user'], 'user')
        self.assertEqual(call_params['pass'], 'pass')

        self.assertTrue(c.is_logged_in())
        self.assertEqual(c._session, 'sess')

        c.call.return_value = Response(203, 'LOGGED OUT')

        c.logout()

        # First item is list of positional arguments
        call_command = c.call.call_args[0][0]

        self.assertEqual(call_command, 'LOGOUT')
        self.assertFalse(c.is_logged_in())
        self.assertIsNone(c._session)
Esempio n. 2
0
    def test_encoding(self, *args):
        c = Client()

        c.call.return_value = Response(200, 'sess LOGIN ACCEPTED')
        c.auth('user', 'pass')

        c.call.return_value = Response(219, 'ENCODING CHANGED')
        c.encoding('UTF-8')

        self.assertEqual(c._codec.encoding, 'UTF-8')

        c.call.return_value = Response(203, 'LOGGED OUT')
        c.logout()

        # Encoding should be reset to default after logout
        self.assertEqual(c._codec.encoding, Client.ENCODING)