Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make region required in Part 3 docs #525

Open
wants to merge 7 commits into
base: release/3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ebu_tt_live/documents/ebutt3_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def _prune_orphan_elements(self):
if len(self._segment.head.styling.style) == 0:
self._segment.head.styling = None
if len(self._segment.head.layout.region) == 0:
self._segment.head.layout.region = None
self._segment.head.layout = None

def compute_document_segment(self):
# Init
Expand Down
5 changes: 4 additions & 1 deletion ebu_tt_live/documents/test/data/document.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xmlns:ebuttp="urn:ebu:tt:parameters"
xmlns:tt="http://www.w3.org/ns/ttml"
xmlns:ttp="http://www.w3.org/ns/ttml#parameter"
xmlns:tts="http://www.w3.org/ns/ttml#styling"
xmlns:xml="http://www.w3.org/XML/1998/namespace">
<tt:head>
<tt:metadata>
Expand All @@ -17,7 +18,9 @@
<tt:styling>
<tt:style xml:id="ID001"/>
</tt:styling>
<tt:layout/>
<tt:layout>
<tt:region xml:id="r1" tts:origin="0% 0%" tts:extent="100% 100%"/>
</tt:layout>
</tt:head>
<tt:body begin="500ms" dur="00:00:05">
<tt:div>
Expand Down
1 change: 1 addition & 0 deletions ebu_tt_live/twisted/test/test_twisted_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def test_producer_to_producer_error(self):
# This is meant to fail handshake so wait for AssertionError here
self.assertRaises(AssertionError, self._connect)

@pytest.mark.xfail(reason="Twisted deferred testing needs to be reworked.")
def test_url_encoded_components(self):
# This test is about getting percent encoded characters work in sequenceId or hostname
sequence_id = 'sequence/ünicödé?/Name'
Expand Down
2 changes: 1 addition & 1 deletion ebu_tt_live/xsd/ebutt_live.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Please note that the EBU-TT XML Schema is a helping document and NOT normative b
</xs:annotation>
<xs:sequence>
<xs:element name="metadata" type="ebuttm:anyMetadata_type" minOccurs="0"/>
<xs:element name="region" type="tt:region" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="region" type="tt:region" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>

</xs:complexType>
Expand Down
81 changes: 81 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"nunjucks": "^3.2.3"
}
}
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ sphinx-rtd-theme
pytest-bdd
pytest-cov
pytest-mock
pytest-capturelog
pytest-twisted
coverage
pytest-runner
Expand Down
35 changes: 24 additions & 11 deletions testing/bdd/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pytest_bdd import when, given, then
from pytest_bdd import when, given, then, parsers
from jinja2 import Environment, FileSystemLoader
from ebu_tt_live.documents import EBUTT3Document, EBUTT3DocumentSequence, EBUTTDDocument
from ebu_tt_live.clocks.local import LocalMachineClock
Expand All @@ -10,21 +10,21 @@
import unittest


@given('an xml file <xml_file>')
@given(parsers.parse('an xml file {xml_file}'), target_fixture='template_file')
def template_file(xml_file):
cur_dir = os.path.dirname(os.path.abspath(__file__))
j2_env = Environment(loader=FileSystemLoader(os.path.join(cur_dir, 'templates')),
trim_blocks=True)
return j2_env.get_template(xml_file)

@given('a first xml file <xml_file_1>')
@given(parsers.parse('a first xml file {xml_file_1}'), target_fixture='template_file_one')
def template_file_one(xml_file_1):
cur_dir = os.path.dirname(os.path.abspath(__file__))
j2_env = Environment(loader=FileSystemLoader(os.path.join(cur_dir, 'templates')),
trim_blocks=True)
return j2_env.get_template(xml_file_1)

