File size: 1,289 Bytes
bbc23ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Exercise the deployment overlay with real files, including clone timestamp collisions."""
import os
from pathlib import Path
import shlex
import shutil
import subprocess

import pytest


def test_deployment_copies_same_size_changes_with_identical_timestamps(tmp_path):
    rsync = shutil.which('rsync')
    if not rsync:
        pytest.skip('rsync is required by the deployment runner')
    source, space = tmp_path/'source', tmp_path/'space'
    source.mkdir(); space.mkdir()
    new, old = source/'api.py', space/'api.py'
    new.write_text('version="1.7.1"\n'); old.write_text('version="1.7.0"\n')
    for file in (new, old):
        os.utime(file, (1700000000, 1700000000))
    assert new.stat().st_size == old.stat().st_size
    # Space-only files must survive the overlay.
    retained = space/'space-only.txt'
    retained.write_text('keep')
    workflow = Path(__file__).parents[1]/'.github/workflows/deploy-huggingface.yml'
    command = next(line.strip() for line in workflow.read_text().splitlines()
                   if line.strip().startswith('rsync '))
    arguments = shlex.split(command)
    subprocess.run([rsync, *arguments[1:-2], str(source)+'/', str(space)+'/'], check=True)
    assert old.read_bytes() == new.read_bytes()
    assert retained.read_text() == 'keep'