Use ns time for geojson and gzipped geojson mtime
This commit is contained in:
parent
1be7950237
commit
f69c959f2a
2 changed files with 14 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from django.core.files.base import ContentFile
|
||||
|
@ -33,6 +34,17 @@ def test_get(client, settings, datalayer):
|
|||
assert j["type"] == "FeatureCollection"
|
||||
|
||||
|
||||
def test_gzip_should_be_created_if_accepted(client, datalayer, map, post_data):
|
||||
url = reverse("datalayer_view", args=(datalayer.pk,))
|
||||
response = client.get(url, headers={"ACCEPT_ENCODING": "gzip"})
|
||||
assert response.status_code == 200
|
||||
flat = datalayer.geojson.path
|
||||
gzipped = datalayer.geojson.path + ".gz"
|
||||
assert Path(flat).exists()
|
||||
assert Path(gzipped).exists()
|
||||
assert Path(flat).stat().st_mtime_ns == Path(gzipped).stat().st_mtime_ns
|
||||
|
||||
|
||||
def test_update(client, datalayer, map, post_data):
|
||||
url = reverse("datalayer_update", args=(map.pk, datalayer.pk))
|
||||
client.login(username=map.owner.username, password="123123")
|
||||
|
@ -49,6 +61,7 @@ def test_update(client, datalayer, map, post_data):
|
|||
j = json.loads(response.content.decode())
|
||||
assert "id" in j
|
||||
assert datalayer.pk == j["id"]
|
||||
assert Path(modified_datalayer.geojson.path).exists()
|
||||
|
||||
|
||||
def test_should_not_be_possible_to_update_with_wrong_map_id_in_url(
|
||||
|
|
|
@ -112,7 +112,7 @@ def gzip_file(from_path, to_path):
|
|||
with open(from_path, "rb") as f_in:
|
||||
with gzip.open(to_path, "wb") as f_out:
|
||||
f_out.writelines(f_in)
|
||||
os.utime(to_path, (stat.st_mtime, stat.st_mtime))
|
||||
os.utime(to_path, ns=(stat.st_mtime_ns, stat.st_mtime_ns))
|
||||
|
||||
|
||||
def is_ajax(request):
|
||||
|
|
Loading…
Reference in a new issue