Projet

Général

Profil

0001-tests-test-rate-limiting-with-freezegun-38180.patch

Benjamin Dauvergne, 03 janvier 2020 22:57

Télécharger (1,66 ko)

Voir les différences:

Subject: [PATCH] tests: test rate limiting with freezegun (#38180)

 tests/test_form_pages.py | 5 +++--
 tox.ini                  | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)
tests/test_form_pages.py
1499 1499
    assert resp.location == 'http://example.net/test/%s' % formdata_id
1500 1500
    resp = resp.follow()
1501 1501

  
1502
def test_form_tracking_code_rate_limit(pub):
1502
def test_form_tracking_code_rate_limit(pub, freezer):
1503 1503
    pub.load_site_options()
1504 1504
    if not pub.site_options.has_section('options'):
1505 1505
        pub.site_options.add_section('options')
......
1508 1508
        pub.site_options.write(fd)
1509 1509

  
1510 1510
    # twice
1511
    freezer.move_to('2018-12-01T00:00:00')
1511 1512
    get_app(pub).get('/code/ABC/load', status=404)
1512 1513
    get_app(pub).get('/code/ABC/load', status=404)
1513 1514
    # and out
1514 1515
    get_app(pub).get('/code/ABC/load', status=403)
1515 1516
    get_app(pub).get('/code/ABC/load', status=403)
1516 1517
    # wait two second
1517
    time.sleep(2)
1518
    freezer.move_to('2018-12-01T00:00:02')
1518 1519
    # and ok again
1519 1520
    get_app(pub).get('/code/ABC/load', status=404)
1520 1521

  
tox.ini
21 21
    pytest-mock
22 22
    pytest-cov
23 23
    pytest-django
24
    pytest-freezegun
24 25
    WebTest
25 26
    mechanize
26 27
    gadjo
27
-