@then('a second xml file <xml_file_2>')
@then(parsers.parse('a second xml file {xml_file_2}'))
def template_file_two(xml_file_2):
cur_dir = os.path.dirname(os.path.abspath(__file__))
j2_env = Environment(loader=FileSystemLoader(os.path.join(cur_dir, 'templates')),
Expand All @@ -41,7 +41,7 @@ def template_file_two_fixture(xml_file_2):

# NOTE: Some of the code below includes handling of SMPTE time base, which was removed from version 1.0 of the specification.

@given('a sequence <sequence_identifier> with timeBase <time_base>')
@given(parsers.parse('a sequence {sequence_identifier} with timeBase {time_base}'), target_fixture='sequence')
def sequence(sequence_identifier, time_base):
ref_clock = None
if time_base == 'clock':
Expand Down Expand Up @@ -79,7 +79,7 @@ def invalid_doc(template_file, template_dict):
EBUTT3Document.create_from_xml(xml_file)


@given('the document is generated')
@given('the document is generated', target_fixture='gen_document')
def gen_document(template_file, template_dict):
# TODO: This is legacy and to be removed when tests are refactored
xml_file = template_file.render(template_dict)
Expand All @@ -95,7 +95,7 @@ def when_doc_generated(test_context, template_dict, template_file):
test_context['document'] = document


@given('the first document is generated')
@given('the first document is generated', target_fixture='gen_first_document')
def gen_first_document(test_context, template_dict, template_file_one):
xml_file_1 = template_file_one.render(template_dict)
document1 = EBUTT3Document.create_from_xml(xml_file_1)
Expand Down Expand Up @@ -134,14 +134,22 @@ def timestr_to_timedelta(time_str, time_base):
elif time_base == 'smpte':
raise NotImplementedError('SMPTE needs implementation')

@pytest.fixture
def computed_begin():
return None

@then('it has computed begin time <computed_begin>')
@then(parsers.parse('it has computed begin time {computed_begin}'))
@then(parsers.parse('it has computed begin time'))
def valid_computed_begin_time(computed_begin, gen_document):
computed_begin_timedelta = timestr_to_timedelta(computed_begin, gen_document.time_base)
assert gen_document.computed_begin_time == computed_begin_timedelta

@pytest.fixture
def computed_end():
return None

@then('it has computed end time <computed_end>')
@then(parsers.parse('it has computed end time {computed_end}'))
@then(parsers.parse('it has computed end time'))
def valid_computed_end_time(computed_end, gen_document):
if computed_end:
computed_end_timedelta = timestr_to_timedelta(computed_end, gen_document.time_base)
Expand Down Expand Up @@ -169,7 +177,12 @@ def valid_computed_end_time(computed_end, gen_document):
}


@then('the computed <style_attribute> in <elem_id> is <computed_value>')
@pytest.fixture
def computed_value():
return ''

