diff --git a/functional_tests/data/sample.torrent b/functional_tests/data/sample.torrent new file mode 100644 index 000000000..4c2ed6bf4 Binary files /dev/null and b/functional_tests/data/sample.torrent differ diff --git a/functional_tests/features/transmission.feature b/functional_tests/features/transmission.feature index 8ea511527..eef5c021f 100644 --- a/functional_tests/features/transmission.feature +++ b/functional_tests/features/transmission.feature @@ -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 diff --git a/functional_tests/step_definitions/site.py b/functional_tests/step_definitions/site.py index ab1ff9eae..54e812c27 100644 --- a/functional_tests/step_definitions/site.py +++ b/functional_tests/step_definitions/site.py @@ -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) diff --git a/functional_tests/support/site.py b/functional_tests/support/site.py index 29f0596a6..fa68bde01 100644 --- a/functional_tests/support/site.py +++ b/functional_tests/support/site.py @@ -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'))