Beispiel #1
0
def test_date_gmtime(date, expected, lt, gt):
	for d in (Date.parse(date.encode('utf-8')), Date(date)):
		assert d is not None
		assert d.gmtime == expected
		assert d == expected
		assert d == Date(date)

	assert gt > date
	assert lt < date
Beispiel #2
0
def test_repr(request_, response):
    to_test = (request_, request_.body, request_.method, request_.protocol,
               response, Message(), response.status, response.headers, Date())
    for e in to_test:
        assert repr(e).startswith('<HTTP')
        assert repr(e).endswith('>')

    assert repr(request_.uri).startswith('<URI')
    assert repr(request_.uri).endswith('>')
Beispiel #3
0
def test_date_timestamp(date, expected, lt, gt):
	for d in (Date.parse(date.encode('utf-8')), Date(date)):
		assert d is not None
		assert float(d) == expected
		assert d == expected
		assert d == Date(date)

	assert gt > date
	assert lt < date
Beispiel #4
0
    def if_range(self, client):
        if 'Range' not in client.request.headers:
            return
        if_range = client.request.headers.get('If-Range')
        if 'Etag' in client.response.headers:
            etag = client.response.headers.element('ETag')
            if etag == if_range:
                return

        if 'Last-Modified' in client.response.headers:
            last_modified = client.response.headers.element('Last-Modified')
            try:
                Date(if_range)
            except InvalidDate:
                pass
            else:
                if last_modified == if_range:
                    return

        raise EXPECTATION_FAILED('If-Range not satisfiable.')
 def _last_modified_header(self, client):
     if hasattr(client.resource, 'last_modified'):
         last_modified = client.resource.last_modified(client)
         if not isinstance(last_modified, (type(None), Date)):
             last_modified = Date(last_modified)
         return last_modified
Beispiel #6
0
def test_date_gmtime(date, expected):
    d = Date.parse(date)
    assert d is not None
    assert d.gmtime == expected
    assert d == expected
Beispiel #7
0
def test_date_timestamp(date, expected):
    d = Date.parse(date)
    assert d is not None
    assert float(d) == expected
    assert d == expected
Beispiel #8
0
def test_date_gmtime(date, expected):
	d = Date.parse(date)
	assert d is not None
	assert d.gmtime == expected
	assert d == expected
Beispiel #9
0
def test_date_timestamp(date, expected):
	d = Date.parse(date)
	assert d is not None
	assert float(d) == expected
	assert d == expected