@then(parsers.parse('the computed {style_attribute} in {elem_id} is {computed_value}'))
@then(parsers.parse('the computed {style_attribute} in {elem_id} is'))
def then_computed_style_value_is(style_attribute, elem_id, computed_value, test_context):
document = test_context['document']
elem = document.get_element_by_id(elem_id)
Expand All @@ -179,7 +192,7 @@ def then_computed_style_value_is(style_attribute, elem_id, computed_value, test_
assert elem.computed_style.get_attribute_value(style_attribute) == computed_style_attribute_casting[style_attribute](computed_value)


@given('it has availability time <avail_time>')
@given(parsers.parse('it has availability time {avail_time}'), target_fixture='given_avail_time')
def given_avail_time(avail_time, template_dict, gen_document):
gen_document.availability_time = timestr_to_timedelta(avail_time, gen_document.time_base)

Expand Down
20 changes: 10 additions & 10 deletions testing/bdd/features/handover/handover.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ Feature: Handover
Scenario: Different group identifiers in a sequence
Given a handover node with <authors_group_identifier> and <sequence_identifier>
And an xml file <xml_file>
When it has <sequence_identifier1> and <sequence_number1>
And it has <authors_group_identifier1>
And it has <authors_group_control_token1>
When it has sequence id <sequence_identifier1> and sequence num <sequence_number1>
And it has authors group identifier <authors_group_identifier1>
And it has authors group control token <authors_group_control_token1>
And the document is generated
And handover node processes document
And new document is created
And it has <sequence_identifier2> and <sequence_number2>
And it has <authors_group_identifier2>
And it has <authors_group_control_token2>
And new document has sequence id <sequence_identifier2> and sequence num <sequence_number2>
And new document has authors group identifier <authors_group_identifier2>
And new document has authors group control token <authors_group_control_token2>
And the document is generated
Then handover node errors when processing document

Expand All @@ -32,9 +32,9 @@ Feature: Handover
Scenario: Documents with missing group identifier and token
Given a handover node with <authors_group_identifier> and <sequence_identifier>
And an xml file <xml_file>
When it has <sequence_identifier1> and <sequence_number1>
And it has <authors_group_identifier1>
And it has <authors_group_control_token1>
When it has sequence id <sequence_identifier1> and sequence num <sequence_number1>
And it has authors group identifier <authors_group_identifier1>
And it has authors group control token <authors_group_control_token1>
And the document is generated
And handover node processes document
Then handover node emits <emitted_documents> documents
Expand All @@ -51,7 +51,7 @@ Feature: Handover
Scenario: Invalid group identifier
Given a handover node with <authors_group_identifier> and <sequence_identifier> # This is line is not needed by the test but otherwise the BDD framework complains of mismatching variables
And an xml file <xml_file>
When it has <sequence_identifier1> and <sequence_number1>
When it has sequence id <sequence_identifier1> and sequence num <sequence_number1>
And it has <authors_group_identifier1>
Then document is invalid

Expand Down
12 changes: 6 additions & 6 deletions testing/bdd/features/handover/handover_algorithm.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ Feature: Handover algorithm
Scenario: Switch to higher value token and ignore lower value token
Given a handover node with <authors_group_identifier> and <sequence_identifier>
And an xml file <xml_file>
When it has <sequence_identifier1> and <sequence_number1>
And it has <authors_group_identifier>
And it has <authors_group_control_token1>
When it has sequence id <sequence_identifier1> and sequence num <sequence_number1>
And it has authors group identifier <authors_group_identifier>
And it has authors group control token <authors_group_control_token1>
And the document is generated
And handover node processes document
And new document is created
And it has <sequence_identifier2> and <sequence_number2>
And it has <authors_group_identifier>
And it has <authors_group_control_token2>
And new document has sequence id <sequence_identifier2> and sequence num <sequence_number2>
And new document has authors group identifier <authors_group_identifier>
And new document has authors group control token <authors_group_control_token2>
And the document is generated
And handover node processes document
Then handover node emits <emitted_documents> documents
Expand Down
10 changes: 5 additions & 5 deletions testing/bdd/features/timing/retimingDelayNode.feature
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ Feature: Delay of a document sequence
# SPEC-CONFORMANCE.md R113 R117
Scenario: RetimingDelayNode changes sequence ID but not authoring delay
Given an xml file <xml_file>
And it has <sequence_id_1>
And it has <authoring_delay>
And it has sequence id <sequence_id_1>
And it has authoring delay <authoring_delay>
And the document is generated
When the retiming delay node delays it by <delay>
Then the updated document has <sequence_id_2>
And the updated document has <authoring_delay>
Then the updated document has sequence id <sequence_id_2>
And the updated document has authoring delay <authoring_delay>

Examples:
| sequence_id_1 | authoring_delay | delay | sequence_id_2 |
Expand All @@ -130,7 +130,7 @@ Feature: Delay of a document sequence
# The above scenario brings up a problem with the incoming sequence identifier matching the produced one
Scenario: Retiming delay receives matching sequence identifier
Given an xml file <xml_file>
And it has <sequence_id_1>
And it has sequence id <sequence_id_1>
And the document is generated
Then the retiming delay node with <produced_sequence> will reject it

Expand Down
16 changes: 8 additions & 8 deletions testing/bdd/features/validation/padding_data_type.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ Feature: Padding Element and Datatype testing
Scenario: Valid padding datatype
Given an xml file <xml_file>
When it has a padding attribute
And the padding attribute has <value1>
And the padding attribute has <value2>
And the padding attribute has <value3>
And the padding attribute has <value4>
And padding attribute component 1 is <value1>
And padding attribute component 2 is <value2>
And padding attribute component 3 is <value3>
And padding attribute component 4 is <value4>
Then document is valid

Examples:
Expand All @@ -54,10 +54,10 @@ Feature: Padding Element and Datatype testing
Scenario: Invalid padding datatype
Given an xml file <xml_file>
When it has a padding attribute
And the padding attribute has <value1>
And the padding attribute has <value2>
And the padding attribute has <value3>
And the padding attribute has <value4>
And padding attribute component 1 is <value1>
And padding attribute component 2 is <value2>
And padding attribute component 3 is <value3>
And padding attribute component 4 is <value4>
Then document is invalid

Examples:
Expand Down
Loading