Added some test cases and added another error message
This commit is contained in:
		| @@ -619,6 +619,9 @@ def receive_product_data(message): | |||||||
|     except sqlalchemy.exc.IntegrityError: |     except sqlalchemy.exc.IntegrityError: | ||||||
|         session.rollback() |         session.rollback() | ||||||
|         bot.send_message(chat_id=user_id, text='Product is in database already') |         bot.send_message(chat_id=user_id, text='Product is in database already') | ||||||
|  |     except pymysql.err.OperationalError: | ||||||
|  |         session.rollback() | ||||||
|  |         bot.send_message(chat_id=user_id, text='Unknown error') | ||||||
|  |  | ||||||
|  |  | ||||||
| @bot.callback_query_handler(func=lambda call: True) | @bot.callback_query_handler(func=lambda call: True) | ||||||
|   | |||||||
| @@ -20,6 +20,11 @@ def fetch_url(url): | |||||||
|  |  | ||||||
|     Raises: |     Raises: | ||||||
|         None: None |         None: None | ||||||
|  |  | ||||||
|  |     Test: | ||||||
|  |         What happens if url returns non 200 status code | ||||||
|  |         What happens if url returns 200 status code | ||||||
|  |         What happens if Firefox, Gecko or important libraries are not installed | ||||||
|     """ |     """ | ||||||
|     display = Display(visible=False, size=(800, 600)) |     display = Display(visible=False, size=(800, 600)) | ||||||
|     display.start() |     display.start() | ||||||
| @@ -57,6 +62,11 @@ def get_title(response): | |||||||
|  |  | ||||||
|     Raises: |     Raises: | ||||||
|         None: None |         None: None | ||||||
|  |  | ||||||
|  |     Test: | ||||||
|  |         Response contains meta tag with title attribute | ||||||
|  |         Response doesn't contain meta tag | ||||||
|  |         Response is invalid html | ||||||
|     """ |     """ | ||||||
|     soup = BeautifulSoup(response, 'html.parser') |     soup = BeautifulSoup(response, 'html.parser') | ||||||
|  |  | ||||||
| @@ -79,6 +89,12 @@ def get_image(response): | |||||||
|  |  | ||||||
|     Raises: |     Raises: | ||||||
|         None: None |         None: None | ||||||
|  |  | ||||||
|  |     Test: | ||||||
|  |         Response contains div with "imgTagWrapperId" id and includes json data | ||||||
|  |         Response doesn't contain div | ||||||
|  |         Response is invalid html | ||||||
|  |         JSON is not valid | ||||||
|     """ |     """ | ||||||
|     soup = BeautifulSoup(response, 'html.parser') |     soup = BeautifulSoup(response, 'html.parser') | ||||||
|  |  | ||||||
| @@ -111,6 +127,11 @@ def get_description(response): | |||||||
|  |  | ||||||
|     Raises: |     Raises: | ||||||
|         None: None |         None: None | ||||||
|  |  | ||||||
|  |     Test: | ||||||
|  |         Response contains div with "feature-bullets" id | ||||||
|  |         Response doesn't contain div | ||||||
|  |         Response is invalid html | ||||||
|     """ |     """ | ||||||
|     soup = BeautifulSoup(response, 'html.parser') |     soup = BeautifulSoup(response, 'html.parser') | ||||||
|  |  | ||||||
| @@ -139,6 +160,13 @@ def get_price(response): | |||||||
|  |  | ||||||
|     Raises: |     Raises: | ||||||
|         None: None |         None: None | ||||||
|  |  | ||||||
|  |     Test: | ||||||
|  |         Response contains div with class "twister-plus-buying-options-price-data" | ||||||
|  |         Response doesn't contain div | ||||||
|  |         No valid JSON | ||||||
|  |         Only price, currency missing | ||||||
|  |         Response is invalid html | ||||||
|     """ |     """ | ||||||
|     soup = BeautifulSoup(response, 'html.parser') |     soup = BeautifulSoup(response, 'html.parser') | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user