Skip to content

Commit 95efa5e

Browse files
author
Abhilash Joseph C
committed
Refactor the Code
1 parent 50cf1e6 commit 95efa5e

31 files changed

+78
-508
lines changed

.coveragerc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# .coveragerc to control coverage.py
22
[run]
33
branch = True
4-
omit = py3resttest/runner.py
4+
omit = resttest3/runner.py
55

66
command_line = --source py3resttest -m pytest tests/test_*.py
77
[paths]
88
source =
9-
py3resttest/
9+
resttest3/
1010

1111
[report]
1212
# Regexes for lines to exclude from consideration

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ COPY requirements.txt /tmp/requirements.txt
1414

1515
#RUN pip install --no-cache-dir -r /tmp/requirements.txt
1616

17-
COPY . /py3resttest
18-
WORKDIR /py3resttest
17+
COPY . /resttest3
18+
WORKDIR /resttest3
1919

2020

2121
RUN python setup.py bdist_wheel
2222
RUN pip install -U dist/*
23-
RUN flake8 py3resttest --count --select=E9,F63,F7,F82 --show-source --statistics
24-
RUN flake8 py3resttest --count --exit-zero --max-complexity=30 --max-line-length=127 --statistics
23+
RUN flake8 resttest3 --count --select=E9,F63,F7,F82 --show-source --statistics
24+
RUN flake8 resttest3 --count --exit-zero --max-complexity=30 --max-line-length=127 --statistics
2525
# RUN python -m pytest tests
26-
RUN coverage run --source py3resttest -m pytest tests/test_*.py
26+
RUN coverage run --source resttest3 -m pytest tests/test_*.py
2727
RUN coverage report
2828
#RUN resttest3 --url https://www.courtlistener.com --test tests/fun_test.yaml
2929

coverage.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22
# pip install coverage
3-
coverage run --source py3resttest -m pytest tests/test_*.py
3+
coverage run --source resttest3 -m pytest tests/test_*.py
44
coverage html
55
coverage report

docs/extensions.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ python pyresttest/resttest.py https://api.github.com fancypants_test.yaml --impo
2222

2323
## What does an extension look like?
2424
```python
25-
import py3resttest.validators as validators
25+
import resttest3.validators as validators
2626

2727
# Define a simple generator that doubles with each value
2828
def parse_generator_doubling(config):
@@ -44,11 +44,6 @@ GENERATORS = {'doubling': parse_generator_doubling}
4444

4545
If this is imported when executing the test, you can now use this generator in tests.
4646

47-
# Full Example
48-
See the [sample extension](pyresttest/tests/sample_extension.py).
49-
It shows an extension for all extensible functions.
50-
51-
5247
# What Doe An Extension Need To Work?
5348

5449
1. Function(s) to run
@@ -105,6 +100,8 @@ The 'parse' function below will be registered in the registry.
105100

106101
Example:
107102
```python
103+
104+
from resttest3.validators import AbstractExtractor
108105
class HeaderExtractor(AbstractExtractor):
109106
""" Extractor that pulls out a named header """
110107
extractor_type = 'header' # Printable name for the type
@@ -133,6 +130,9 @@ Validators should extend AbstractValidator.
133130
The parse function below will be registered in the registry VALIDATORS.
134131

135132
```python
133+
from resttest3.validators import AbstractValidator, _get_extractor, Failure
134+
from resttest3.utils import Parser
135+
from resttest3.constants import VALIDATOR_TESTS
136136
class ExtractTestValidator(AbstractValidator):
137137
""" Does extract and test from request body """
138138
name = 'ExtractTestValidator'
@@ -145,7 +145,7 @@ class ExtractTestValidator(AbstractValidator):
145145
def parse(config):
146146
""" Config is a dict """
147147
output = ExtractTestValidator()
148-
config = parsing.lowercase_keys(parsing.flatten_dictionaries(config))
148+
config = Parser.flatten_lowercase_keys_dict(config)
149149
output.config = config
150150
extractor = _get_extractor(config)
151151
output.extractor = extractor

py3resttest/__init__.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

resttest3/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
__version__ = '1.0.0-dev'
2+
__author__ = 'Abhilash Joseph C'
3+
4+
from resttest3.utils import register_extensions
5+
6+
register_extensions('resttest3.ext.validator_jsonschema')
7+
register_extensions('resttest3.ext.extractor_jmespath')

py3resttest/binding.py renamed to resttest3/binding.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
Basic context implementation for binding variables to values
66
"""
77

8-
logger = logging.getLogger('py3resttest')
8+
logger = logging.getLogger('resttest3')
99

1010

11-
class Context(object):
11+
class Context:
1212
""" Manages binding of variables & generators, with both variable name and generator name being strings """
13+
1314
# variables = {}
1415
def __init__(self):
1516
self.variables = {} # Maps variable name to current value
File renamed without changes.

py3resttest/contenthandling.py renamed to resttest3/contenthandling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import string
33

4-
from py3resttest.utils import Parser
4+
from resttest3.utils import Parser
55

66
"""
77
Encapsulates contend handling logic, for pulling file content into tests
File renamed without changes.

0 commit comments

Comments
 (0)