예제 #1
0
def state_should_be_preserved_between_encode_and_decode():
    original = CookieStorage('name', 'namespace')
    request = factory.get('/')
    original.process_request(request)
    original.steps = {'step1': Step('step1')}
    # create new storage by decoding original
    restored = CookieStorage('name', 'namespace')
    restored.decode(original.encode())
    # they should be the same
    assert restored.encode() == original.encode()
예제 #2
0
def state_should_be_preserved_between_encode_and_decode():
    original = CookieStorage('name', 'namespace')
    request = factory.get('/')
    original.process_request(request)
    original.steps = {'step1': Step('step1')}
    # create new storage by decoding original
    restored = CookieStorage('name', 'namespace')
    restored.decode(original.encode())
    # they should be the same
    assert restored.encode() == original.encode()
예제 #3
0
def reset_should_clear_data():
    storage = CookieStorage('name', 'namespace')
    storage.steps = {'step1': Step('step1')}

    expected = '{"current_step":null,"steps":{"step1":{"files":null,"data":null}}}'
    assert storage.encode() == '%s$%s' % (storage.hmac(expected), expected)

    storage.reset()

    expected = '{"current_step":null,"steps":{}}'
    assert storage.encode() == '%s$%s' % (storage.hmac(expected), expected)
예제 #4
0
def reset_should_clear_data():
    storage = CookieStorage('name', 'namespace')
    storage.steps = {'step1': Step('step1')}

    expected = '{"current_step":null,"steps":{"step1":{"files":null,"data":null}}}'
    assert storage.encode() == '%s$%s' % (storage.hmac(expected), expected)

    storage.reset()

    expected = '{"current_step":null,"steps":{}}'
    assert storage.encode() == '%s$%s' % (storage.hmac(expected), expected)
예제 #5
0
def should_add_cookies_to_response():
    storage = CookieStorage('name', 'namespace')
    request, response = factory.get('/'), HttpResponse('')
    storage.process_request(request)
    storage.steps = {'step1': Step('step1')}
    storage.process_response(response)
    assert response.cookies[storage.key].value == storage.encode()
예제 #6
0
def should_add_cookies_to_response():
    storage = CookieStorage('name', 'namespace')
    request, response = factory.get('/'), HttpResponse('')
    storage.process_request(request)
    storage.steps = {'step1': Step('step1')}
    storage.process_response(response)
    assert response.cookies[storage.key].value == storage.encode()