Skip to content

Commit

Permalink
AFC: fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
matan1008 committed Dec 21, 2021
1 parent 075def9 commit 91c9f17
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/services/test_afc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from datetime import datetime

import pytest

from pymobiledevice3.exceptions import AfcException, AfcFileNotFoundError
from pymobiledevice3.services.afc import AfcService, afc_error_t, MAXIMUM_READ_SIZE

Expand Down Expand Up @@ -157,22 +158,24 @@ def test_isdir_missing_path_inside_a_file(afc: AfcService):
def test_stat_file(afc: AfcService):
data = b'data'
timestamp = datetime.fromtimestamp(afc.lockdown.get_value(key='TimeIntervalSince1970'))
timestamp = timestamp.replace(microsecond=0) # stat resolution might not include microseconds
afc.set_file_contents(TEST_FILENAME, data)
stat = afc.stat(TEST_FILENAME)
afc.rm(TEST_FILENAME)
assert stat['st_size'] == len(data)
assert stat['st_ifmt'] == 'S_IFREG'
assert stat['st_mtime'] > timestamp
assert stat['st_mtime'] >= timestamp


def test_stat_folder(afc: AfcService):
timestamp = datetime.fromtimestamp(afc.lockdown.get_value(key='TimeIntervalSince1970'))
timestamp = timestamp.replace(microsecond=0) # stat resolution might not include microseconds
afc.makedirs(TEST_FOLDER_NAME)
stat = afc.stat(TEST_FOLDER_NAME)
afc.rm(TEST_FOLDER_NAME)
assert stat['st_size'] == 64
assert stat['st_size'] in (64, 68)
assert stat['st_ifmt'] == 'S_IFDIR'
assert stat['st_mtime'] > timestamp
assert stat['st_mtime'] >= timestamp


@pytest.mark.parametrize('path', [
Expand Down

0 comments on commit 91c9f17

Please sign in to comment.