Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: svanoort/pyresttest
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.7.1
Choose a base ref
...
head repository: svanoort/pyresttest
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 16 commits
  • 5 files changed
  • 5 contributors

Commits on Mar 15, 2016

  1. Bump version for development

    svanoort committed Mar 15, 2016
    Copy the full SHA
    53e1051 View commit details

Commits on Mar 26, 2016

  1. Copy the full SHA
    11b39f2 View commit details

Commits on Mar 28, 2016

  1. Merge pull request #182 from danielatdattrixdotcom/coerce-url

    Clean up URL to eliminate double slashes when templating
    svanoort committed Mar 28, 2016
    Copy the full SHA
    65400ce View commit details

Commits on Mar 30, 2016

  1. Copy the full SHA
    ae0a121 View commit details
  2. Copy the full SHA
    2884f2f View commit details
  3. Revert "Clean up URL to eliminate double slashes when templating."

    This reverts commit 11b39f2.
    
    Why: breaks URL handling because it applies to the scheme (http:// etc)
    svanoort committed Mar 30, 2016
    Copy the full SHA
    d20df16 View commit details
  4. Revert "Clean up URL to eliminate double slashes when templating."

    This reverts commit 11b39f2.
    
    Why: breaks URL handling because it applies to the scheme (http:// etc)
    svanoort committed Mar 30, 2016
    Copy the full SHA
    198883c View commit details

Commits on Mar 31, 2016

  1. Merge pull request #186 from svanoort/fix-threaded-loading

    Fix threaded loading + update docs
    svanoort committed Mar 31, 2016
    Copy the full SHA
    b47c8ea View commit details
  2. Mention timeout more in the readme

    because people keep asking
    svanoort committed Mar 31, 2016
    Copy the full SHA
    74c3af7 View commit details

Commits on May 24, 2016

  1. Update advanced_guide.md to clarify generator binding

    Answers issues such as #200
    svanoort committed May 24, 2016
    Copy the full SHA
    d6985d4 View commit details

Commits on Apr 3, 2017

  1. Update advanced_guide.md

    Some typos
    OlafvdSpek authored Apr 3, 2017
    Copy the full SHA
    a7ffd02 View commit details

Commits on Aug 2, 2017

  1. Added input for python 3

    Iakhin, Ruslan authored and Iakhin, Ruslan committed Aug 2, 2017
    Copy the full SHA
    a81b792 View commit details

Commits on Feb 1, 2018

  1. Merge pull request #259 from yakhira/master

    Added input for python 3
    svanoort authored Feb 1, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7420231 View commit details
  2. Merge pull request #236 from OlafvdSpek/patch-1

    Update advanced_guide.md
    svanoort authored Feb 1, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    25d5df8 View commit details

Commits on Feb 3, 2018

  1. Update README.md

    Add installation instructions for python-pycurl in Linux Alpine
    kontrollanten authored Feb 3, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7f296ad View commit details
  2. Merge pull request #270 from kontrollanten/master

    Update README.md
    svanoort authored Feb 3, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f92acf8 View commit details
Showing with 32 additions and 9 deletions.
  1. +13 −0 CHANGELOG.md
  2. +4 −2 README.md
  3. +3 −3 advanced_guide.md
  4. +11 −3 pyresttest/resttest.py
  5. +1 −1 setup.py
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 1.7.2 UNRELEASED
**Bugfixes:**
- Fix threading issue with changing relative paths & reading files
- Thank you to @akshay059 for opening an issue for this https://github.com/svanoort/pyresttest/issues/183

**Features:**
* Mention new Atom editor package for PyRestTest, created by @BastienAr (Thank you!)
* Strip duplicate backslashes in templated URLs
- Thank you @danielatdattrixdotcom for you PR! - https://github.com/svanoort/pyresttest/pull/182

**Special mentions:**
- Big thank you to @spradeev for assisting with issues and questions, to free up time for working on code/architectural improvments for big features!

## 1.7.1 Mon Mar 15 23:05:00 2016 -0400
**Bugfixes:**
* Fix JSONschema extension in Python 3, and add test coverage for it
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -57,6 +57,7 @@ PyRestTest works on Linux or Mac with Python 2.6, 2.7, or 3.3+ (with module 'fut
**First we need to install package python-pycurl:**
* Ubuntu/Debian: (sudo) `apt-get install python-pycurl`
* CentOS/RHEL: (sudo) `yum install python-pycurl`
* Alpine: (sudo) `apk add curl-dev`
* Mac: *don't worry about it*
* Other platforms: *unsupported.* You *may* get it to work by installing pycurl & pyyaml manually. Also include 'future' for Python 3. No guarantees though.
*This is needed because the pycurl dependency may fail to install by pip. In *very rare* cases you may need to intall python-pyyaml if pip cannot install it correctly.*
@@ -113,7 +114,7 @@ Manually copying in a working system pycurl installation may help:
---
- config:
- testset: "Basic tests"

- timeout: 100 # Increase timeout from the default 10 seconds
- test:
- name: "Basic get"
- url: "/api/person/"
@@ -158,6 +159,7 @@ Manually copying in a working system pycurl installation may help:
- Advanced features have [separate documentation](advanced_guide.md) (templating, generators, content extraction, complex validation).
- How to [extend PyRestTest](extensions.md) is its own document
- There are a [ton of examples](https://github.com/svanoort/pyresttest/tree/master/examples)
- @BastienAr has created an [Atom editor package](https://atom.io/packages/language-pyresttest) for PyRestTest development (thank you!)
## Running A Simple Test
@@ -209,7 +211,7 @@ There are 5 top level test syntax elements:
- *url:* a simple test, fetches given url via GET request and checks for good response code
- *test*: a fully defined test (see below)
- *benchmark*: a fully defined benchmark (see below)
- *config* or *configuration*: overall test configuration
- *config* or *configuration*: overall test configuration (timeout is the most common option)
- *import*: import another test set file so you Don't Repeat Yourself

## Import example
6 changes: 3 additions & 3 deletions advanced_guide.md
Original file line number Diff line number Diff line change
@@ -13,15 +13,15 @@ For how to write custom Python extensions, see the [extensions guide](extensions
- Tests and benchmarks may use variables to template out configuration dynamically.
- Templating is performed using basic [Python string templating](https://docs.python.org/2/library/string.html#template-strings).
- Templating uses variables contained in a context, and **templates are evaluated freshly** for each test run or benchmark iteration
- Contexts are either passed into a test, or created in the text if not supplied
- Contexts are either passed into a test, or created in the test if not supplied
- **Contexts are persistent within a TestSet. Once a variable is set, it can be used in all following tests**
- **Context variables are modified and set** in 3 ways:
1. **Variable values may be statically declared** with 'variable_binds' in TestSet config or the test
2. **Generator output may be bound to a variable** with 'generator binds' in the test
+ Generators **must be declared by name** in the TestSet config for them to be used
+ Generator bindings evaluate once per HTTP call:
- **Only once per Test**, and **multiple times for a Benchmark**
+ Generator bindings only apply to the Test/Benchmark they are declared in. New values are generated only when the binding is evaluated.
+ Generator bindings are re-evaluated (and a new value generated) every time they are declared in a Test/Benchmark. Once the value has been generated, it can be used in all subsequent tests (unless that variable is bound to something else).
3. **Data may be extracted from the HTTP response body** with the 'extract_binds' element in a test.
+ Note that if the request fails, the data cannot be set (nothing to work with)
+ Currently, this is unsupported for benchmarks: using extraction doesn't make sense because benchmarks should be isolated.
@@ -175,7 +175,7 @@ Will return: NOTHING (None object) -- that key is not defined for 'person'.
- This query: 'thing'
Will return: {"foo":"bar"}

*Note that if you use this in templates it will appear as {u'foo': u'bar'} because it is converted to a python dictionary.* If you with to use it in other tests, you will need to extract the component elements individually.
*Note that if you use this in templates it will appear as {u'foo': u'bar'} because it is converted to a python dictionary.* If you wish to use it in other tests, you will need to extract the component elements individually.

- This query: '.'
Will return: the whole response (as a python object). This can be very useful if you want to do contains or count operations on it.
14 changes: 11 additions & 3 deletions pyresttest/resttest.py
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
import json
import csv
import logging
import threading
from optparse import OptionParser
from email import message_from_string # For headers handling
import time
@@ -79,7 +80,7 @@
logging.basicConfig(format='%(levelname)s:%(message)s')
logger = logging.getLogger('pyresttest')


DIR_LOCK = threading.RLock() # Guards operations changing the working directory
class cd:
"""Context manager for changing the current working directory"""
# http://stackoverflow.com/questions/431684/how-do-i-cd-in-python/13197763#13197763
@@ -89,12 +90,14 @@ def __init__(self, newPath):

def __enter__(self):
if self.newPath: # Don't CD to nothingness
DIR_LOCK.acquire()
self.savedPath = os.getcwd()
os.chdir(self.newPath)

def __exit__(self, etype, value, traceback):
if self.newPath: # Don't CD to nothingness
if self.newPath: # Don't CD to nothingness
os.chdir(self.savedPath)
DIR_LOCK.release()


class TestConfig:
@@ -341,7 +344,12 @@ def run_test(mytest, test_config=TestConfig(), context=None, curl_handle=None, *
print("%s" % (templated_test.headers))
if mytest.body is not None:
print("\n%s" % templated_test.body)
raw_input("Press ENTER when ready (%d): " % (mytest.delay))


if sys.version_info >= (3,0):
input("Press ENTER when ready (%d): " % (mytest.delay))
else:
raw_input("Press ENTER when ready (%d): " % (mytest.delay))

if mytest.delay > 0:
print("Delaying for %ds" % mytest.delay)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
test_dependencies.append('discover')

setup(name='pyresttest',
version='1.7.1',
version='1.7.2.dev',
description='Python RESTful API Testing & Microbenchmarking Tool',
long_description='Python RESTful API Testing & Microbenchmarking Tool \n Documentation at https://github.com/svanoort/pyresttest',
author='Sam Van Oort',