Ruff format

This commit is contained in:
2026-09-17 15:23:42 -07:00
parent e593996b65
commit f7808e2236
37 changed files with 1877 additions and 1399 deletions
+58 -35
View File
@@ -1,25 +1,26 @@
import unittest
from ptulsconv.docparser import parse_document
import os.path
import unittest
from ptulsconv.docparser import parse_document
class TestRobinHood1(unittest.TestCase):
path = os.path.dirname(__file__) + '/../export_cases/Robin Hood Spotting.txt'
path = os.path.dirname(__file__) + "/../export_cases/Robin Hood Spotting.txt"
def test_header_export(self):
with open(self.path,"r") as file:
with open(self.path, "r") as file:
session = parse_document(file.read())
self.assertIsNotNone(session.header)
self.assertEqual(session.header.session_name, 'Robin Hood Spotting')
self.assertEqual(session.header.session_name, "Robin Hood Spotting")
self.assertEqual(session.header.sample_rate, 48000.0)
self.assertEqual(session.header.bit_depth, 24)
self.assertEqual(session.header.timecode_fps, '29.97')
self.assertEqual(session.header.timecode_fps, "29.97")
self.assertEqual(session.header.timecode_drop_frame, False)
def test_all_sections(self):
with open(self.path,"r") as file:
with open(self.path, "r") as file:
session = parse_document(file.read())
self.assertIsNotNone(session.header)
@@ -31,52 +32,74 @@ class TestRobinHood1(unittest.TestCase):
def test_tracks(self):
with open(self.path,"r") as file:
with open(self.path, "r") as file:
session = parse_document(file.read())
self.assertEqual(len(session.tracks), 14)
self.assertListEqual(["Scenes", "Robin", "Will", "Marian", "John",
"Guy", "Much", "Butcher", "Town Crier",
"Soldier 1", "Soldier 2", "Soldier 3",
"Priest", "Guest at Court"],
list(map(lambda t: t.name, session.tracks)))
self.assertListEqual(["", "[ADR] {Actor=Errol Flynn} $CN=1",
"[ADR] {Actor=Patrick Knowles} $CN=2",
"[ADR] {Actor=Olivia DeHavilland} $CN=3",
"[ADR] {Actor=Claude Raines} $CN=4",
"[ADR] {Actor=Basil Rathbone} $CN=5",
"[ADR] {Actor=Herbert Mundin} $CN=6",
"[ADR] {Actor=George Bunny} $CN=101",
"[ADR] {Actor=Leonard Mundie} $CN=102",
"[ADR] $CN=103",
"[ADR] $CN=104",
"[ADR] $CN=105",
"[ADR] {Actor=Thomas R. Mills} $CN=106",
"[ADR] $CN=107"],
list(map(lambda t: t.comments, session.tracks)))
self.assertListEqual(
[
"Scenes",
"Robin",
"Will",
"Marian",
"John",
"Guy",
"Much",
"Butcher",
"Town Crier",
"Soldier 1",
"Soldier 2",
"Soldier 3",
"Priest",
"Guest at Court",
],
list(map(lambda t: t.name, session.tracks)),
)
self.assertListEqual(
[
"",
"[ADR] {Actor=Errol Flynn} $CN=1",
"[ADR] {Actor=Patrick Knowles} $CN=2",
"[ADR] {Actor=Olivia DeHavilland} $CN=3",
"[ADR] {Actor=Claude Raines} $CN=4",
"[ADR] {Actor=Basil Rathbone} $CN=5",
"[ADR] {Actor=Herbert Mundin} $CN=6",
"[ADR] {Actor=George Bunny} $CN=101",
"[ADR] {Actor=Leonard Mundie} $CN=102",
"[ADR] $CN=103",
"[ADR] $CN=104",
"[ADR] $CN=105",
"[ADR] {Actor=Thomas R. Mills} $CN=106",
"[ADR] $CN=107",
],
list(map(lambda t: t.comments, session.tracks)),
)
def test_a_track(self):
with open(self.path,"r") as file:
with open(self.path, "r") as file:
session = parse_document(file.read())
guy_track = session.tracks[5]
self.assertEqual(guy_track.name, 'Guy')
self.assertEqual(guy_track.comments, '[ADR] {Actor=Basil Rathbone} $CN=5')
self.assertEqual(guy_track.name, "Guy")
self.assertEqual(guy_track.comments, "[ADR] {Actor=Basil Rathbone} $CN=5")
self.assertEqual(guy_track.user_delay_samples, 0)
self.assertListEqual(guy_track.state, [])
self.assertEqual(len(guy_track.clips), 16)
self.assertEqual(guy_track.clips[5].channel, 1)
self.assertEqual(guy_track.clips[5].event, 6)
self.assertEqual(guy_track.clips[5].clip_name, "\"What's your name? You Saxon dog!\" $QN=GY106")
self.assertEqual(
guy_track.clips[5].clip_name,
'"What\'s your name? You Saxon dog!" $QN=GY106',
)
self.assertEqual(guy_track.clips[5].start_timecode, "01:04:19:15")
self.assertEqual(guy_track.clips[5].finish_timecode, "01:04:21:28")
self.assertEqual(guy_track.clips[5].duration, "00:00:02:13")
self.assertEqual(guy_track.clips[5].timestamp, None)
self.assertEqual(guy_track.clips[5].state, 'Unmuted')
self.assertEqual(guy_track.clips[5].state, "Unmuted")
def test_memory_locations(self):
with open(self.path,"r") as file:
with open(self.path, "r") as file:
session = parse_document(file.read())
self.assertEqual(len(session.markers), 1)
@@ -86,5 +109,5 @@ class TestRobinHood1(unittest.TestCase):
self.assertEqual(session.markers[0].units, "Samples")
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
+20 -16
View File
@@ -1,52 +1,56 @@
import unittest
from ptulsconv.docparser import parse_document
import os.path
import unittest
from ptulsconv.docparser import parse_document
class TestRobinHood5(unittest.TestCase):
path = os.path.dirname(__file__) + '/../export_cases/Robin Hood Spotting5.txt'
path = os.path.dirname(__file__) + "/../export_cases/Robin Hood Spotting5.txt"
def test_skipped_segments(self):
with open(self.path,"r") as file:
with open(self.path, "r") as file:
session = parse_document(file.read())
self.assertIsNone(session.files)
self.assertIsNone(session.clips)
def test_plugins(self):
with open(self.path,"r") as file:
with open(self.path, "r") as file:
session = parse_document(file.read())
self.assertEqual(len(session.plugins), 2)
def test_stereo_track(self):
with open(self.path,"r") as file:
with open(self.path, "r") as file:
session = parse_document(file.read())
self.assertEqual(session.tracks[1].name, 'MX WT (Stereo)')
self.assertEqual(session.tracks[1].name, "MX WT (Stereo)")
self.assertEqual(len(session.tracks[1].clips), 2)
self.assertEqual(session.tracks[1].clips[0].clip_name, 'RobinHood.1-01.L')
self.assertEqual(session.tracks[1].clips[1].clip_name, 'RobinHood.1-01.R')
self.assertEqual(session.tracks[1].clips[0].clip_name, "RobinHood.1-01.L")
self.assertEqual(session.tracks[1].clips[1].clip_name, "RobinHood.1-01.R")
def test_a_track(self):
with open(self.path,"r") as file:
with open(self.path, "r") as file:
session = parse_document(file.read())
guy_track = session.tracks[8]
self.assertEqual(guy_track.name, 'Guy')
self.assertEqual(guy_track.comments, '[ADR] {Actor=Basil Rathbone} $CN=5')
self.assertEqual(guy_track.name, "Guy")
self.assertEqual(guy_track.comments, "[ADR] {Actor=Basil Rathbone} $CN=5")
self.assertEqual(guy_track.user_delay_samples, 0)
self.assertListEqual(guy_track.state, ['Solo'])
self.assertListEqual(guy_track.state, ["Solo"])
self.assertEqual(len(guy_track.clips), 16)
self.assertEqual(guy_track.clips[5].channel, 1)
self.assertEqual(guy_track.clips[5].event, 6)
self.assertEqual(guy_track.clips[5].clip_name, "\"What's your name? You Saxon dog!\" $QN=GY106")
self.assertEqual(
guy_track.clips[5].clip_name,
'"What\'s your name? You Saxon dog!" $QN=GY106',
)
self.assertEqual(guy_track.clips[5].start_timecode, "01:04:19:15.00")
self.assertEqual(guy_track.clips[5].finish_timecode, "01:04:21:28.00")
self.assertEqual(guy_track.clips[5].duration, "00:00:02:13.00")
self.assertEqual(guy_track.clips[5].timestamp, "01:04:19:09.70")
self.assertEqual(guy_track.clips[5].state, 'Unmuted')
self.assertEqual(guy_track.clips[5].state, "Unmuted")
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
+18 -12
View File
@@ -1,33 +1,39 @@
import unittest
from ptulsconv.docparser import parse_document
import os.path
import unittest
from ptulsconv.docparser import parse_document
class TestRobinHood6(unittest.TestCase):
path = os.path.dirname(__file__) + '/../export_cases/Robin Hood Spotting6.txt'
path = os.path.dirname(__file__) + "/../export_cases/Robin Hood Spotting6.txt"
def test_a_track(self):
with open(self.path, "r") as file:
session = parse_document(file.read())
marian_track = session.tracks[6]
self.assertEqual(marian_track.name, 'Marian')
self.assertEqual(marian_track.comments, '[ADR] {Actor=Olivia DeHavilland} $CN=3')
self.assertEqual(marian_track.name, "Marian")
self.assertEqual(
marian_track.comments, "[ADR] {Actor=Olivia DeHavilland} $CN=3"
)
self.assertEqual(marian_track.user_delay_samples, 0)
self.assertListEqual(marian_track.state, ['Solo'])
self.assertListEqual(marian_track.state, ["Solo"])
self.assertEqual(len(marian_track.clips), 4)
self.assertListEqual(marian_track.plugins, ['Channel Strip (mono)', 'ReVibe II (mono/5.1)'])
self.assertListEqual(
marian_track.plugins, ["Channel Strip (mono)", "ReVibe II (mono/5.1)"]
)
self.assertEqual(marian_track.clips[2].channel, 1)
self.assertEqual(marian_track.clips[2].event, 3)
self.assertEqual(marian_track.clips[2].clip_name,
"\"Isn't that reason enough for a Royal Ward who must obey her guardian?\" $QN=M103")
self.assertEqual(
marian_track.clips[2].clip_name,
'"Isn\'t that reason enough for a Royal Ward who must obey her guardian?" $QN=M103',
)
self.assertEqual(marian_track.clips[2].start_timecode, "01:08:01:11")
self.assertEqual(marian_track.clips[2].finish_timecode, "01:08:04:24")
self.assertEqual(marian_track.clips[2].duration, "00:00:03:12")
self.assertEqual(marian_track.clips[2].timestamp, "01:08:01:11")
self.assertEqual(marian_track.clips[2].state, 'Unmuted')
self.assertEqual(marian_track.clips[2].state, "Unmuted")
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
+12 -9
View File
@@ -1,16 +1,17 @@
import unittest
from ptulsconv.docparser import parse_document
import os.path
import unittest
from ptulsconv.docparser import parse_document
class TestRobinHoodDF(unittest.TestCase):
path = os.path.dirname(__file__) + '/../export_cases/Robin Hood SpottingDF.txt'
path = os.path.dirname(__file__) + "/../export_cases/Robin Hood SpottingDF.txt"
def test_header_export_df(self):
with open(self.path, "r") as file:
session = parse_document(file.read())
self.assertEqual(session.header.timecode_drop_frame, True)
def test_a_track(self):
@@ -19,16 +20,18 @@ class TestRobinHoodDF(unittest.TestCase):
session = parse_document(file.read())
guy_track = session.tracks[4]
self.assertEqual(guy_track.name, 'Robin')
self.assertEqual(guy_track.comments, '[ADR] {Actor=Errol Flynn} $CN=1')
self.assertEqual(guy_track.name, "Robin")
self.assertEqual(guy_track.comments, "[ADR] {Actor=Errol Flynn} $CN=1")
self.assertEqual(guy_track.user_delay_samples, 0)
self.assertListEqual(guy_track.state, [])
self.assertEqual(len(guy_track.clips), 10)
self.assertEqual(guy_track.clips[5].channel, 1)
self.assertEqual(guy_track.clips[5].event, 6)
self.assertEqual(guy_track.clips[5].clip_name, "\"Hold there! What's his fault?\" $QN=R106")
self.assertEqual(
guy_track.clips[5].clip_name, '"Hold there! What\'s his fault?" $QN=R106'
)
self.assertEqual(guy_track.clips[5].start_timecode, "01:05:30;15")
self.assertEqual(guy_track.clips[5].finish_timecode, "01:05:32;01")
self.assertEqual(guy_track.clips[5].duration, "00:00:01;16")
self.assertEqual(guy_track.clips[5].timestamp, None)
self.assertEqual(guy_track.clips[5].state, 'Unmuted')
self.assertEqual(guy_track.clips[5].state, "Unmuted")
+11 -14
View File
@@ -1,28 +1,24 @@
import os
import os.path
import tempfile
import unittest
import tempfile
import sys
import os.path
import os
import glob
from ptulsconv import commands
class TestPDFExport(unittest.TestCase):
def test_report_generation(self):
"""
Setp through every text file in export_cases and make sure it can
Setp through every text file in export_cases and make sure it can
be converted into PDF docs without throwing an error
"""
files = []
files = [os.path.dirname(__file__) +
"/../export_cases/Robin Hood Spotting.txt"]
files = [os.path.dirname(__file__) + "/../export_cases/Robin Hood Spotting.txt"]
for path in files:
tempdir = tempfile.TemporaryDirectory()
os.chdir(tempdir.name)
try:
commands.convert(input_file=path, major_mode='doc')
commands.convert(input_file=path, major_mode="doc")
except Exception as e:
print("Error in test_report_generation")
print(f"File: {path}")
@@ -33,13 +29,14 @@ class TestPDFExport(unittest.TestCase):
def test_report_generation_track_markers(self):
files = []
files.append(os.path.dirname(__file__) +
"/../export_cases/Test for ptulsconv.txt")
files.append(
os.path.dirname(__file__) + "/../export_cases/Test for ptulsconv.txt"
)
for path in files:
tempdir = tempfile.TemporaryDirectory()
os.chdir(tempdir.name)
try:
commands.convert(input_file=path, major_mode='doc')
commands.convert(input_file=path, major_mode="doc")
except Exception as e:
print("Error in test_report_generation_track_markers")
print(f"File: {path}")
@@ -49,5 +46,5 @@ class TestPDFExport(unittest.TestCase):
tempdir.cleanup()
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
+24 -21
View File
@@ -1,38 +1,41 @@
import unittest
from ptulsconv.docparser.tag_compiler import Event
from ptulsconv.docparser.adr_entity import ADRLine, make_entity
from fractions import Fraction
from ptulsconv.docparser.adr_entity import ADRLine, make_entity
from ptulsconv.docparser.tag_compiler import Event
class TestADREntity(unittest.TestCase):
def test_event2line(self):
tags = {
'Ver': '1.0',
'Actor': "Bill",
'CN': "1",
'QN': 'J1001',
'R': 'Noise',
'EFF': 'EFF'
"Ver": "1.0",
"Actor": "Bill",
"CN": "1",
"QN": "J1001",
"R": "Noise",
"EFF": "EFF",
}
event = Event(clip_name='"This is a test." (sotto voce)',
track_name="Justin",
session_name="Test Project",
tags=tags,
start=Fraction(0, 1), finish=Fraction(1, 1))
event = Event(
clip_name='"This is a test." (sotto voce)',
track_name="Justin",
session_name="Test Project",
tags=tags,
start=Fraction(0, 1),
finish=Fraction(1, 1),
)
line = make_entity(event)
self.assertIsInstance(line, ADRLine)
self.assertEqual('Bill', line.actor_name)
self.assertEqual('Justin', line.character_name)
self.assertEqual("Bill", line.actor_name)
self.assertEqual("Justin", line.character_name)
self.assertEqual('"This is a test." (sotto voce)', line.prompt)
self.assertEqual('Noise', line.reason)
self.assertEqual('J1001', line.cue_number)
self.assertEqual("Noise", line.reason)
self.assertEqual("J1001", line.cue_number)
self.assertEqual(True, line.effort)
self.assertEqual('Test Project', line.title)
self.assertEqual('1.0', line.version)
self.assertEqual("Test Project", line.title)
self.assertEqual("1.0", line.version)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
+10 -4
View File
@@ -1,7 +1,9 @@
import unittest
from ptulsconv import broadcast_timecode
from fractions import Fraction
from ptulsconv import broadcast_timecode
class TestBroadcastTimecode(unittest.TestCase):
def test_basic_to_frame_count(self):
r1 = "01:00:00:00"
@@ -66,7 +68,9 @@ class TestBroadcastTimecode(unittest.TestCase):
def test_seconds_to_smpte(self):
secs = Fraction(25, 24)
frame_duration = Fraction(1, 24)
tc_format = broadcast_timecode.TimecodeFormat(frame_duration=frame_duration, logical_fps=24, drop_frame=False)
tc_format = broadcast_timecode.TimecodeFormat(
frame_duration=frame_duration, logical_fps=24, drop_frame=False
)
s1 = tc_format.seconds_to_smpte(secs)
self.assertEqual(s1, "00:00:01:01")
@@ -77,9 +81,11 @@ class TestBroadcastTimecode(unittest.TestCase):
def test_unparseable_timecode(self):
time_str = "11.32-19"
s1 = broadcast_timecode.smpte_to_frame_count(time_str, frames_per_logical_second=24)
s1 = broadcast_timecode.smpte_to_frame_count(
time_str, frames_per_logical_second=24
)
self.assertIsNone(s1)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
+14 -12
View File
@@ -1,24 +1,26 @@
import unittest
from ptulsconv.docparser.doc_entity import HeaderDescriptor
from fractions import Fraction
from ptulsconv.docparser.doc_entity import HeaderDescriptor
class DocParserTestCase(unittest.TestCase):
def test_header(self):
header = HeaderDescriptor(session_name="Test Session",
sample_rate=48000.0,
bit_depth=24,
start_timecode="00:59:52:00",
timecode_format="30",
timecode_drop_frame=False,
count_audio_tracks=0,
count_clips=0,
count_files=0)
header = HeaderDescriptor(
session_name="Test Session",
sample_rate=48000.0,
bit_depth=24,
start_timecode="00:59:52:00",
timecode_format="30",
timecode_drop_frame=False,
count_audio_tracks=0,
count_clips=0,
count_files=0,
)
self.assertEqual(header.session_name, "Test Session")
self.assertEqual(header.start_time, Fraction((59 * 60 + 52) * 30, 30))
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
+2 -2
View File
@@ -1,6 +1,8 @@
import unittest
from ptulsconv import footage
class TestFootage(unittest.TestCase):
def test_basic_footage(self):
r1 = "90+0"
@@ -11,5 +13,3 @@ class TestFootage(unittest.TestCase):
r1 = "1+8"
f1 = footage.footage_to_seconds(r1)
self.assertEqual(float(f1 or 0), 1.0)
+116 -82
View File
@@ -1,12 +1,11 @@
import unittest
from fractions import Fraction
import ptulsconv.docparser.tag_compiler
from ptulsconv.docparser import doc_entity
from fractions import Fraction
class TestTagCompiler(unittest.TestCase):
def test_one_track(self):
c = ptulsconv.docparser.tag_compiler.TagCompiler()
@@ -16,31 +15,48 @@ class TestTagCompiler(unittest.TestCase):
events = c.compile_events()
event1 = next(events)
self.assertEqual('This is clip 1', event1.clip_name)
self.assertEqual('Track 1', event1.track_name)
self.assertEqual('Test Session', event1.session_name)
self.assertEqual(dict(A='A',
Color='Blue',
Ver='1.1',
Mode='2',
Comment='This is some text in the comments',
Part='1'), event1.tags)
self.assertEqual("This is clip 1", event1.clip_name)
self.assertEqual("Track 1", event1.track_name)
self.assertEqual("Test Session", event1.session_name)
self.assertEqual(
dict(
A="A",
Color="Blue",
Ver="1.1",
Mode="2",
Comment="This is some text in the comments",
Part="1",
),
event1.tags,
)
self.assertEqual(Fraction(3600, 1), event1.start)
event2 = next(events)
self.assertEqual("This is the second clip ...and this is the last clip", event2.clip_name)
self.assertEqual('Track 1', event2.track_name)
self.assertEqual('Test Session', event2.session_name)
self.assertEqual(dict(R='Noise', A='A', B='B',
Color='Red',
Comment='This is some text in the comments',
N='1', Mode='2',
Ver='1.1',
M1='M1',
Part='2'), event2.tags)
self.assertEqual(
"This is the second clip ...and this is the last clip", event2.clip_name
)
self.assertEqual("Track 1", event2.track_name)
self.assertEqual("Test Session", event2.session_name)
self.assertEqual(
dict(
R="Noise",
A="A",
B="B",
Color="Red",
Comment="This is some text in the comments",
N="1",
Mode="2",
Ver="1.1",
M1="M1",
Part="2",
),
event2.tags,
)
self.assertEqual(c.session.header.convert_timecode('01:00:01:10'), event2.start)
self.assertEqual(c.session.header.convert_timecode('01:00:03:00'), event2.finish)
self.assertEqual(c.session.header.convert_timecode("01:00:01:10"), event2.start)
self.assertEqual(
c.session.header.convert_timecode("01:00:03:00"), event2.finish
)
self.assertIsNone(next(events, None))
@@ -51,76 +67,94 @@ class TestTagCompiler(unittest.TestCase):
all_tags = c.compile_tag_list()
self.assertTrue(all_tags['Mode'] == {'2', '1'})
self.assertTrue(all_tags["Mode"] == {"2", "1"})
@staticmethod
def make_test_session():
test_header = doc_entity.HeaderDescriptor(session_name="Test Session $Ver=1.1",
sample_rate=48000,
timecode_format="24",
timecode_drop_frame=False,
bit_depth=24,
start_timecode='00:59:00:00',
count_audio_tracks=1,
count_clips=3,
count_files=0
)
test_header = doc_entity.HeaderDescriptor(
session_name="Test Session $Ver=1.1",
sample_rate=48000,
timecode_format="24",
timecode_drop_frame=False,
bit_depth=24,
start_timecode="00:59:00:00",
count_audio_tracks=1,
count_clips=3,
count_files=0,
)
test_clips = [
doc_entity.TrackClipDescriptor(channel=1, event=1,
clip_name='This is clip 1 {Color=Blue} $Mode=2',
start_time='01:00:00:00',
finish_time='01:00:01:03',
duration='00:00:01:03',
state='Unmuted',
timestamp=None),
doc_entity.TrackClipDescriptor(channel=1, event=2,
clip_name='This is the second clip {R=Noise} [B] $Mode=2',
start_time='01:00:01:10',
finish_time='01:00:02:00',
duration='00:00:00:14',
state='Unmuted',
timestamp=None),
doc_entity.TrackClipDescriptor(channel=1, event=3,
clip_name='& ...and this is the last clip $N=1 $Mode=2',
start_time='01:00:02:00',
finish_time='01:00:03:00',
duration='00:00:01:00',
state='Unmuted',
timestamp=None),
doc_entity.TrackClipDescriptor(
channel=1,
event=1,
clip_name="This is clip 1 {Color=Blue} $Mode=2",
start_time="01:00:00:00",
finish_time="01:00:01:03",
duration="00:00:01:03",
state="Unmuted",
timestamp=None,
),
doc_entity.TrackClipDescriptor(
channel=1,
event=2,
clip_name="This is the second clip {R=Noise} [B] $Mode=2",
start_time="01:00:01:10",
finish_time="01:00:02:00",
duration="00:00:00:14",
state="Unmuted",
timestamp=None,
),
doc_entity.TrackClipDescriptor(
channel=1,
event=3,
clip_name="& ...and this is the last clip $N=1 $Mode=2",
start_time="01:00:02:00",
finish_time="01:00:03:00",
duration="00:00:01:00",
state="Unmuted",
timestamp=None,
),
]
test_track = doc_entity.TrackDescriptor(
index=0,
name="Track 1 [A] {Color=Red} $Mode=1",
comments="{Comment=This is some text in the comments}",
user_delay_samples=0,
plugins=[],
state=[],
clips=test_clips)
comments="{Comment=This is some text in the comments}",
user_delay_samples=0,
plugins=[],
state=[],
clips=test_clips,
)
markers = [doc_entity.MarkerDescriptor(number=1,
location="01:00:00:00",
time_reference=48000 * 3600,
units="Samples",
name="Marker 1 {Part=1}",
comments="", track_marker=False,
),
doc_entity.MarkerDescriptor(number=2,
location="01:00:01:00",
time_reference=48000 * 3601,
units="Samples",
name="Marker 2 {Part=2}",
comments="[M1]", track_marker=False,
),
]
markers = [
doc_entity.MarkerDescriptor(
number=1,
location="01:00:00:00",
time_reference=48000 * 3600,
units="Samples",
name="Marker 1 {Part=1}",
comments="",
track_marker=False,
),
doc_entity.MarkerDescriptor(
number=2,
location="01:00:01:00",
time_reference=48000 * 3601,
units="Samples",
name="Marker 2 {Part=2}",
comments="[M1]",
track_marker=False,
),
]
test_session = doc_entity.SessionDescriptor(header=test_header,
tracks=[test_track],
clips=[],
files=[],
markers=markers,
plugins=[])
test_session = doc_entity.SessionDescriptor(
header=test_header,
tracks=[test_track],
clips=[],
files=[],
markers=markers,
plugins=[],
)
return test_session
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
+6 -6
View File
@@ -1,6 +1,6 @@
import unittest
from ptulsconv.docparser.tagged_string_parser_visitor import parse_tags, TagPreModes
from ptulsconv.docparser.tagged_string_parser_visitor import TagPreModes, parse_tags
class TestTagInterpreter(unittest.TestCase):
@@ -17,12 +17,12 @@ class TestTagInterpreter(unittest.TestCase):
def test_tags(self):
s1 = parse_tags("{a=100}")
self.assertEqual(s1.tag_dict['a'], "100")
self.assertEqual(s1.tag_dict["a"], "100")
s2 = parse_tags("{b=This is a test} [option] $X=9")
self.assertEqual(s2.tag_dict['b'], 'This is a test')
self.assertEqual(s2.tag_dict['option'], 'option')
self.assertEqual(s2.tag_dict['X'], "9")
self.assertEqual(s2.tag_dict["b"], "This is a test")
self.assertEqual(s2.tag_dict["option"], "option")
self.assertEqual(s2.tag_dict["X"], "9")
def test_modes(self):
s1 = parse_tags("@ Monday Tuesday {a=1}")
@@ -35,5 +35,5 @@ class TestTagInterpreter(unittest.TestCase):
self.assertEqual(s3.mode, TagPreModes.APPEND)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
+35 -20
View File
@@ -1,15 +1,18 @@
import unittest
from ptulsconv.docparser import doc_entity, pt_doc_parser, tag_compiler
import os.path
import unittest
from ptulsconv.docparser import doc_entity, pt_doc_parser, tag_compiler
class TaggingIntegratedTests(unittest.TestCase):
path = os.path.dirname(__file__) + '/../export_cases/Tag Tests/Tag Tests.txt'
path = os.path.dirname(__file__) + "/../export_cases/Tag Tests/Tag Tests.txt"
def test_event_list(self):
with open(self.path, 'r') as f:
with open(self.path, "r") as f:
document_ast = pt_doc_parser.protools_text_export_grammar.parse(f.read())
document: doc_entity.SessionDescriptor = pt_doc_parser.DocParserVisitor().visit(document_ast)
document: doc_entity.SessionDescriptor = (
pt_doc_parser.DocParserVisitor().visit(document_ast)
)
compiler = tag_compiler.TagCompiler()
compiler.session = document
@@ -27,9 +30,11 @@ class TaggingIntegratedTests(unittest.TestCase):
self.assertEqual("Region 04", events[8].clip_name)
def test_append(self):
with open(self.path, 'r') as f:
with open(self.path, "r") as f:
document_ast = pt_doc_parser.protools_text_export_grammar.parse(f.read())
document: doc_entity.SessionDescriptor = pt_doc_parser.DocParserVisitor().visit(document_ast)
document: doc_entity.SessionDescriptor = (
pt_doc_parser.DocParserVisitor().visit(document_ast)
)
compiler = tag_compiler.TagCompiler()
compiler.session = document
@@ -39,20 +44,26 @@ class TaggingIntegratedTests(unittest.TestCase):
self.assertEqual("Dolor sic amet the rain in spain", events[2].clip_name)
self.assertEqual(document.header.convert_timecode("01:00:10:00"), events[2].start)
self.assertEqual(document.header.convert_timecode("01:00:25:00"), events[2].finish)
self.assertEqual(
document.header.convert_timecode("01:00:10:00"), events[2].start
)
self.assertEqual(
document.header.convert_timecode("01:00:25:00"), events[2].finish
)
self.assertIn('X', events[2].tags.keys())
self.assertIn('ABC', events[2].tags.keys())
self.assertIn('A', events[2].tags.keys())
self.assertEqual('302', events[2].tags['X'])
self.assertEqual('ABC', events[2].tags['ABC'])
self.assertEqual('1', events[2].tags['A'])
self.assertIn("X", events[2].tags.keys())
self.assertIn("ABC", events[2].tags.keys())
self.assertIn("A", events[2].tags.keys())
self.assertEqual("302", events[2].tags["X"])
self.assertEqual("ABC", events[2].tags["ABC"])
self.assertEqual("1", events[2].tags["A"])
def test_successive_appends(self):
with open(self.path, 'r') as f:
with open(self.path, "r") as f:
document_ast = pt_doc_parser.protools_text_export_grammar.parse(f.read())
document: doc_entity.SessionDescriptor = pt_doc_parser.DocParserVisitor().visit(document_ast)
document: doc_entity.SessionDescriptor = (
pt_doc_parser.DocParserVisitor().visit(document_ast)
)
compiler = tag_compiler.TagCompiler()
compiler.session = document
@@ -62,9 +73,13 @@ class TaggingIntegratedTests(unittest.TestCase):
self.assertEqual("A B C", events[3].clip_name)
self.assertEqual(document.header.convert_timecode("01:00:15:00"), events[3].start)
self.assertEqual(document.header.convert_timecode("01:00:45:00"), events[3].finish)
self.assertEqual(
document.header.convert_timecode("01:00:15:00"), events[3].start
)
self.assertEqual(
document.header.convert_timecode("01:00:45:00"), events[3].finish
)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()
+3 -3
View File
@@ -8,13 +8,13 @@ class MyTestCase(unittest.TestCase):
v = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
expected = [1, 2, 7, 5, 6, 15, 9, 10]
should = (lambda x, y: y % 4 == 0)
do_combine = (lambda x, y: x + y)
should = lambda x, y: y % 4 == 0
do_combine = lambda x, y: x + y
r = apply_appends(iter(v), should, do_combine)
r1 = list(r)
self.assertEqual(r1, expected)
if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()