Prevnet assertion when .csv download link is not present.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 22 Nov 2017 18:56:25 +0000 (19:56 +0100)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 22 Nov 2017 18:56:25 +0000 (19:56 +0100)
bob_download.py

index b701d01..2e8d699 100755 (executable)
@@ -81,11 +81,14 @@ def main(username, password, destdir, csv_format):
         response = session.get(urljoin(response.url, url))  # e.g. 'https://rechnung.bob.at/bill.ctn.cdr.obp?bsn=79'
         assert response.ok
         html = BeautifulSoup(response.text, 'html.parser')
+        assert html.find('div', id='obp.calls.table')  # make sure we are on the right page
+
         if not html.find('a', id='link_csv_download'):
             filepath = os.path.join(destdir, 'debug_no_link_csv_download.txt')
             with open(filepath, 'wb') as file:
                 file.write(response.content)
-        assert html.find('a', id='link_csv_download')
+            continue
+
         response = session.get('https://rechnung.bob.at/obp/download.obp?fmt={}&table=obp.calls.table'.format(csv_format))
         assert response.ok
         filename = response.headers['Content-Disposition'].split('=')[1] # e.g. 'EVN_1509_523260091_1_069911934859.txt'