RESORT

Helps you get better REST

resort logo

a server

class BasicHander(your.framework.RequestHandler):
    def get(self):
        '''a REST endpoint.'''
        self.set_status(HTTPStatus.OK)
        self.write("pong")
	
    
handlers = ((r'/ping', BasicHander),)
your.framework..Application(handlers=handlers).serve()

		

the boilerplate

$ resort create basic-rest-test
$ cd basic-rest-test

basic-rest-test/
  test_first.json
  config.json

					
  1. test_first.json - all the test_* files are Resort tests
  2. config.json - project settings (optional)

the test_first.json

{
  "paths": [
	["/api/foo"],
	["/api/bar", {"method": "POST", "json": [...]}],
  ],
  "server": {
	"url": "http://127.0.0.1:8888",
	"session": {
	"type": "post-request",
	  "create": ["/session", {"method": "POST", ...}],
	  "delete": ["/session", {"method": "DELETE"}]
}}}

					

the etalon

$ resort store

basic-rest-test/
  etalons/
    test_first_0_basic.et.json
    test_first_1_basic.et.json
  test_first.json

						

the diff

# introduce some changes to the server
$ resort check
test_first.json:
Nothing changed.

#whoray! no bad news is good news

						

python API

	import unittest
from resort.engine import ResortEngine
from resort.project import ResortProject

class TestBasicRESTServer(unittest.TestCase):

  def test_resort_all(self):
	  project_dir = pathlib.Path(__file__).parent
	  rp = ResortProject.read(project_dir)
	  self.assertIsNotNone(rp)
	  check_result = ResortEngine.check(rp)
	  self.assertEqual(check_result['changes'], 0)
	
							

Contacts

  • github.com/againagainst/resort
  • @againagainst
  • again.against@gmail.com