mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Added test for db.mtime_ns
This commit is contained in:
parent
3c5afaeb23
commit
4d798ca0e3
2 changed files with 14 additions and 2 deletions
|
|
@ -33,7 +33,7 @@ class Database:
|
|||
self.cached_table_counts = None
|
||||
self._write_thread = None
|
||||
self._write_queue = None
|
||||
if not self.is_mutable:
|
||||
if not self.is_mutable and not self.is_memory:
|
||||
p = Path(path)
|
||||
self.hash = inspect_hash(p)
|
||||
self.cached_size = p.stat().st_size
|
||||
|
|
@ -197,6 +197,8 @@ class Database:
|
|||
|
||||
@property
|
||||
def mtime_ns(self):
|
||||
if self.is_memory:
|
||||
return None
|
||||
return Path(self.path).stat().st_mtime_ns
|
||||
|
||||
@property
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"""
|
||||
Tests for the datasette.database.Database class
|
||||
"""
|
||||
from datasette.database import Results, MultipleValues
|
||||
from datasette.database import Database, Results, MultipleValues
|
||||
from datasette.utils import sqlite3
|
||||
from .fixtures import app_client
|
||||
import pytest
|
||||
|
|
@ -188,3 +188,13 @@ async def test_execute_write_fn_exception(db):
|
|||
|
||||
with pytest.raises(AssertionError):
|
||||
await db.execute_write_fn(write_fn, block=True)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_mtime_ns(db):
|
||||
assert isinstance(db.mtime_ns, int)
|
||||
|
||||
|
||||
def test_mtime_ns_is_none_for_memory(app_client):
|
||||
memory_db = Database(app_client.ds, is_memory=True)
|
||||
assert None is memory_db.mtime_ns
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue