The sample test data

Here, we have a test case with a setUp() method that is run once at the start of the test suite and a tearDown() method that is run at the end.

Here is a subset of the contents linked to the test setup and teardown at the top of serverless-microservice-data-api/test/test_dynamo_get.py:

import unittest
import json

class TestIndexGetMethod(unittest.TestCase):
def setUp(self):
self.validJsonDataNoStartDate = json.loads('{"httpMethod":
"GET","path": "/path/to/resource/324","headers": ' 'null} ')
self.validJsonDataStartDate =
json.loads('{"queryStringParameters": {"startDate":
"20171013"},' '"httpMethod": "GET","path": "/path/to/resource
/324","headers": ' 'null} ')
self.invalidJsonUserIdData =
json.loads('{"queryStringParameters": {"startDate":
"20171013"},' '"httpMethod": "GET","path": "/path/to/resource
/324f","headers": ' 'null} ')
self.invalidJsonData = "{ invalid JSON request!} "
def tearDown(self):
pass

I created four different JSON Python dictionaries:

  • self.validJsonDataNoStartDate: A valid GET request with no StartDate filter
  • self.validJsonDataStartDate: A valid GET request with a StartDate filter
  • self.invalidJsonUserIdData: An invalid UserId that is not a number
  • self.invalidJsonData: Invalid JSON that cannot be parsed
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset