transmission: Implement upload torrent functional test

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2018-10-03 11:48:36 -07:00 committed by James Valleroy
parent a214e64175
commit eea5d6b754
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
4 changed files with 63 additions and 0 deletions

Binary file not shown.

View File

@ -32,3 +32,9 @@ Scenario: Disable transmission application
Given the transmission application is enabled
When I disable the transmission application
Then the transmission site should not be available
Scenario: Upload a torrent to transmission
Given the transmission application is enabled
When all torrents are removed from transmission
And I upload a sample torrent to transmission
Then there should be 1 torrents listed in transmission

View File

@ -133,3 +133,21 @@ def repro_delete_config(browser):
@then('the repro configuration should be restored')
def repro_is_configured(browser):
assert site.repro_is_configured(browser)
@when('all torrents are removed from transmission')
def transmission_remove_all_torrents(browser):
site.transmission_remove_all_torrents(browser)
@when('I upload a sample torrent to transmission')
def transmission_upload_sample_torrent(browser):
site.transmission_upload_sample_torrent(browser)
@then(
parsers.parse(
'there should be {torrents_number:d} torrents listed in transmission'
))
def transmission_assert_number_of_torrents(browser, torrents_number):
assert torrents_number == site.transmission_get_number_of_torrents(browser)

View File

@ -224,3 +224,42 @@ def jsxc_has_contact(browser):
jsxc_login(browser)
contact = browser.find_by_text('alice@localhost')
return bool(contact)
def transmission_remove_all_torrents(browser):
"""Remove all torrents from transmission."""
browser.visit(config['DEFAULT']['url'] + '/transmission')
while True:
torrents = browser.find_by_css('#torrent_list .torrent')
if not torrents:
break
torrents.first.click()
eventually(browser.is_element_not_present_by_css,
args=['#toolbar-remove.disabled'])
browser.click_link_by_id('toolbar-remove')
eventually(browser.is_element_not_present_by_css,
args=['#dialog-container[style="display: none;"]'])
browser.click_link_by_id('dialog_confirm_button')
eventually(browser.is_element_present_by_css,
args=['#toolbar-remove.disabled'])
def transmission_upload_sample_torrent(browser):
"""Upload a sample torrent into transmission."""
browser.visit(config['DEFAULT']['url'] + '/transmission')
file_path = os.path.join(
os.path.dirname(__file__), '..', 'data', 'sample.torrent')
browser.click_link_by_id('toolbar-open')
eventually(browser.is_element_not_present_by_css,
args=['#upload-container[style="display: none;"]'])
browser.attach_file('torrent_files[]', [file_path])
browser.click_link_by_id('upload_confirm_button')
eventually(browser.is_element_present_by_css,
args=['#torrent_list .torrent'])
def transmission_get_number_of_torrents(browser):
"""Return the number torrents currently in transmission."""
browser.visit(config['DEFAULT']['url'] + '/transmission')
return len(browser.find_by_css('#torrent_list .torrent'))