Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipeline #146

Open
wants to merge 78 commits into
base: backup_master
Choose a base branch
from
Open
Changes from 8 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
3cfbe97
codebase linting and quality controls
niall-byrne Nov 13, 2019
d11b6d5
testing: Update pytest coverage package
niall-byrne Nov 14, 2019
3b9b9f3
Create pythonpackage.yml
niall-byrne Nov 14, 2019
6845a74
Add build pipeline.
niall-byrne Nov 14, 2019
80dd104
Merge branch 'niall-byrne-patch-1' into pipeline
niall-byrne Nov 14, 2019
6380de9
testing: Add unittest for makeclass
niall-byrne Nov 18, 2019
662c8e1
add test cases for extract_swagger_path
Seonaid Nov 18, 2019
e8c2ca9
add test to extract_swagger_path
Seonaid Nov 18, 2019
c7ba089
refactor extract_swagger_path tests
Seonaid Nov 18, 2019
9f86b63
Added sanitize_doc unit test
AshrafPatel Nov 18, 2019
1c60c6b
Testing: added test for swagger function extract_path_arguments
slafi-vw Nov 18, 2019
adbe846
mock render_page call to test render_endpoint
Seonaid Nov 18, 2019
7dcc6db
Testing: added test for swagger function extract_path_arguments
slafi-vw Nov 18, 2019
d3730fb
testing: added test for model(...)
Nov 18, 2019
acab4b8
Added test_render_homepage.py
AshrafPatel Nov 18, 2019
eca24de
testing: Add test for operation(...)
Nov 18, 2019
d708ab0
test __parse_docs_ green
Seonaid Nov 18, 2019
cd8b2c3
linting: Apply linter to pipelines branch
niall-byrne Nov 19, 2019
d2efca4
Merge remote-tracking branch 'original/pipeline' into pipeline
Nov 19, 2019
fb2d2c5
Merge remote-tracking branch 'parent/pipeline' into pipeline
Seonaid Nov 19, 2019
794c6e0
testing: Run linting tools on test_model and test_operation
Nov 19, 2019
40005cb
linting the files
Seonaid Nov 19, 2019
300040c
testing: Fix unused import on test_operation
Nov 19, 2019
6f375c7
Merge pull request #132 from dlieu/pipeline
niall-byrne Nov 19, 2019
ef9a130
Merge pull request #130 from Seonaid/pipeline
niall-byrne Nov 19, 2019
1f72742
Merge remote-tracking branch 'original/pipeline' into pipeline
slafi-vw Nov 19, 2019
4c155eb
Testing: added test for swagger function extract_path_arguments
slafi-vw Nov 18, 2019
23a1116
testing for deduce_swagger_type_flat included bug fix discovered in t…
Seonaid Nov 19, 2019
f796969
testing: coverage for staticfiles
niall-byrne Nov 19, 2019
b93cf34
Merge pull request #133 from niall-byrne/local
niall-byrne Nov 19, 2019
c11bba6
test deduce_swaagger_type
Seonaid Nov 19, 2019
b57ceaf
testing: Add test for ResourceLister
niall-byrne Nov 19, 2019
eb5a753
Merge pull request #134 from niall-byrne/local
niall-byrne Nov 19, 2019
4acfa98
test render page
Seonaid Nov 19, 2019
41675ee
Testing: nested and extract_path_arguments
slafi-vw Nov 19, 2019
53aa2d7
Testing: nested and extract_path_arguments
slafi-vw Nov 19, 2019
e6cf2a7
linting
Seonaid Nov 19, 2019
905ad4a
Merge pull request #136 from Seonaid/pipeline
niall-byrne Nov 22, 2019
d353968
tests: clean up some formatting, ensure system compatibillity
niall-byrne Nov 22, 2019
3f1d470
scripts: ensure coverage data in regenerated on each test run
niall-byrne Nov 22, 2019
4f1e88c
testing: Fix python2 compatibillity
niall-byrne Nov 22, 2019
69979ec
testing: Fix python2 compatibillity
niall-byrne Nov 22, 2019
f3750c7
Merge pull request #131 from AshrafPatel/ashraf_test
niall-byrne Nov 23, 2019
b97f1c8
Merge remote-tracking branch 'rantav/pipeline' into pipeline
niall-byrne Nov 23, 2019
f0891f7
Merge remote-tracking branch 'rantav/pipeline' into pipeline
niall-byrne Nov 23, 2019
bd71db5
tests: refactor duplicated test cases
niall-byrne Nov 23, 2019
55c4a87
WIP: testing swagger endpoint
niall-byrne Nov 23, 2019
79f0a4a
testing: validate html generated by swagger endpoint
niall-byrne Nov 27, 2019
074e45e
testing: add coverage for extract_path_parameters
niall-byrne Nov 27, 2019
3ae3ace
Merge pull request #135 from slafi/local
niall-byrne Nov 27, 2019
30cf491
testing: Fix nested function extraction, clean up tests.
niall-byrne Nov 27, 2019
98e1fe2
testing: swagger endpoint class
niall-byrne Nov 27, 2019
71f717b
Testing: Add test_add_model
Nov 19, 2019
79e8021
testing: coverage for get_current_registry
niall-byrne Nov 28, 2019
cb0a21a
testing: WIP doc method
niall-byrne Nov 28, 2019
845eddd
testing: Add coverage for docs function
niall-byrne Nov 28, 2019
2226c92
testing: coverage for register_once
niall-byrne Nov 28, 2019
6ac8e08
testing: exclude python3 import compatibillity from coverage
niall-byrne Nov 28, 2019
0bd2125
completed test_add_model
Dec 12, 2019
d5a51dc
support python2 imports
Jan 28, 2020
1122380
seperate test fixture objects into another file
Jan 29, 2020
c066f2e
rename from TodoItem to MockTodoItem
Jan 29, 2020
06c5dac
Add Mock in front of naming for: ModelWithResourceFieldsNoRequired
Jan 29, 2020
24f9f92
refactor fixtures into seperate file
Jan 29, 2020
587e5e9
refactor patching data structures into seperate file. use context man…
Jan 29, 2020
f8df19b
refactor(DEVELOPMENT): modernize the development tool chain, and add …
niall-byrne Feb 10, 2020
1bc43e2
test(PYTHON2): add a test case to conclude coverage, and swap black f…
niall-byrne Feb 10, 2020
1ed6de6
docs(CLI): update development environment documentation
niall-byrne Feb 10, 2020
853ff70
ci(GITHUB): fix error on dockerfile manipulation
niall-byrne Feb 10, 2020
29b7dfd
fix(STDOUT): remove diagnostic print statements
niall-byrne Feb 10, 2020
b20b568
docs(README): github action badge nit
niall-byrne Feb 10, 2020
678f54c
docs(EXAMPLES): add some instructions to quickly bring up the example…
niall-byrne Feb 10, 2020
500e191
docs(CONTRIBUTING): update contact details
niall-byrne Feb 10, 2020
cb04b62
refactor(CLEANUP): cleanup the repository root, and coverage configur…
niall-byrne Feb 10, 2020
94ae777
for init testing, make sure resource_fields code is NOT called
Jan 29, 2020
4f14f0a
community: Add contribution guidelines link, and standard code of con…
niall-byrne Jan 30, 2020
3e0e5e2
fix py2 testing issues from old-style classes
Feb 10, 2020
f43ec05
docs(CONTRIBUTION): add some guidelines for commit message and linting
niall-byrne Feb 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions tests/test_extract_swagger_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import pytest

