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

Issue 499 bdd feature files #513

Open
wants to merge 14 commits into
base: release/2.1.3
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
4 changes: 2 additions & 2 deletions ebu_tt_live/config/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ def _ws_create_server_factory(self, listen, producer=None, consumer=None):

def _ws_create_client_factories(self, connect, producer=None, consumer=None, proxy=None):
factory_args = {}
if proxy:
factory_args.update({'host': proxy.host, 'port': proxy.port})
for dst in connect:
client_factory = self._websocket.BroadcastClientFactory(
url=dst.geturl(),
Expand All @@ -147,6 +145,8 @@ def _ws_create_client_factories(self, connect, producer=None, consumer=None, pro
**factory_args
)
client_factory.protocol = self._websocket.BroadcastClientProtocol
client_factory.proxy = proxy

client_factory.connect()

def ws_backend_producer(self, custom_producer, listen=None, connect=None, proxy=None):
Expand Down
6 changes: 1 addition & 5 deletions ebu_tt_live/config/carriage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from ebu_tt_live.carriage.direct import DirectCarriageImpl
from ebu_tt_live.carriage.websocket import WebsocketProducerCarriage, WebsocketConsumerCarriage
from ebu_tt_live.carriage import filesystem
from ebu_tt_live.utils import HTTPProxyConfig
from ebu_tt_live.strings import ERR_CONF_PROXY_CONF_VALUE, ERR_NO_SUCH_COMPONENT
from ebu_tt_live.errors import ConfigurationError
from ebu_tt_live.strings import CFG_FILENAME_PATTERN, CFG_MESSAGE_PATTERN
Expand Down Expand Up @@ -134,10 +133,7 @@ def parse_proxy_address(value):
match = proxy_regex.match(value)
if match:
# Ignoring the protocol part for now as it is only a http proxy
result = HTTPProxyConfig(
host=match.group('host'),
port=int(match.group('port'))
)
result = {u'host': match.group('host'), u'port': int(match.group('port'))}
elif value:
# In this case something was provided that isn't a falsy value but the parsing failed.
raise ConfigurationError(
Expand Down
3 changes: 2 additions & 1 deletion ebu_tt_live/ui/user_input_producer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ <h3>This is the User Input Producer (UIP).</h3>
<div class="doc-item-template doc-item">
<span>Seq.Num.: </span><span class="seqNum-value"></span><span> -- </span>
<span>Au.G.Id.: </span><span class="autGID-value"></span><span> -- </span>
<span>Au.G.C.Token: </span><snap class="autGCT-value"></snap>
<span>Au.G.C.Token: </span><span class="autGCT-value"></span>
</div>
<div class="message-item-template message-item">
<span>Message from sender: </span><span class="sender-value"></span>
<span> Payload: </span><span class="payload"></span>
</div>
</div>
<div id="result-view-div">
Expand Down
13 changes: 9 additions & 4 deletions ebu_tt_live/ui/user_input_producer/uip.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ $(document).ready(function() {
'urn:ebu:tt:livemessage', 'sender'
)[0].firstChild.nodeValue
);
clonedElement.find('.payload').text(
message.getElementsByTagNameNS(
'urn:ebu:tt:livemessage', 'payload'
)[0].firstChild.nodeValue
);

clonedElement.removeClass('message-item-template');
clonedElement.addClass('result-list-item');
Expand Down Expand Up @@ -512,7 +517,7 @@ $(document).ready(function() {

function renderHandoverMessageTemplate(template_data) {
var rendered_document = nunjucks.render(
'ebu_tt_live/ui/user_input_producer/template/live_message_template.xml',
'template/live_message_template.xml',
template_data
);
return rendered_document;
Expand Down Expand Up @@ -572,7 +577,7 @@ $(document).ready(function() {
var timeout = computeScheduledSendTimeout(media_offset);
var template_data = createTemplateDict();
var rendered_document = nunjucks.render(
'ebu_tt_live/ui/user_input_producer/template/user_input_producer_template.xml',
'template/user_input_producer_template.xml',
template_data
);

Expand All @@ -588,7 +593,7 @@ $(document).ready(function() {

function asyncSubmit() {
var template_data = createTemplateDict();
var rendered_document = nunjucks.render('ebu_tt_live/ui/user_input_producer/template/user_input_producer_template.xml', template_data);
var rendered_document = nunjucks.render('template/user_input_producer_template.xml', template_data);
renderSendDocument(rendered_document);
sequence_numbers[sequence_identifier] += 1;
localStorage.sequence_numbers = JSON.stringify(sequence_numbers);
Expand All @@ -600,7 +605,7 @@ $(document).ready(function() {
// If doc in not null then it was already rendered (needed for scheduled times : the document
// has to be rendered when the sending is scheduled not at effective sending time.
if (doc == null) {
rendered_document = nunjucks.render('ebu_tt_live/ui/user_input_producer/template/user_input_producer_template.xml', template_data);
rendered_document = nunjucks.render('template/user_input_producer_template.xml', template_data);
} else {
rendered_document = doc;
}
Expand Down
4 changes: 1 addition & 3 deletions ebu_tt_live/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,6 @@ def __call__(cls, *args, **kwargs):
instance = super(AutoRegisteringABCMeta, cls).__call__(*args, **kwargs)
return instance

HTTPProxyConfig = collections.namedtuple('HTTPProxyConfig', ['host', 'port'])


# The following section is taken from https://github.com/django/django/blob/master/django/test/utils.py
# This is a relatively simple XML comparator implementation based on Python's minidom library.
Expand Down Expand Up @@ -467,4 +465,4 @@ def first_node(document):
want_root = first_node(parseString(want))
got_root = first_node(parseString(got))

return check_element(want_root, got_root)
return check_element(want_root, got_root)
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
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
"ipdb>=0.10.1,<0.10.3", # This will eventually be removed from here
"configobj",
"pyyaml",
"service_identity",
"twisted",
"autobahn",
"autobahn<18",
"nltk",
"sortedcontainers",
"configman",
Expand Down
17 changes: 15 additions & 2 deletions testing/bdd/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@ def template_file_one(xml_file_1):
return j2_env.get_template(xml_file_1)

@then('a second xml file <xml_file_2>')
@pytest.fixture
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')),
trim_blocks=True)
return j2_env.get_template(xml_file_2)

# Calling fixtures directly is deprecated, this solution described at
# https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly
# seems to work, creating a named fixture rather than defining the "then"
# step as a fixture directly.
@pytest.fixture(name='template_file_two')
def template_file_two_fixture(xml_file_2):
return template_file_two(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>')
Expand Down Expand Up @@ -97,14 +104,20 @@ def gen_first_document(test_context, template_dict, template_file_one):
return document1

@then('the second document is generated')
@pytest.fixture
def gen_second_document(test_context, template_dict, template_file_two):
xml_file_2 = template_file_two.render(template_dict)
document2 = EBUTT3Document.create_from_xml(xml_file_2)
test_context['document2'] = document2
document2.validate()
return document2

# Calling fixtures directly is deprecated, this solution described at
# https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly
# seems to work, creating a named fixture rather than defining the "then"
# step as a fixture directly.
@pytest.fixture(name='gen_second_document')
def gen_second_document_fixture(test_context, template_dict, template_file_two):
return gen_second_document(test_context, template_dict, template_file_two)

@then('EBUTTD document is valid')
def then_ebuttd_document_valid(test_context):
Expand Down
16 changes: 9 additions & 7 deletions testing/bdd/features/styles/padding.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Feature: Compute padding on a single EBU-TT Live element
# Percentage relative to width and height of region.

Examples:
| xml_file | cell_resolution | style_attribute | elem_id |
| padding.xml | 10 10 | tts:padding | region1 |
| xml_file | cell_resolution | style_attribute | region_attribute | elem_id |
| padding.xml | 10 10 | tts:padding | tts:padding | R1 |


# Inheritence: region (S1) > div (S2) > p (S3) > span (S4)
Expand All @@ -16,15 +16,17 @@ Feature: Compute padding on a single EBU-TT Live element
Given an xml file <xml_file>
When it has a cell resolution of <cell_resolution>
And it contains style S1 with <style_attribute> value <S1_value>
And it contains <style_attribute> value <S2_value> applied to region
And region has attribute <region_attribute> set to <S2_value>
And the document is generated
Then the computed <style_attribute> in <elem_id> is <computed_value>

Examples:
| S1_value | S2_value | computed_value |
| 1% | 5% | 5% |
| 1c 1c | | 10% 10% 10% 10% |
| | 1c .5c 1c 0.5c | 10% 5% 10% 5% |
| S1_value | S2_value | computed_value |
| 1% | 5% | 5% |
@skip
# Skipping because the code doesn't actually do what this test thinks it should do!
| 1c 1c | *?Empty?* | 10% 10% 10% 10% |
| | 1c .5c 1c 0.5c | 10% 5% 10% 5% |



Expand Down
4 changes: 2 additions & 2 deletions testing/bdd/templates/padding.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<tt:style {% if attribute and value_1 != "*?Empty?*" %} {{ attribute }}="{{ value_1 }}" {% endif %} xml:id="S1" />
</tt:styling>
<tt:layout>
<tt:region xml:id="{{ elem_id }}" style="S1" tts:origin="0 0" tts:extent="100% 100%"
{% if attribute and value_2 != "*?Empty?*" %} {{ attribute }}="{{ value_2 }}" {% endif %} />
<tt:region xml:id="R1" style="S1" tts:origin="0% 0%" tts:extent="100% 100%"
{% if region_attribute and value_2 != "*?Empty?*" %} {{ region_attribute }}="{{ value_2 }}" {% endif %} />
</tt:layout>
</tt:head>
<tt:body begin="00:00:00.500" dur="00:00:05">
Expand Down
8 changes: 8 additions & 0 deletions testing/bdd/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
scenarios('features/styles/style_attribute_simple.feature')
scenarios('features/styles/style_attribute_inherited.feature')
scenarios('features/styles/lineHeight.feature')
scenarios('features/styles/fontSize_inherited.feature')
scenarios('features/styles/padding.feature')


@when('it has a cell resolution of <cell_resolution>')
Expand Down Expand Up @@ -100,3 +102,9 @@ def when_document_converted(test_context, local_time_mapping):
test_context['ebuttd_document'] = ebuttd_document
# TODO: Add the proper assertions
ebuttd_document.get_xml()


@when('region has attribute <region_attribute> set to <S2_value>')
def when_region_has_attribute(template_dict, region_attribute, S2_value):
template_dict['region_attribute'] = region_attribute
template_dict['value_2'] = S2_value