mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-15 09:51:21 +00:00
transmission: Implement upload torrent functional test
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
a214e64175
commit
eea5d6b754
BIN
functional_tests/data/sample.torrent
Normal file
BIN
functional_tests/data/sample.torrent
Normal file
Binary file not shown.
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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'))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user