from flask_restful_swagger import swagger


"""
Docstring from extract_swagger_path:

Extracts a swagger type path from the given flask style path.
This /path/<parameter> turns into this /path/{parameter}
And this /<string(length=2):lang_code>/<string:id>/<float:probability>
to this: /{lang_code}/{id}/{probability}
"""


@pytest.mark.parametrize(
"case_name, test_input, expected",
[
("empty_string", "", ""),
("simple", "/endpoint", "/endpoint"),
("single_parameter_no_type", "/path/<parameter>", "/path/{parameter}"),
(
"single_parameter_string",
"/<string(length=2):lang_code>",
"/{lang_code}",
),
(
"multiple_parameters",
"/<string(length=3):lang_code>/<string:id>/<float:probability>",
"/{lang_code}/{id}/{probability}",
),
(
"multiple_parameters_varied_length_string",
"/<string(length=5):lang_code>/<string:id>/<float:probability>",
"/{lang_code}/{id}/{probability}",
),
(
"long_path_single_parameter",
"path/subpath/other_path/<string(length=2):lang_code>",
"path/subpath/other_path/{lang_code}",
),
],
)
def test_extract_swagger_path(case_name, test_input, expected):
assert swagger.extract_swagger_path(test_input) == expected


def test_extract_swagger_path_returns_string():
assert isinstance(swagger.extract_swagger_path("/endpoint/123"), str)
52 changes: 52 additions & 0 deletions tests/test_parse_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from flask_restful_swagger import swagger


class MockBasicObject:
pass


def test_parse_doc_no_object_is_none():
assert swagger._parse_doc(None) == (None, None)


def test_parse_doc_no_docs_is_none():
assert swagger._parse_doc(MockBasicObject()) == (None, None)


def test_parse_doc_one_line_doc():
test_one_line_doc = MockBasicObject()
test_one_line_doc.__doc__ = "Some Text Goes Here"
assert swagger._parse_doc(test_one_line_doc) == (
"Some Text Goes Here",
None,
)


def test_parse_doc_multi_line_doc():
test_multi_line_doc = MockBasicObject()
test_multi_line_doc.__doc__ = (
"Some Text Goes Here \n this is the extra text\n"
"and this is the third line."
)
extracted = swagger._parse_doc(test_multi_line_doc)
assert extracted[0] == "Some Text Goes Here "
assert (
extracted[1]
== " this is the extra text<br/>and this is the third line."
)


def test_parse_doc_weird_characters():
test_weird_characters = MockBasicObject()
test_weird_characters.__doc__ = (
"Hi, 297agiu(*#&_$ ! \n Oh, the terrible 2908*&%)(#%#"
)
extracted = swagger._parse_doc(test_weird_characters)
assert extracted[0] == "Hi, 297agiu(*#&_$ ! "
assert extracted[1] == "Oh, the terrible 2908*&%)(#%#"


def test_parse_doc_ends_with_newline():
test_ends_newline = MockBasicObject()
test_ends_newline.__doc__ = "Overview \n Some details \n"
assert swagger._parse_doc(test_ends_newline)[1] == "Some details "
20 changes: 20 additions & 0 deletions tests/test_render_endpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import unittest
from unittest.mock import patch

from flask_restful_swagger import swagger


class Endpoint:
pass


class RenderEndpointTestCast(unittest.TestCase):
def test_render_endpoint(self):
endpoint = Endpoint()
with patch(
"flask_restful_swagger.swagger.render_page"
) as mock_render_page:
swagger.render_endpoint(endpoint)
mock_render_page.assert_called_with(
"endpoint.html", endpoint.__dict__
)