def test_two_successive_state_queries_do_not_result_into_two_status_checks( self): # A certain time interval has to pass between successive checks for the # resource to query its status. self.conn.send_get_request.side_effect = [ self.status_with({'pending': True}), self.status_with({'pending': False}) ] r = Resource('ID', self.conn) r.is_pending() pending = r.is_pending() self.assertEqual(len(self.conn.send_get_request.mock_calls), 1) self.assertTrue( pending) # Still True because there was only one query.
def test_two_successive_state_queries_do_not_result_into_two_status_checks(self): # A certain time interval has to pass between successive checks for the # resource to query its status. self.conn.send_get_request.side_effect = [ self.status_with({ 'pending': True }), self.status_with({ 'pending': False }) ] r = Resource('ID', self.conn) r.is_pending() pending = r.is_pending() self.assertEqual(len(self.conn.send_get_request.mock_calls), 1) self.assertTrue(pending) # Still True because there was only one query.
def test_is_pending_checks_status_on_first_call_and_returns_correct_value( self): self.conn.send_get_request.return_value = self.status_with( {'pending': True}) r = Resource('ID', self.conn) pending = r.is_pending() self.assertTrue(pending) self.conn.send_get_request.assert_called_once_with('/ID/status')
def test_is_pending_checks_status_on_first_call_and_returns_correct_value(self): self.conn.send_get_request.return_value = self.status_with({ 'pending': True }) r = Resource('ID', self.conn) pending = r.is_pending() self.assertTrue(pending) self.conn.send_get_request.assert_called_once_with('/ID/status')