Projet

Général

Profil

0006-misc-fix-singleton-comparison-pylint-error-56288.patch

Lauréline Guérin, 30 août 2021 17:53

Télécharger (12,1 ko)

Voir les différences:

Subject: [PATCH 06/31] misc: fix singleton-comparison pylint error (#56288)

 tests/test_cells.py              | 28 ++++++++++++++--------------
 tests/test_lingo_manager.py      |  2 +-
 tests/test_lingo_remote_regie.py | 14 +++++++-------
 tests/test_requests.py           | 14 +++++++-------
 4 files changed, 29 insertions(+), 29 deletions(-)
tests/test_cells.py
580 580
    with mock.patch('combo.utils.requests.get') as requests_get:
581 581
        context = cell.get_cell_extra_context({})
582 582
        # can't get URL, 'foobar' variable is missing
583
        assert context['json'] == None
583
        assert context['json'] is None
584 584
        assert requests_get.call_count == 0
585 585
    request = RequestFactory().get('/')
586 586
    request.user = User(username='foo', email='foo@example.net')
......
825 825
            app.get(url)
826 826
            assert requests_get.call_count == 1
827 827
            assert requests_get.call_args[0][0] == 'http://foo?var=plop'
828
            assert requests_get.call_args[-1]['log_errors'] == False
828
            assert requests_get.call_args[-1]['log_errors'] is False
829 829
            assert requests_get.call_args[-1]['timeout'] == 42
830 830

  
831 831

  
......
1147 1147
            assert resp.text.strip() == '/var1=toto/var2=toto/'
1148 1148
            assert len(requests_get.mock_calls) == 2
1149 1149
            assert requests_get.mock_calls[0][1][0] == 'http://foo'
1150
            assert requests_get.mock_calls[0][-1]['log_errors'] == True
1151
            assert requests_get.mock_calls[0][-1]['timeout'] == None
1150
            assert requests_get.mock_calls[0][-1]['log_errors'] is True
1151
            assert requests_get.mock_calls[0][-1]['timeout'] is None
1152 1152
            assert requests_get.mock_calls[1][1][0] == 'http://bar'
1153
            assert requests_get.mock_calls[1][-1]['log_errors'] == False
1153
            assert requests_get.mock_calls[1][-1]['log_errors'] is False
1154 1154
            assert requests_get.mock_calls[1][-1]['timeout'] == 42
1155 1155

  
1156 1156
        with mock.patch('combo.utils.requests.get') as requests_get:
......
1168 1168
            assert requests_get.mock_calls[0][1][0] == 'http://foo'
1169 1169
            assert requests_get.mock_calls[1][1][0] == 'http://bar'
1170 1170
            context = cell.get_cell_extra_context({})
1171
            assert context['json'] == None
1171
            assert context['json'] is None
1172 1172
            assert context['json_url'] == 'http://foo'
1173 1173
            assert context['json_status'] == 404
1174 1174
            assert context['json_error'] == data
1175
            assert context['plop'] == None
1175
            assert context['plop'] is None
1176 1176
            assert context['plop_url'] == 'http://bar'
1177 1177
            assert context['plop_status'] == 404
1178 1178
            assert context['plop_error'] == data
......
1228 1228
            assert resp.text.strip() == '/var1=bar/var2=bar/'
1229 1229
            assert len(requests_get.mock_calls) == 3
1230 1230
            assert requests_get.mock_calls[0][1][0] == 'http://foo'
1231
            assert requests_get.mock_calls[0][-1]['log_errors'] == True
1232
            assert requests_get.mock_calls[0][-1]['timeout'] == None
1231
            assert requests_get.mock_calls[0][-1]['log_errors'] is True
1232
            assert requests_get.mock_calls[0][-1]['timeout'] is None
1233 1233
            assert requests_get.mock_calls[1][1][0] == 'http://bar'
1234
            assert requests_get.mock_calls[1][-1]['log_errors'] == False
1234
            assert requests_get.mock_calls[1][-1]['log_errors'] is False
1235 1235
            assert requests_get.mock_calls[1][-1]['timeout'] == 42
1236 1236
            assert requests_get.mock_calls[2][1][0] == 'http://bar/bar'
1237
            assert requests_get.mock_calls[2][-1]['log_errors'] == False
1237
            assert requests_get.mock_calls[2][-1]['log_errors'] is False
1238 1238
            assert requests_get.mock_calls[2][-1]['timeout'] == 10
1239 1239
            context = cell.get_cell_extra_context({})
1240 1240
            assert context['json'] == data
......
1261 1261
            assert len(requests_get.mock_calls) == 2
1262 1262
            assert requests_get.mock_calls[0][1][0] == 'http://foo'
1263 1263
            context = cell.get_cell_extra_context({})
1264
            assert context['json'] == None
1264
            assert context['json'] is None
1265 1265
            assert context['json_url'] == 'http://foo'
1266 1266
            assert context['json_status'] == 404
1267 1267
            assert context['json_error'] == data
1268
            assert context['plop'] == None
1268
            assert context['plop'] is None
1269 1269
            assert context['plop_url'] == 'http://'
1270 1270
            assert context['plop_status'] == 404
1271 1271
            assert context['plop_error'] == data
1272 1272
            # plop2 url is empty, no request: None value, no status
1273
            assert context['plop2'] == None
1273
            assert context['plop2'] is None
1274 1274
            assert context['plop2_url'] == ''
1275 1275
            assert 'plop2_status' not in context
1276 1276
            assert 'plop2_error' not in context
tests/test_lingo_manager.py
656 656
    assert resp.location.endswith('/manage/lingo/paymentbackends/')
657 657
    payment_backend = PaymentBackend.objects.get(slug='slug1')
658 658
    assert payment_backend.label == 'label1-modified'
659
    assert payment_backend.service_options['consider_all_response_signed'] == True
659
    assert payment_backend.service_options['consider_all_response_signed'] is True
660 660
    assert payment_backend.service_options['number'] == 12
661 661
    assert payment_backend.service_options['choice'] == 'b'
662 662
    assert payment_backend.service_options['choices'] == ['a', 'b']
tests/test_lingo_remote_regie.py
116 116

  
117 117
@mock.patch('combo.utils.requests_wrapper.RequestsSession.send')
118 118
def test_remote_regie_active_invoices_cell(mock_send, remote_regie):
119
    assert remote_regie.is_remote() == True
119
    assert remote_regie.is_remote() is True
120 120
    assert remote_regie.can_pay_only_one_basket_item is False
121 121

  
122 122
    page = Page(title='xxx', slug='test_basket_cell', template_name='standard')
......
163 163
    query = urlparse.parse_qs(querystring, keep_blank_values=True)
164 164
    assert query['NameID'][0] == 'r2d2'
165 165
    assert query['orig'][0] == 'combo'
166
    assert check_query(querystring, 'combo') == True
166
    assert check_query(querystring, 'combo') is True
167 167

  
168 168
    # with no invoice
169 169
    ws_invoices = {'err': 0, 'data': []}
......
220 220

  
221 221
@mock.patch('combo.utils.requests_wrapper.RequestsSession.send')
222 222
def test_remote_regie_past_invoices_cell(mock_send, remote_regie):
223
    assert remote_regie.is_remote() == True
223
    assert remote_regie.is_remote() is True
224 224

  
225 225
    page = Page(title='xxx', slug='test_basket_cell', template_name='standard')
226 226
    page.save()
......
292 292
    query = urlparse.parse_qs(querystring, keep_blank_values=True)
293 293
    assert query['NameID'][0] == 'r2d2'
294 294
    assert query['orig'][0] == 'combo'
295
    assert check_query(querystring, 'combo') == True
295
    assert check_query(querystring, 'combo') is True
296 296

  
297 297
    # with no invoice
298 298
    ws_invoices = {'err': 0, 'data': []}
......
355 355
@mock.patch('combo.apps.lingo.models.Regie.pay_invoice')
356 356
@mock.patch('combo.apps.lingo.models.requests.get')
357 357
def test_anonymous_successful_item_payment(mock_get, mock_pay_invoice, app, remote_regie):
358
    assert remote_regie.is_remote() == True
358
    assert remote_regie.is_remote() is True
359 359
    encrypt_id = aes_hex_encrypt(settings.SECRET_KEY, force_bytes('F201601'))
360 360
    # invoice with amount_paid
361 361
    invoices = copy.deepcopy(INVOICES)
......
510 510

  
511 511
@mock.patch('combo.apps.lingo.models.requests.get')
512 512
def test_anonymous_item_payment_email_error(mock_get, app, remote_regie):
513
    assert remote_regie.is_remote() == True
513
    assert remote_regie.is_remote() is True
514 514
    encrypt_id = aes_hex_encrypt(settings.SECRET_KEY, force_bytes('F201601'))
515 515
    mock_json = mock.Mock()
516 516
    mock_json.json.return_value = {'err': 0, 'data': INVOICES[0]}
......
526 526

  
527 527
@mock.patch('combo.apps.lingo.models.requests.get')
528 528
def test_wrong_crypted_item(mock_get, remote_regie, app):
529
    assert remote_regie.is_remote() == True
529
    assert remote_regie.is_remote() is True
530 530
    mock_json = mock.Mock()
531 531
    mock_json.json.return_value = {'err': 0, 'data': INVOICES[0]}
532 532
    mock_get.return_value = mock_json
tests/test_requests.py
37 37
        assert query['orig'][0] == 'myself'
38 38
        assert query['email'][0] == ''
39 39
        assert query['NameID'][0] == ''
40
        assert check_query(querystring, 'secret') == True
40
        assert check_query(querystring, 'secret') is True
41 41

  
42 42
        requests.get('/foo/bar/', remote_service=remote_service, without_user=True)
43 43
        url = send.call_args[0][0].url
......
47 47
        assert query['orig'][0] == 'myself'
48 48
        assert 'email' not in query
49 49
        assert 'NameID' not in query
50
        assert check_query(querystring, 'secret') == True
50
        assert check_query(querystring, 'secret') is True
51 51

  
52 52

  
53 53
def test_auto_sign():
......
58 58
        dummy, dummy, dummy, dummy, querystring, dummy = urlparse.urlparse(url)
59 59
        query = urlparse.parse_qs(querystring, keep_blank_values=True)
60 60
        assert query['orig'][0] == 'combo'
61
        assert check_query(querystring, 'combo') == True
61
        assert check_query(querystring, 'combo') is True
62 62

  
63 63
        requests.get('http://doesnotexist/foo/bar/', remote_service='auto')
64 64
        assert send.call_args[0][0].url == 'http://doesnotexist/foo/bar/'
......
78 78
        assert query['NameID'][0] == 'r2d2'
79 79
        assert 'email' not in query
80 80
        assert query['orig'][0] == 'myself'
81
        assert check_query(querystring, 'secret') == True
81
        assert check_query(querystring, 'secret') is True
82 82

  
83 83
        requests.get('/foo/bar/', remote_service=remote_service, user=user, federation_key='email')
84 84
        url = send.call_args[0][0].url
......
88 88
        assert query['email'][0] == 'foo@example.net'
89 89
        assert 'NameID' not in query
90 90
        assert query['orig'][0] == 'myself'
91
        assert check_query(querystring, 'secret') == True
91
        assert check_query(querystring, 'secret') is True
92 92

  
93 93
        user = MockUser(samlized=False)
94 94

  
......
100 100
        assert 'NameID' not in query
101 101
        assert query['email'][0] == 'foo@example.net'
102 102
        assert query['orig'][0] == 'myself'
103
        assert check_query(querystring, 'secret') == True
103
        assert check_query(querystring, 'secret') is True
104 104

  
105 105

  
106 106
def test_sign_anonymous_user():
......
117 117
        assert query['NameID'][0] == ''
118 118
        assert query['email'][0] == ''
119 119
        assert query['orig'][0] == 'myself'
120
        assert check_query(querystring, 'secret') == True
120
        assert check_query(querystring, 'secret') is True
121 121

  
122 122

  
123 123
def test_requests_cache():
124
-