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

+2-2
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

+5-5
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

+1-1
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

+7-7
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

-7
This file was deleted.

resttest3/__init__.py

+7
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

+3-2
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

+1-1
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.
File renamed without changes.

py3resttest/ext/extractor_jmespath.py renamed to resttest3/ext/extractor_jmespath.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import jmespath
44

5-
from py3resttest.validators import AbstractExtractor
5+
from resttest3.validators import AbstractExtractor
66

77

88
class JMESPathExtractor(AbstractExtractor):

py3resttest/ext/validator_jsonschema.py renamed to resttest3/ext/validator_jsonschema.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import jsonschema
55
import yaml
66

7-
from py3resttest.constants import FAILURE_VALIDATOR_EXCEPTION
8-
from py3resttest.contenthandling import ContentHandler
9-
from py3resttest.utils import Parser
10-
from py3resttest.validators import AbstractValidator, Failure
7+
from resttest3.constants import FAILURE_VALIDATOR_EXCEPTION
8+
from resttest3.contenthandling import ContentHandler
9+
from resttest3.utils import Parser
10+
from resttest3.validators import AbstractValidator, Failure
1111

1212

1313
class JsonSchemaValidator(AbstractValidator):

py3resttest/generators.py renamed to resttest3/generators.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
INT32_MAX_VALUE = 2147483647 # Max of 32 bit unsigned int
1212

13-
logger = logging.getLogger('py3resttest.generators')
13+
logger = logging.getLogger('resttest3.generators')
1414

1515
# Character sets to use in text generation, python string plus extras
1616
CHARACTER_SETS = {
@@ -213,7 +213,7 @@ def parse_generator(configuration):
213213
""" Parses a configuration built from yaml and returns a generator
214214
Configuration should be a map
215215
"""
216-
from py3resttest.utils import Parser
216+
from resttest3.utils import Parser
217217
configuration = Parser.lowercase_keys(Parser.flatten_dictionaries(configuration))
218218
gen_type = str(configuration.get(u'type')).lower()
219219

py3resttest/runner.py renamed to resttest3/runner.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import yaml
99
from alive_progress import alive_bar
1010

11-
from py3resttest.testcase import TestSet
12-
from py3resttest.utils import register_extensions
11+
from resttest3.testcase import TestSet
12+
from resttest3.utils import register_extensions
1313

14-
logger = logging.getLogger('py3resttest')
14+
logger = logging.getLogger('resttest3')
1515
logging.basicConfig(format='%(levelname)s:%(message)s')
1616

1717

py3resttest/testcase.py renamed to resttest3/testcase.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111

1212
import pycurl
1313

14-
from py3resttest.binding import Context
15-
from py3resttest.constants import (
14+
from resttest3.binding import Context
15+
from resttest3.constants import (
1616
AuthType, YamlKeyWords, TestCaseKeywords, DEFAULT_TIMEOUT, EnumHttpMethod, FAILURE_CURL_EXCEPTION,
1717
FAILURE_TEST_EXCEPTION, FAILURE_INVALID_RESPONSE
1818
)
19-
from py3resttest.contenthandling import ContentHandler
20-
from py3resttest.exception import HttpMethodError, BindError, ValidatorError
21-
from py3resttest.generators import parse_generator
22-
from py3resttest.utils import read_testcase_file, ChangeDir, Parser
23-
from py3resttest.validators import parse_extractor, parse_validator, Failure
19+
from resttest3.contenthandling import ContentHandler
20+
from resttest3.exception import HttpMethodError, BindError, ValidatorError
21+
from resttest3.generators import parse_generator
22+
from resttest3.utils import read_testcase_file, ChangeDir, Parser
23+
from resttest3.validators import parse_extractor, parse_validator, Failure
2424

25-
logger = logging.getLogger('py3resttest')
25+
logger = logging.getLogger('resttest3')
2626

2727

2828
class TestCaseConfig:

py3resttest/utils.py renamed to resttest3/utils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99

1010
import yaml
1111

12-
from py3resttest.generators import register_generator
13-
from py3resttest.validators import register_test, register_comparator, register_extractor
14-
from py3resttest.validators import register_validator
12+
from resttest3.generators import register_generator
13+
from resttest3.validators import register_test, register_comparator, register_extractor
14+
from resttest3.validators import register_validator
1515

16-
logger = logging.getLogger('py3resttest')
16+
logger = logging.getLogger('resttest3')
1717

1818

1919
class ChangeDir:

py3resttest/validators.py renamed to resttest3/validators.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from abc import abstractmethod, ABCMeta
77
from typing import Dict, List, Union, Optional
88

9-
from py3resttest.constants import COMPARATORS, FAILURE_EXTRACTOR_EXCEPTION, FAILURE_VALIDATOR_FAILED, VALIDATOR_TESTS
9+
from resttest3.constants import COMPARATORS, FAILURE_EXTRACTOR_EXCEPTION, FAILURE_VALIDATOR_FAILED, VALIDATOR_TESTS
1010

11-
logger = logging.getLogger('py3resttest.validators')
11+
logger = logging.getLogger('resttest3.validators')
1212

1313
EXTRACTORS = {}
1414
VALIDATORS = {}
@@ -287,7 +287,7 @@ def parse(config):
287287
expected: 'myValue'
288288
}
289289
"""
290-
from py3resttest.utils import Parser
290+
from resttest3.utils import Parser
291291
output = ComparatorValidator()
292292
config = Parser.lowercase_keys(Parser.flatten_dictionaries(config))
293293
output.config = config
@@ -354,7 +354,7 @@ def get_readable_config(self, context=None):
354354

355355
@staticmethod
356356
def parse(config):
357-
from py3resttest.utils import Parser
357+
from resttest3.utils import Parser
358358
output = ExtractTestValidator()
359359
config = Parser.lowercase_keys(Parser.flatten_dictionaries(config))
360360
output.config = config

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'\n Documentation at https://abhijo89-to.github.io/py3resttest/',
1212
author="Abhilash Joseph C",
1313
author_email='[email protected]',
14-
url='https://github.com/abhijo89-to/py3resttest',
14+
url='https://github.com/abhijo89-to/resttest3',
1515
keywords=['rest', 'web', 'http', 'testing', 'api'],
1616
classifiers=[
1717
'Environment :: Console',
@@ -31,9 +31,9 @@
3131
license='Apache License, Version 2.0',
3232
install_requires=install_requires,
3333
tests_require=install_requires,
34-
test_suite="py3resttest.tests",
34+
test_suite="resttest3.tests",
3535
entry_points={
36-
'console_scripts': ['resttest3=py3resttest.runner:main'],
36+
'console_scripts': ['resttest3=resttest3.runner:main'],
3737
}
3838

3939
)

0 commit comments

Comments
 (0)