bdd: Compare unordered req's for :reload --force.

This commit is contained in:
Florian Bruhin 2015-11-23 20:00:25 +01:00
parent 79680f505e
commit d4c24c935c
2 changed files with 14 additions and 1 deletions

View File

@ -23,6 +23,7 @@ import re
import time
import json
import logging
import collections
import yaml
import pytest_bdd as bdd
@ -118,6 +119,18 @@ def list_of_loaded_pages(httpbin, pages):
assert actual_requests == expected_requests
@bdd.then(bdd.parsers.parse("The unordered requests should be:\n{pages}"))
def list_of_loaded_pages_unordered(httpbin, pages):
expected_requests = [httpbin.ExpectedRequest('GET', '/' + path.strip())
for path in pages.split('\n')]
actual_requests = httpbin.get_requests()
# Requests are not hashable, we need to convert to ExpectedRequests
actual_requests = map(httpbin.ExpectedRequest.from_request,
actual_requests)
assert (collections.Counter(actual_requests) ==
collections.Counter(expected_requests))
@bdd.then(bdd.parsers.re(r'the (?P<category>error|message|warning) '
r'"(?P<message>.*)" should be shown.'))
def expect_error(quteproc, httpbin, category, message):

View File

@ -160,7 +160,7 @@ Feature: Various utility commands.
And I run :stop
And I open custom/redirect-later-continue in a new tab
And I wait 1s
Then the requests should be:
Then the unordered requests should be:
custom/redirect-later-continue
custom/redirect-later?delay=-1
# no request on / because we stopped the redirect