Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@
using namespace mqss::client;

nlohmann::json CircuitJobRequest::toJson(bool isHpc) const {
nlohmann::json circuit = mCircuit;

if (isHpc) {
circuit = nlohmann::json::array({mCircuit});
}

return {
{"circuit", std::move(circuit)}, {"circuit_format", mCircuitFormat},
{"resource_name", mResourceName}, {"shots", mShots},
{"no_modify", mNoModify}, {"queued", mQueued},
{"circuit",
isHpc ? nlohmann::json::array({mCircuit}) : nlohmann::json(mCircuit)},
{"circuit_format", mCircuitFormat},
{"resource_name", mResourceName},
{"shots", mShots},
{"no_modify", mNoModify},
{"queued", mQueued},
};
}

Expand Down
16 changes: 8 additions & 8 deletions tests/unit/c++/job_unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class MQSSClientTest : public ::testing::Test {
TEST_F(MQSSClientTest, SubmitJobSuccess) {
auto job = createCircuitJob();

EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson()))
EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson(1)))
.WillOnce(Return(kSubmitSuccess));

auto client = createClient();
Expand All @@ -105,7 +105,7 @@ TEST_F(MQSSClientTest, SubmitJobSuccess) {
TEST_F(MQSSClientTest, SubmitJobEmptyResponse) {
auto job = createCircuitJob();

EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson()))
EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson(1)))
.WillOnce(Return(""));

auto client = createClient();
Expand All @@ -116,7 +116,7 @@ TEST_F(MQSSClientTest, SubmitJobEmptyResponse) {
TEST_F(MQSSClientTest, SubmitJobInvalidJson) {
auto job = createCircuitJob();

EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson()))
EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson(1)))
.WillOnce(Return("not-json"));

auto client = createClient();
Expand All @@ -127,7 +127,7 @@ TEST_F(MQSSClientTest, SubmitJobInvalidJson) {
TEST_F(MQSSClientTest, SubmitJobMissingUuid) {
auto job = createCircuitJob();

EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson()))
EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson(1)))
.WillOnce(Return(R"({"status":"ok"})"));

auto client = createClient();
Expand Down Expand Up @@ -262,7 +262,7 @@ TEST_F(MQSSClientTest, GetJobResultInvalidJson) {
TEST_F(MQSSClientTest, SubmitHamiltonianJobSuccess) {
auto job = createHamiltonianJob();

EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson()))
EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson(0)))
.WillOnce(Return(kSubmitSuccess));

auto client = createClient();
Expand All @@ -277,7 +277,7 @@ TEST_F(MQSSClientTest, SubmitHamiltonianJobSuccess) {
TEST_F(MQSSClientTest, SubmitHamiltonianJobEmptyResponse) {
auto job = createHamiltonianJob();

EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson()))
EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson(0)))
.WillOnce(Return(""));

auto client = createClient();
Expand All @@ -288,7 +288,7 @@ TEST_F(MQSSClientTest, SubmitHamiltonianJobEmptyResponse) {
TEST_F(MQSSClientTest, SubmitHamiltonianJobInvalidJson) {
auto job = createHamiltonianJob();

EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson()))
EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson(0)))
.WillOnce(Return("not-json"));

auto client = createClient();
Expand All @@ -299,7 +299,7 @@ TEST_F(MQSSClientTest, SubmitHamiltonianJobInvalidJson) {
TEST_F(MQSSClientTest, SubmitHamiltonianJobMissingUuid) {
auto job = createHamiltonianJob();

EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson()))
EXPECT_CALL(*mock_ptr_, post(job.getPath(), job.toJson(0)))
.WillOnce(Return(R"({"status":"ok"})"));

auto client = createClient();
Expand Down
Loading