Пример #1
0
    def test_expires_none(self):
        """Test case where expires is None."""

        morsel = Morsel()
        morsel['expires'] = None
        cookie = morsel_to_cookie(morsel)
        assert cookie.expires is None
Пример #2
0
    def test_expires_invalid_str(self):
        """Test case where an invalid string is input."""

        morsel = Morsel()
        morsel['expires'] = 'woops'
        with pytest.raises(ValueError):
            morsel_to_cookie(morsel)
Пример #3
0
    def test_expires_invalid_int(self):
        """Test case where an invalid type is passed for expires."""

        morsel = Morsel()
        morsel['expires'] = 100
        with pytest.raises(TypeError):
            morsel_to_cookie(morsel)
Пример #4
0
    def test_expires_valid_str(self):
        """Test case where we convert expires from string time."""

        morsel = Morsel()
        morsel['expires'] = 'Thu, 01-Jan-1970 00:00:01 GMT'
        cookie = morsel_to_cookie(morsel)
        assert cookie.expires == 1
    def test_max_age_invalid_str(self):
        """Test case where a invalid max age is passed."""

        morsel = Morsel()
        morsel['max-age'] = 'woops'
        with pytest.raises(TypeError):
            morsel_to_cookie(morsel)
    def test_max_age_valid_int(self):
        """Test case where a valid max age in seconds is passed."""

        morsel = Morsel()
        morsel['max-age'] = 60
        cookie = morsel_to_cookie(morsel)
        assert isinstance(cookie.expires, int)
Пример #7
0
def cloudflare_cookies():
    # Cloudflare cookie that should be set when challenge is presented
    cfduid = Morsel()
    cfduid.set('__cfduid', 'uid-1', 'uid-1')
    cfduid['path'] = '/'
    cfduid['domain'] = '.example-site.dev'

    # Cloudflare cookie that should be set when challenge is bypassed
    cf_clearance = Morsel()
    cf_clearance.set('cf_clearance', 'uid-2', 'uid-2')
    cf_clearance['path'] = '/'
    cf_clearance['domain'] = '.example-site.dev'

    return cfduid, cf_clearance
 def test_expires_invalid_int(self, value, exception):
     """Test case where an invalid type is passed for expires."""
     morsel = Morsel()
     morsel['expires'] = value
     with pytest.raises(exception):
         morsel_to_cookie(morsel)