Forum Discussion

Olga_T's avatar
Olga_T
SmartBear Alumni (Retired)
7 years ago

[Week 12] - API Summer Winners & Script Tasks

 Hi all,

 

It’s Monday already, so I’m happy to announce our Week 12  API Summer 2018 winners:

 

1st place - $50 gift card

 @Lucian

with 22 points (TechCorner topic included)

2nd place - $35 gift card

@sanj

with 15 points

3rd place - $15 gift card

@aaronpliu

with 6 points

 

Congratulations, everyone!

 

We have only one week of API Summer left, so check out our additional tasks today and put forth your greatest effort to win! Create scripts based on these tasks and get 2 points to your score:

 

  • Dispatching based on the values in Request Body (ServiceV)

Create a REST virtual service from the Petstore Swagger specification and add a dispatching script for the "POST /v2/pet" resource. 

A sample request:

JSON

XML

{
"id" : 0,
"category" : {
"id" : 0,
"name" : "string"
},
"name" : "doggie",
"photoUrls" : [ "string" ],
"tags" : [ {
"id" : 0,
"name" : "string"
} ],
"status" : "available"
}

<Pet>
<id>0</id>
<Category>
<id>0</id>
<name>string</name>
</Category>
<name>doggie</name>
<photoUrl>
<photoUrls>string</photoUrls>
</photoUrl>
<tag>
<Tag>
<id>0</id>
<name>string</name>
</Tag>
</tag>
<status>available</status>
</Pet>

The dispatching condition:

 

- If the "name" property contains more than 3 characters, and the "status" value is one of

 

Unknown macro: {available, pending or sold}

 

 return the "OK" response (HTTP status code is 200, body is "{"result": "OK"}" or "<result>OK</result>" depending on the media type of the request).

 

- Otherwise, return the "Bad Request" response (HTTP status code is 400, body is "{"error": "Invalid Request"}" or "<error>Invalid Request</error>" depending on the media type of the request.

 

 

  • Enabling/disabling TestCases depending on tags values

Currently, you can pass the -T argument to force TestRunner to run only TestSuites or TestCases with specific tags. At that, if you pass several tags, the items containing all these tags (e.g. tag1 AND tag2 AND tagN) will be run.

Your task is to run TestCases and TestSuites which contain tag1 OR tag2 OR tagN.

 

For this, create a Project Setup script -

- which checks the values of the TestCaseTags and TestSuiteTags Global Properties (they are passed as command-line arguments and their format is "tag1,tag2,tagN");

- and which disables the corresponding items, which don't contain any of the listed tags. 

 

  • Adding and assigning a new tag

Create a script, which adds a new tag and assigns it to all TestCases within a TestSuite.

 

 

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Congratulation, Guys! Last week of API Summer has already been started. Who will win next week? I'm so excited :)