misc: fix singleton-comparison pylint error (#56288)
This commit is contained in:
parent
02d5299c9a
commit
6bc2e43f12
|
@ -580,7 +580,7 @@ def test_json_cell():
|
|||
with mock.patch('combo.utils.requests.get') as requests_get:
|
||||
context = cell.get_cell_extra_context({})
|
||||
# can't get URL, 'foobar' variable is missing
|
||||
assert context['json'] == None
|
||||
assert context['json'] is None
|
||||
assert requests_get.call_count == 0
|
||||
request = RequestFactory().get('/')
|
||||
request.user = User(username='foo', email='foo@example.net')
|
||||
|
@ -825,7 +825,7 @@ def test_config_json_cell_with_param_in_url(app):
|
|||
app.get(url)
|
||||
assert requests_get.call_count == 1
|
||||
assert requests_get.call_args[0][0] == 'http://foo?var=plop'
|
||||
assert requests_get.call_args[-1]['log_errors'] == False
|
||||
assert requests_get.call_args[-1]['log_errors'] is False
|
||||
assert requests_get.call_args[-1]['timeout'] == 42
|
||||
|
||||
|
||||
|
@ -1147,10 +1147,10 @@ def test_config_json_cell_additional_url(app):
|
|||
assert resp.text.strip() == '/var1=toto/var2=toto/'
|
||||
assert len(requests_get.mock_calls) == 2
|
||||
assert requests_get.mock_calls[0][1][0] == 'http://foo'
|
||||
assert requests_get.mock_calls[0][-1]['log_errors'] == True
|
||||
assert requests_get.mock_calls[0][-1]['timeout'] == None
|
||||
assert requests_get.mock_calls[0][-1]['log_errors'] is True
|
||||
assert requests_get.mock_calls[0][-1]['timeout'] is None
|
||||
assert requests_get.mock_calls[1][1][0] == 'http://bar'
|
||||
assert requests_get.mock_calls[1][-1]['log_errors'] == False
|
||||
assert requests_get.mock_calls[1][-1]['log_errors'] is False
|
||||
assert requests_get.mock_calls[1][-1]['timeout'] == 42
|
||||
|
||||
with mock.patch('combo.utils.requests.get') as requests_get:
|
||||
|
@ -1168,11 +1168,11 @@ def test_config_json_cell_additional_url(app):
|
|||
assert requests_get.mock_calls[0][1][0] == 'http://foo'
|
||||
assert requests_get.mock_calls[1][1][0] == 'http://bar'
|
||||
context = cell.get_cell_extra_context({})
|
||||
assert context['json'] == None
|
||||
assert context['json'] is None
|
||||
assert context['json_url'] == 'http://foo'
|
||||
assert context['json_status'] == 404
|
||||
assert context['json_error'] == data
|
||||
assert context['plop'] == None
|
||||
assert context['plop'] is None
|
||||
assert context['plop_url'] == 'http://bar'
|
||||
assert context['plop_status'] == 404
|
||||
assert context['plop_error'] == data
|
||||
|
@ -1228,13 +1228,13 @@ def test_config_json_cell_additional_url(app):
|
|||
assert resp.text.strip() == '/var1=bar/var2=bar/'
|
||||
assert len(requests_get.mock_calls) == 3
|
||||
assert requests_get.mock_calls[0][1][0] == 'http://foo'
|
||||
assert requests_get.mock_calls[0][-1]['log_errors'] == True
|
||||
assert requests_get.mock_calls[0][-1]['timeout'] == None
|
||||
assert requests_get.mock_calls[0][-1]['log_errors'] is True
|
||||
assert requests_get.mock_calls[0][-1]['timeout'] is None
|
||||
assert requests_get.mock_calls[1][1][0] == 'http://bar'
|
||||
assert requests_get.mock_calls[1][-1]['log_errors'] == False
|
||||
assert requests_get.mock_calls[1][-1]['log_errors'] is False
|
||||
assert requests_get.mock_calls[1][-1]['timeout'] == 42
|
||||
assert requests_get.mock_calls[2][1][0] == 'http://bar/bar'
|
||||
assert requests_get.mock_calls[2][-1]['log_errors'] == False
|
||||
assert requests_get.mock_calls[2][-1]['log_errors'] is False
|
||||
assert requests_get.mock_calls[2][-1]['timeout'] == 10
|
||||
context = cell.get_cell_extra_context({})
|
||||
assert context['json'] == data
|
||||
|
@ -1261,16 +1261,16 @@ def test_config_json_cell_additional_url(app):
|
|||
assert len(requests_get.mock_calls) == 2
|
||||
assert requests_get.mock_calls[0][1][0] == 'http://foo'
|
||||
context = cell.get_cell_extra_context({})
|
||||
assert context['json'] == None
|
||||
assert context['json'] is None
|
||||
assert context['json_url'] == 'http://foo'
|
||||
assert context['json_status'] == 404
|
||||
assert context['json_error'] == data
|
||||
assert context['plop'] == None
|
||||
assert context['plop'] is None
|
||||
assert context['plop_url'] == 'http://'
|
||||
assert context['plop_status'] == 404
|
||||
assert context['plop_error'] == data
|
||||
# plop2 url is empty, no request: None value, no status
|
||||
assert context['plop2'] == None
|
||||
assert context['plop2'] is None
|
||||
assert context['plop2_url'] == ''
|
||||
assert 'plop2_status' not in context
|
||||
assert 'plop2_error' not in context
|
||||
|
|
|
@ -656,7 +656,7 @@ def test_edit_payment_backend(app, admin_user):
|
|||
assert resp.location.endswith('/manage/lingo/paymentbackends/')
|
||||
payment_backend = PaymentBackend.objects.get(slug='slug1')
|
||||
assert payment_backend.label == 'label1-modified'
|
||||
assert payment_backend.service_options['consider_all_response_signed'] == True
|
||||
assert payment_backend.service_options['consider_all_response_signed'] is True
|
||||
assert payment_backend.service_options['number'] == 12
|
||||
assert payment_backend.service_options['choice'] == 'b'
|
||||
assert payment_backend.service_options['choices'] == ['a', 'b']
|
||||
|
|
|
@ -116,7 +116,7 @@ class MockUser:
|
|||
|
||||
@mock.patch('combo.utils.requests_wrapper.RequestsSession.send')
|
||||
def test_remote_regie_active_invoices_cell(mock_send, remote_regie):
|
||||
assert remote_regie.is_remote() == True
|
||||
assert remote_regie.is_remote() is True
|
||||
assert remote_regie.can_pay_only_one_basket_item is False
|
||||
|
||||
page = Page(title='xxx', slug='test_basket_cell', template_name='standard')
|
||||
|
@ -163,7 +163,7 @@ def test_remote_regie_active_invoices_cell(mock_send, remote_regie):
|
|||
query = urlparse.parse_qs(querystring, keep_blank_values=True)
|
||||
assert query['NameID'][0] == 'r2d2'
|
||||
assert query['orig'][0] == 'combo'
|
||||
assert check_query(querystring, 'combo') == True
|
||||
assert check_query(querystring, 'combo') is True
|
||||
|
||||
# with no invoice
|
||||
ws_invoices = {'err': 0, 'data': []}
|
||||
|
@ -220,7 +220,7 @@ def test_remote_regie_active_invoices_cell_failure(mock_get, app, remote_regie):
|
|||
|
||||
@mock.patch('combo.utils.requests_wrapper.RequestsSession.send')
|
||||
def test_remote_regie_past_invoices_cell(mock_send, remote_regie):
|
||||
assert remote_regie.is_remote() == True
|
||||
assert remote_regie.is_remote() is True
|
||||
|
||||
page = Page(title='xxx', slug='test_basket_cell', template_name='standard')
|
||||
page.save()
|
||||
|
@ -292,7 +292,7 @@ def test_remote_regie_past_invoices_cell(mock_send, remote_regie):
|
|||
query = urlparse.parse_qs(querystring, keep_blank_values=True)
|
||||
assert query['NameID'][0] == 'r2d2'
|
||||
assert query['orig'][0] == 'combo'
|
||||
assert check_query(querystring, 'combo') == True
|
||||
assert check_query(querystring, 'combo') is True
|
||||
|
||||
# with no invoice
|
||||
ws_invoices = {'err': 0, 'data': []}
|
||||
|
@ -355,7 +355,7 @@ def test_remote_regie_past_invoices_cell_failure(mock_get, app, remote_regie):
|
|||
@mock.patch('combo.apps.lingo.models.Regie.pay_invoice')
|
||||
@mock.patch('combo.apps.lingo.models.requests.get')
|
||||
def test_anonymous_successful_item_payment(mock_get, mock_pay_invoice, app, remote_regie):
|
||||
assert remote_regie.is_remote() == True
|
||||
assert remote_regie.is_remote() is True
|
||||
encrypt_id = aes_hex_encrypt(settings.SECRET_KEY, force_bytes('F201601'))
|
||||
# invoice with amount_paid
|
||||
invoices = copy.deepcopy(INVOICES)
|
||||
|
@ -510,7 +510,7 @@ def test_pay_remote_item_failure(mock_get, mock_pay_invoice, app, remote_regie):
|
|||
|
||||
@mock.patch('combo.apps.lingo.models.requests.get')
|
||||
def test_anonymous_item_payment_email_error(mock_get, app, remote_regie):
|
||||
assert remote_regie.is_remote() == True
|
||||
assert remote_regie.is_remote() is True
|
||||
encrypt_id = aes_hex_encrypt(settings.SECRET_KEY, force_bytes('F201601'))
|
||||
mock_json = mock.Mock()
|
||||
mock_json.json.return_value = {'err': 0, 'data': INVOICES[0]}
|
||||
|
@ -526,7 +526,7 @@ def test_anonymous_item_payment_email_error(mock_get, app, remote_regie):
|
|||
|
||||
@mock.patch('combo.apps.lingo.models.requests.get')
|
||||
def test_wrong_crypted_item(mock_get, remote_regie, app):
|
||||
assert remote_regie.is_remote() == True
|
||||
assert remote_regie.is_remote() is True
|
||||
mock_json = mock.Mock()
|
||||
mock_json.json.return_value = {'err': 0, 'data': INVOICES[0]}
|
||||
mock_get.return_value = mock_json
|
||||
|
|
|
@ -37,7 +37,7 @@ def test_sign():
|
|||
assert query['orig'][0] == 'myself'
|
||||
assert query['email'][0] == ''
|
||||
assert query['NameID'][0] == ''
|
||||
assert check_query(querystring, 'secret') == True
|
||||
assert check_query(querystring, 'secret') is True
|
||||
|
||||
requests.get('/foo/bar/', remote_service=remote_service, without_user=True)
|
||||
url = send.call_args[0][0].url
|
||||
|
@ -47,7 +47,7 @@ def test_sign():
|
|||
assert query['orig'][0] == 'myself'
|
||||
assert 'email' not in query
|
||||
assert 'NameID' not in query
|
||||
assert check_query(querystring, 'secret') == True
|
||||
assert check_query(querystring, 'secret') is True
|
||||
|
||||
|
||||
def test_auto_sign():
|
||||
|
@ -58,7 +58,7 @@ def test_auto_sign():
|
|||
dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
|
||||
query = urlparse.parse_qs(querystring, keep_blank_values=True)
|
||||
assert query['orig'][0] == 'combo'
|
||||
assert check_query(querystring, 'combo') == True
|
||||
assert check_query(querystring, 'combo') is True
|
||||
|
||||
requests.get('http://doesnotexist/foo/bar/', remote_service='auto')
|
||||
assert send.call_args[0][0].url == 'http://doesnotexist/foo/bar/'
|
||||
|
@ -78,7 +78,7 @@ def test_sign_user():
|
|||
assert query['NameID'][0] == 'r2d2'
|
||||
assert 'email' not in query
|
||||
assert query['orig'][0] == 'myself'
|
||||
assert check_query(querystring, 'secret') == True
|
||||
assert check_query(querystring, 'secret') is True
|
||||
|
||||
requests.get('/foo/bar/', remote_service=remote_service, user=user, federation_key='email')
|
||||
url = send.call_args[0][0].url
|
||||
|
@ -88,7 +88,7 @@ def test_sign_user():
|
|||
assert query['email'][0] == 'foo@example.net'
|
||||
assert 'NameID' not in query
|
||||
assert query['orig'][0] == 'myself'
|
||||
assert check_query(querystring, 'secret') == True
|
||||
assert check_query(querystring, 'secret') is True
|
||||
|
||||
user = MockUser(samlized=False)
|
||||
|
||||
|
@ -100,7 +100,7 @@ def test_sign_user():
|
|||
assert 'NameID' not in query
|
||||
assert query['email'][0] == 'foo@example.net'
|
||||
assert query['orig'][0] == 'myself'
|
||||
assert check_query(querystring, 'secret') == True
|
||||
assert check_query(querystring, 'secret') is True
|
||||
|
||||
|
||||
def test_sign_anonymous_user():
|
||||
|
@ -117,7 +117,7 @@ def test_sign_anonymous_user():
|
|||
assert query['NameID'][0] == ''
|
||||
assert query['email'][0] == ''
|
||||
assert query['orig'][0] == 'myself'
|
||||
assert check_query(querystring, 'secret') == True
|
||||
assert check_query(querystring, 'secret') is True
|
||||
|
||||
|
||||
def test_requests_cache():
|
||||
|
|
Loading…
Reference in New Issue