Beispiel #1
0
 def test_upload_product_picture_error(self):
     with patch("os.path.exists" ) as m_exist:
         with patch("builtins.open", mock_open()) as m_open:
             m_exist.return_value = True
             api_client = GrocyApiClient(CONST_BASE_URL, "demo_mode", port = CONST_PORT, verify_ssl = CONST_SSL)
             responses.add(responses.PUT, '{}:{}'.format(CONST_BASE_URL,CONST_PORT) + "/api/files/productpictures/MS5qcGc=", status=400)
             assert api_client.upload_product_picture(1,"/somepath/pic.jpg").status_code != 204
Beispiel #2
0
 def test_upload_product_picture_invalid_missing_data(self):
     with patch("os.path.exists") as m_exist:
         m_exist.return_value = False
         api_client = GrocyApiClient("https://example.com", "api_key")
         responses.add(
             responses.PUT,
             "https://example.com:9192/api/files/productpictures/MS5qcGc=",
             status=204)
         assert api_client.upload_product_picture(
             1, "/somepath/pic.jpg") is None
Beispiel #3
0
 def test_upload_product_picture_error(self):
     with patch("os.path.exists") as m_exist:
         with patch("builtins.open", mock_open()) as m_open:
             m_exist.return_value = True
             api_client = GrocyApiClient("https://example.com", "api_key")
             responses.add(
                 responses.PUT,
                 "https://example.com:9192/api/files/productpictures/MS5qcGc=",
                 status=400)
             assert api_client.upload_product_picture(
                 1, "/somepath/pic.jpg").status_code != 204
Beispiel #4
0
 def test_upload_product_picture_invalid_missing_data(self):
     with patch("os.path.exists" ) as m_exist:
         m_exist.return_value = False
         api_client = GrocyApiClient(CONST_BASE_URL, "demo_mode", port = CONST_PORT, verify_ssl = CONST_SSL)
         responses.add(responses.PUT, '{}:{}'.format(CONST_BASE_URL,CONST_PORT) + "/api/files/productpictures/MS5qcGc=", status=204)
         assert api_client.upload_product_picture(1,"/somepath/pic.jpg") is None