mardi 1 décembre 2020

Mocha JS expect.to.not.have.key() Flask equivalent

I'm building a test suite in Flask python and I want to test that a cookie is not present in headers.

In Mocha, the equivalent would be

describe('GET /', function() {
    it('ensures cookie hasnt been set', function(done) {
        request.get('/')
        .expect(200)
        .end(function(err, res) {
            expect(res.headers).to.not.have.key("set-cookie");
            done(err);
        });
    });
});

Would it be the following?

def test_ensure_cookie_not_set(client):
    response = client.get('/')
    headers = response.headers.get('set-cookie')
    assert headers is None

Aucun commentaire:

Enregistrer un commentaire