update posting methods status/substatus, changed price index to multiple indexes in products responses

This commit is contained in:
diPhantxm
2023-04-12 01:26:08 +03:00
committed by Kirill
parent 838f28d3d9
commit 08180d901c
4 changed files with 311 additions and 14 deletions

View File

@@ -168,7 +168,24 @@ func TestGetProductDetails(t *testing.T) {
"has_stock": false,
"active_product": false
},
"price_index": "0.00",
"price_indexes": {
"external_index_data": {
"minimal_price": "string",
"minimal_price_currency": "string",
"price_index_value": 0
},
"ozon_index_data": {
"minimal_price": "string",
"minimal_price_currency": "string",
"price_index_value": 0
},
"price_index": "WITHOUT_INDEX",
"self_marketplaces_index_data": {
"minimal_price": "string",
"minimal_price_currency": "string",
"price_index_value": 0
}
},
"commissions": [],
"volume_weight": 0.1,
"is_prepayment": false,
@@ -233,7 +250,7 @@ func TestGetProductDetails(t *testing.T) {
"state_updated_at": "2021-10-21T15:48:03.927309Z"
}
}
}`,
}`,
},
// Test No Client-Id or Api-Key
{
@@ -2407,3 +2424,66 @@ func TestSetDiscountOnMarkdownProduct(t *testing.T) {
}
}
}
func TestNumberOfSubsToProductAvailability(t *testing.T) {
t.Parallel()
tests := []struct {
statusCode int
headers map[string]string
params *NumberOfSubsToProductAvailabilityParams
response string
}{
// Test Ok
{
http.StatusOK,
map[string]string{"Client-Id": "my-client-id", "Api-Key": "my-api-key"},
&NumberOfSubsToProductAvailabilityParams{
SKUS: []int64{1234},
},
`{
"result": [
{
"count": 2,
"sku": 1234
}
]
}`,
},
// Test No Client-Id or Api-Key
{
http.StatusUnauthorized,
map[string]string{},
&NumberOfSubsToProductAvailabilityParams{},
`{
"code": 16,
"message": "Client-Id and Api-Key headers are required"
}`,
},
}
for _, test := range tests {
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
resp, err := c.Products().NumberOfSubsToProductAvailability(test.params)
if err != nil {
t.Error(err)
}
if resp.StatusCode != test.statusCode {
t.Errorf("got wrong status code: got: %d, expected: %d", resp.StatusCode, test.statusCode)
}
if resp.StatusCode == http.StatusOK {
if len(resp.Result) != len(test.params.SKUS) {
t.Errorf("Length of SKUS in request and response are not equal")
}
if len(resp.Result) > 0 {
if resp.Result[0].SKU != test.params.SKUS[0] {
t.Errorf("SKU in request and response are not equal")
}
}
}
}
}