Пример #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')
Пример #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')
Пример #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)
Пример #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')
Пример #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)
Пример #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')
Пример #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])
Пример #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])
Пример #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)
Пример #10
0
 def receiveAuth(self, p):
     p.messageReceived(messages.authenticationOk())
     p.messageReceived(messages.parameterStatus('foo', 'bar'))
     p.messageReceived(messages.readyForQuery('idle'))
Пример #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)