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')
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')
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)
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')
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])
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)
def receiveAuth(self, p): p.messageReceived(messages.authenticationOk()) p.messageReceived(messages.parameterStatus('foo', 'bar')) p.messageReceived(messages.readyForQuery('idle'))