def test_sequence_number_increment(self): sip = MockSIPClient(login_user_id="user_id", login_password="******") sip.sequence_number = 0 sip.queue_response("941") response = sip.login() assert 1 == sip.sequence_number # Test wraparound from 9 to 0 sip.sequence_number = 9 sip.queue_response("941") response = sip.login() assert 0 == sip.sequence_number
def test_sequence_number_increment(self): sip = MockSIPClient() sip.sequence_number = 0 sip.queue_response('941') response = sip.login('user_id', 'password') eq_(1, sip.sequence_number) # Test wraparound from 9 to 0 sip.sequence_number = 9 sip.queue_response('941') response = sip.login('user_id', 'password') eq_(0, sip.sequence_number)
def test_sequence_number_increment(self): sip = MockSIPClient(login_user_id='user_id', login_password='******') sip.sequence_number=0 sip.queue_response('941') response = sip.login() eq_(1, sip.sequence_number) # Test wraparound from 9 to 0 sip.sequence_number=9 sip.queue_response('941') response = sip.login() eq_(0, sip.sequence_number)
def test_login_happens_when_user_id_and_password_specified(self): sip = MockSIPClient('user_id', 'password') # We're not logged in, and we must log in before sending a real # message. eq_(True, sip.must_log_in) sip.queue_response('941') sip.queue_response('64Y 201610050000114734 AOnypl |AA12345|AENo Name|BLN|AFYour library card number cannot be located. Please see a staff member for assistance.|AY1AZC9DE') sip.login() response = sip.patron_information('patron_identifier') # Two requests were made. eq_(2, len(sip.requests)) eq_(2, sip.sequence_number) # We ended up with the right data. eq_('12345', response['patron_identifier'])
def test_login_happens_when_user_id_and_password_specified(self): sip = MockSIPClient('user_id', 'password') # We're not logged in, and we must log in before sending a real # message. eq_(True, sip.must_log_in) sip.queue_response('941') sip.queue_response( '64Y 201610050000114734 AOnypl |AA12345|AENo Name|BLN|AFYour library card number cannot be located. Please see a staff member for assistance.|AY1AZC9DE' ) sip.login() response = sip.patron_information('patron_identifier') # Two requests were made. eq_(2, len(sip.requests)) eq_(2, sip.sequence_number) # We ended up with the right data. eq_('12345', response['patron_identifier'])
def test_no_login_when_user_id_and_password_not_specified(self): sip = MockSIPClient() eq_(False, sip.must_log_in) sip.queue_response('64Y 201610050000114734 AOnypl |AA12345|AENo Name|BLN|AFYour library card number cannot be located. Please see a staff member for assistance.|AY1AZC9DE') sip.login() # Zero requests made eq_(0, len(sip.requests)) eq_(0, sip.sequence_number) response = sip.patron_information('patron_identifier') # One request made. eq_(1, len(sip.requests)) eq_(1, sip.sequence_number) # We ended up with the right data. eq_('12345', response['patron_identifier'])
def test_login_happens_when_user_id_and_password_specified(self): sip = MockSIPClient(login_user_id="user_id", login_password="******") # We're not logged in, and we must log in before sending a real # message. assert True == sip.must_log_in sip.queue_response("941") sip.queue_response( "64Y 201610050000114734 AOnypl |AA12345|AENo Name|BLN|AFYour library card number cannot be located. Please see a staff member for assistance.|AY1AZC9DE" ) sip.login() response = sip.patron_information("patron_identifier") # Two requests were made. assert 2 == len(sip.requests) assert 2 == sip.sequence_number # We ended up with the right data. assert "12345" == response["patron_identifier"]
def test_no_login_when_user_id_and_password_not_specified(self): sip = MockSIPClient() eq_(False, sip.must_log_in) sip.queue_response( '64Y 201610050000114734 AOnypl |AA12345|AENo Name|BLN|AFYour library card number cannot be located. Please see a staff member for assistance.|AY1AZC9DE' ) sip.login() # Zero requests made eq_(0, len(sip.requests)) eq_(0, sip.sequence_number) response = sip.patron_information('patron_identifier') # One request made. eq_(1, len(sip.requests)) eq_(1, sip.sequence_number) # We ended up with the right data. eq_('12345', response['patron_identifier'])
def test_no_login_when_user_id_and_password_not_specified(self): sip = MockSIPClient() assert False == sip.must_log_in sip.queue_response( "64Y 201610050000114734 AOnypl |AA12345|AENo Name|BLN|AFYour library card number cannot be located. Please see a staff member for assistance.|AY1AZC9DE" ) sip.login() # Zero requests made assert 0 == len(sip.requests) assert 0 == sip.sequence_number response = sip.patron_information("patron_identifier") # One request made. assert 1 == len(sip.requests) assert 1 == sip.sequence_number # We ended up with the right data. assert "12345" == response["patron_identifier"]
def test_resend(self): sip = MockSIPClient(login_user_id="user_id", login_password="******") # The first response will be a request to resend the original message. sip.queue_response("96") # The second response will indicate a successful login. sip.queue_response("941") response = sip.login() # We made two requests for a single login command. req1, req2 = sip.requests # The first request includes a sequence ID field, "AY", with # the value "0". assert b"9300CNuser_id|COpassword|AY0AZF556\r" == req1 # The second request does not include a sequence ID field. As # a consequence its checksum is different. assert b"9300CNuser_id|COpassword|AZF620\r" == req2 # The login request eventually succeeded. assert {"login_ok": "1", "_status": "94"} == response
def test_resend(self): sip = MockSIPClient() # The first response will be a request to resend the original message. sip.queue_response('96') # The second response will indicate a successful login. sip.queue_response('941') response = sip.login('user_id', 'password') # We made two requests for a single login command. req1, req2 = sip.requests # The first request includes a sequence ID field, "AY", with # the value "0". eq_('9300CNuser_id|COpassword|AY0AZF556\r', req1) # The second request does not include a sequence ID field. As # a consequence its checksum is different. eq_('9300CNuser_id|COpassword|AZF620\r', req2) # The login request eventually succeeded. eq_({'login_ok': '1', '_status': '94'}, response)
def test_resend(self): sip = MockSIPClient(login_user_id='user_id', login_password='******') # The first response will be a request to resend the original message. sip.queue_response('96') # The second response will indicate a successful login. sip.queue_response('941') response = sip.login() # We made two requests for a single login command. req1, req2 = sip.requests # The first request includes a sequence ID field, "AY", with # the value "0". eq_('9300CNuser_id|COpassword|AY0AZF556\r', req1) # The second request does not include a sequence ID field. As # a consequence its checksum is different. eq_('9300CNuser_id|COpassword|AZF620\r', req2) # The login request eventually succeeded. eq_({'login_ok': '1', '_status': '94'}, response)
def test_login_failure(self): sip = MockSIPClient() sip.queue_response('940') response = sip.login('user_id', 'password') eq_('0', response['login_ok'])
def test_login_success(self): sip = MockSIPClient('user_id', 'password') sip.queue_response('941') response = sip.login() eq_({'login_ok': '1', '_status': '94'}, response)
def test_login_password_is_optional(self): """You can specify a login_id without specifying a login_password.""" sip = MockSIPClient(login_user_id="user_id") sip.queue_response("941") response = sip.login() assert {"login_ok": "1", "_status": "94"} == response
def test_login_success(self): sip = MockSIPClient(login_user_id="user_id", login_password="******") sip.queue_response("941") response = sip.login() assert {"login_ok": "1", "_status": "94"} == response
def test_login_password_is_optional(self): """You can specify a login_id without specifying a login_password.""" sip = MockSIPClient('user_id') sip.queue_response('941') response = sip.login() eq_({'login_ok': '1', '_status': '94'}, response)
def test_login_success(self): sip = MockSIPClient() sip.queue_response('941') response = sip.login('user_id', 'password') eq_({'login_ok': '1', '_status': '94'}, response)
def test_login_password_is_optional(self): """You can specify a login_id without specifying a login_password.""" sip = MockSIPClient('user_id') sip.queue_response('941') response = sip.login() eq_({'login_ok': '1', '_status': '94'}, response)