mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-02 20:52:20 -07:00
STAR-322: Adding documentation and fixing model types
This commit is contained in:
parent
fa7cab3246
commit
7668801564
26 changed files with 411 additions and 282 deletions
|
|
@ -2,6 +2,7 @@
|
|||
"data": {
|
||||
"cluster_job_id": "9a59d8e9-91d3-4ff6-b4cb-9db91c4094dd",
|
||||
"job_id": "ABCDefGHIjKlMNOpQrSTUvYxWZ0-1234567890abcDE=",
|
||||
"status": "queued"
|
||||
"status": "queued",
|
||||
"generated_time": "2018-12-10T08:23:55.110Z"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
{
|
||||
"data": {
|
||||
"content_type": "text/plain",
|
||||
"download_url": "https://api.ultimaker.com/print-job-download",
|
||||
"job_id": "ABCDefGHIjKlMNOpQrSTUvYxWZ0-1234567890abcDE=",
|
||||
"job_name": "Ultimaker Robot v3.0",
|
||||
"status": "queued",
|
||||
"status": "uploading",
|
||||
"upload_url": "https://api.ultimaker.com/print-job-upload"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"data": {
|
||||
"cluster_job_id": "",
|
||||
"job_id": "db34b096-c4d5-46f3-bea7-da6a19905e6c",
|
||||
"status": "queued"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"data": {
|
||||
"content_type": "text/plain",
|
||||
"generated_time": "2018-12-10T09:33:00.009Z",
|
||||
"job_id": "j9KUn4D6FRRRmdtbCo4OGAwUf6Ml3p3oU-Zv7RNRv92T",
|
||||
"job_name": "job name",
|
||||
"status": "uploading",
|
||||
"status_description": "The print job has been created. Please upload the file.",
|
||||
"upload_url": "https://www.googleapis.com/upload/storage/v1/b/ultimaker-storage-1/o?uploadType=resumable&upload_id=AEnB2Uqhg1H7BXQVeLJEWw6AheqMicydZVLuH9bnkh6Oge0e6i5X76MW3NZHWRmUTmjzulAF42mkczcC7rsAuPg1Nn8JeFpnNA"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
import json
|
||||
import os
|
||||
from unittest import TestCase
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
|
@ -9,8 +8,9 @@ from unittest.mock import patch, MagicMock
|
|||
from cura.CuraApplication import CuraApplication
|
||||
from src.Cloud.CloudApiClient import CloudApiClient
|
||||
from src.Cloud.CloudOutputDeviceManager import CloudOutputDeviceManager
|
||||
from src.Cloud.Models.CloudJobResponse import CloudJobResponse
|
||||
from src.Cloud.Models.CloudJobUploadRequest import CloudJobUploadRequest
|
||||
from src.Cloud.Models.CloudPrintJobResponse import CloudPrintJobResponse
|
||||
from src.Cloud.Models.CloudPrintJobUploadRequest import CloudPrintJobUploadRequest
|
||||
from tests.Cloud.Fixtures import readFixture, parseFixture
|
||||
from .NetworkManagerMock import NetworkManagerMock
|
||||
|
||||
|
||||
|
|
@ -71,12 +71,11 @@ class TestCloudApiClient(TestCase):
|
|||
network_mock.return_value = self.network
|
||||
results = []
|
||||
|
||||
with open("{}/Fixtures/requestUploadResponse.json".format(os.path.dirname(__file__)), "rb") as f:
|
||||
response = f.read()
|
||||
response = readFixture("putJobUploadResponse")
|
||||
|
||||
self.network.prepareReply("PUT", "https://api-staging.ultimaker.com/cura/v1/jobs/upload", 200, response)
|
||||
self.api.requestUpload(CloudJobUploadRequest(job_name = "job name", file_size = 143234, content_type = "text/plain"),
|
||||
lambda r: results.append(r))
|
||||
request = CloudPrintJobUploadRequest(job_name = "job name", file_size = 143234, content_type = "text/plain")
|
||||
self.api.requestUpload(request, lambda r: results.append(r))
|
||||
self.network.flushReplies()
|
||||
|
||||
self.assertEqual(results[0].content_type, "text/plain")
|
||||
|
|
@ -87,13 +86,11 @@ class TestCloudApiClient(TestCase):
|
|||
results = []
|
||||
progress = MagicMock()
|
||||
|
||||
with open("{}/Fixtures/requestUploadResponse.json".format(os.path.dirname(__file__)), "rb") as f:
|
||||
thedata = json.loads(f.read().decode("ascii"))
|
||||
data = thedata["data"]
|
||||
upload_response = CloudJobResponse(**data)
|
||||
data = parseFixture("putJobUploadResponse")["data"]
|
||||
upload_response = CloudPrintJobResponse(**data)
|
||||
|
||||
self.network.prepareReply("PUT", upload_response.upload_url, 200,
|
||||
'{ data : "" }') # Network client doesn't look into the reply
|
||||
b'{ data : "" }') # Network client doesn't look into the reply
|
||||
|
||||
self.api.uploadMesh(upload_response, b'', lambda job_id: results.append(job_id),
|
||||
progress.advance, progress.error)
|
||||
|
|
@ -107,11 +104,11 @@ class TestCloudApiClient(TestCase):
|
|||
network_mock.return_value = self.network
|
||||
results = []
|
||||
|
||||
cluster_id = "NWKV6vJP_LdYsXgXqAcaNCR0YcLJwar1ugh0ikEZsZs8"
|
||||
job_id = "db34b096-c4d5-46f3-bea7-da6a19905e6c"
|
||||
response = readFixture("postJobPrintResponse")
|
||||
|
||||
with open("{}/Fixtures/requestPrintResponse.json".format(os.path.dirname(__file__)), "rb") as f:
|
||||
response = f.read()
|
||||
cluster_id = "NWKV6vJP_LdYsXgXqAcaNCR0YcLJwar1ugh0ikEZsZs8"
|
||||
cluster_job_id = "9a59d8e9-91d3-4ff6-b4cb-9db91c4094dd"
|
||||
job_id = "ABCDefGHIjKlMNOpQrSTUvYxWZ0-1234567890abcDE="
|
||||
|
||||
self.network.prepareReply("POST",
|
||||
"https://api-staging.ultimaker.com/connect/v1/clusters/{}/print/{}"
|
||||
|
|
@ -123,5 +120,6 @@ class TestCloudApiClient(TestCase):
|
|||
self.network.flushReplies()
|
||||
|
||||
self.assertEqual(len(results), 1)
|
||||
self.assertEqual(results[0].job_id, "db34b096-c4d5-46f3-bea7-da6a19905e6c")
|
||||
self.assertEqual(results[0].job_id, job_id)
|
||||
self.assertEqual(results[0].cluster_job_id, cluster_job_id)
|
||||
self.assertEqual(results[0].status, "queued")
|
||||
|
|
|
|||
|
|
@ -106,7 +106,9 @@ class TestCloudOutputDeviceManager(TestCase):
|
|||
|
||||
@patch("UM.Message.Message.show")
|
||||
def test_api_error(self, message_mock, network_mock):
|
||||
self.clusters_response = {"errors": [{"id": "notFound", "title": "Not found!", "http_status": "404"}]}
|
||||
self.clusters_response = {
|
||||
"errors": [{"id": "notFound", "title": "Not found!", "http_status": "404", "code": "notFound"}]
|
||||
}
|
||||
self.network.prepareReply("GET", self.URL, 200, self.clusters_response)
|
||||
self._loadData(network_mock)
|
||||
self.network.flushReplies()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue