Web service dependencies are very common in client server application development. In many cases client application development may get completed before server, in such case client application cannot be tested fully as real services and data is not ready.

 Many tools are available to mock web services but they are not QA friendly, QA can’t pass different data sets easily to the mock services.

 So, here I have written a simple python script which exposes data of a csv file as a JSON via simple http rest services. These services can be consumed by client applications and QA to simulate real services and data. 

I have basic employee data in a csv file, here are the list of services which exposes data via python.

  • CSV Data

Services

  1. /emp – return all rows of the csv file as a JSON array.
  2. /emp/column/{csv column name} – It return all values of a csv column.
    • g. – /emp/column/City will return all Cities like “Seattle, Fairfax, ALDIE, Chantilly, Herndon”
  3. /emp/search/{search string} – It returns all rows of the csv file in a json array, where each row contains given string.
  4. /emp/search/{csv column name}/{searchString} – It works same like above service but the search is performed only in the given column name instead of on all columns.

Sample response format

The python script and employee data csv file are attached here. The script can be extended for multiple services for different need. I have used these services primarily to consume data in salesforce environment based on different search criteria.

Python Script and CSV file