]> git.phdru.name Git - mc/mc-torrent-vfs-tests.git/commitdiff
Tests(test_list_torrents): Handle torrent that lacks `creation_date`
authorOleg Broytman <phd@phdru.name>
Wed, 29 Jan 2025 00:31:52 +0000 (03:31 +0300)
committerOleg Broytman <phd@phdru.name>
Wed, 29 Jan 2025 00:31:52 +0000 (03:31 +0300)
Set fixed timestamp for 'leaves-metadata.torrent' file.

tests/test_list_torrents.py

index 38d9ca845c840b3cfa18b569799edd9d3ddeb4e2..b01f382eec82012a36eada696d1882b864560937 100755 (executable)
@@ -1,5 +1,7 @@
 #! /usr/bin/env python3
 
+from datetime import datetime
+from time import mktime
 import os
 import os.path
 import subprocess
@@ -19,6 +21,13 @@ def _get_filename(line):
 
 def _test1(basename):
     torrent_file = os.path.join(test_torrents_dir, basename + '.torrent')
+
+    if basename == 'leaves-metadata':
+        # The torrent lacks creation_date field, set fixd timestamp
+        leaves_metadata_dt = datetime(2016, 3, 16, 19, 33)
+        timestamp = mktime(leaves_metadata_dt.timetuple())
+        os.utime(torrent_file, (timestamp, timestamp))
+
     command = os.path.join(extfs_dir, 'torrent')
     pipe = subprocess.Popen([sys.executable, command, 'list', torrent_file],
                             stdout=subprocess.PIPE)