Ejemplo n.º 1
0
 def test_readyForQuery(self):
     def check(m, c):
         self.assertEqual(m.serialize(), 'Z\x00\x00\x00\x05'+c)
     check(messages.readyForQuery('idle'), 'I')
     check(messages.readyForQuery('transaction'), 'T')
     check(messages.readyForQuery('failed'), 'E')
     self.assertRaises(KeyError, messages.readyForQuery, 'foo')
Ejemplo n.º 2
0
    def test_readyForQuery(self):
        def check(m, c):
            self.assertEqual(m.serialize(), 'Z\x00\x00\x00\x05' + c)

        check(messages.readyForQuery('idle'), 'I')
        check(messages.readyForQuery('transaction'), 'T')
        check(messages.readyForQuery('failed'), 'E')
        self.assertRaises(KeyError, messages.readyForQuery, 'foo')
Ejemplo n.º 3
0
    def test_ignoreMessages(self):
        b, f = self.protocols()
        b.ignoreMessages('CZ')
        c = messages.commandComplete('SAVEPOINT')
        z = messages.readyForQuery('idle')

        f.transport.expectNothing()
        b.messageReceived(c)
        b.messageReceived(z)
Ejemplo n.º 4
0
    def test_extra_auth_messages_raise_errors(self):
        p = self.backend()
        p.messageReceived(messages.readyForQuery('idle'))

        try:
            p.messageReceived(messages.authenticationOk())
        except AssertionError, e:
            self.assertEqual(
                e.message, 'Adding auth message, but authentication complete')
Ejemplo n.º 5
0
 def test_ignoreMessages(self):
     b, f = self.protocols()
     b.ignoreMessages('CZ')
     c = messages.commandComplete('SAVEPOINT')
     z = messages.readyForQuery('idle')
     
     f.transport.expectNothing()
     b.messageReceived(c)
     b.messageReceived(z)
Ejemplo n.º 6
0
 def test_extra_auth_messages_raise_errors(self):
     p = self.backend()
     p.messageReceived(messages.readyForQuery('idle'))
     
     try:
         p.messageReceived(messages.authenticationOk())
     except AssertionError, e:
         self.assertEqual(
             e.message, 
             'Adding auth message, but authentication complete')
Ejemplo n.º 7
0
    def test_subsequent_sets_override_original_auth_parameter_status(self):
        p = self.backend()
        a = messages.authenticationOk()
        f = messages.parameterStatus('foo', 'bar')
        b = messages.parameterStatus('baz', 'goo')
        z = messages.readyForQuery('idle')
        p.messageReceived(a)
        p.messageReceived(f)
        p.messageReceived(b)
        p.messageReceived(z)
        self.assertEqual(p.authenticationResponse, [a, f, b, z])

        x = messages.parameterStatus('foo', 'bar2')
        p.messageReceived(x)
        self.assertEqual(p.authenticationResponse, [a, x, b, z])
Ejemplo n.º 8
0
    def test_subsequent_sets_override_original_auth_parameter_status(self):
        p = self.backend()
        a = messages.authenticationOk()
        f = messages.parameterStatus('foo', 'bar')
        b = messages.parameterStatus('baz', 'goo')
        z = messages.readyForQuery('idle')
        p.messageReceived(a)
        p.messageReceived(f)
        p.messageReceived(b)
        p.messageReceived(z)
        self.assertEqual(p.authenticationResponse, [a, f, b, z])

        x = messages.parameterStatus('foo', 'bar2')
        p.messageReceived(x)
        self.assertEqual(p.authenticationResponse, [a, x, b, z])
Ejemplo n.º 9
0
 def test_transaction_status_tracked(self):
     p = self.backend()
     self.assertEqual(None, p.transactionStatus)
     z = messages.readyForQuery('idle')
     p.messageReceived(z)
     self.assertEqual('idle', p.transactionStatus)
Ejemplo n.º 10
0
 def receiveAuth(self, p):
     p.messageReceived(messages.authenticationOk())
     p.messageReceived(messages.parameterStatus('foo', 'bar'))
     p.messageReceived(messages.readyForQuery('idle'))
Ejemplo n.º 11
0
 def test_transaction_status_tracked(self):
     p = self.backend()
     self.assertEqual(None, p.transactionStatus)
     z = messages.readyForQuery('idle')
     p.messageReceived(z)
     self.assertEqual('idle', p.transactionStatus)