%global _empty_manifest_terminate_build 0 Name: python-bddrest Version: 4.2.0 Release: 1 Summary: A toolchain for testing REST APIs in BDD manner. License: MIT URL: https://github.com/pylover/bddrest Source0: https://mirrors.nju.edu.cn/pypi/web/packages/81/9b/8a05203c10576267777aebd8973fffb5e6bd502e0121c4f9b91b984bf9e4/bddrest-4.2.0.tar.gz BuildArch: noarch %description * [Quick start](#quick-start) * [Writing tests](#writing-tests) * [Dumping a Story](#dumping-a-story) * [Auto Dumping](#auto-dumping) * [Markdown](#markdown) * [Command Line Interface](#command-line-interface) * [Enabling the bash autocompletion for bddrest](#enabling-the-bash-autocompletion-for-bddrest) ## Quick start ### Writing tests Using `Given`, `when`, functions as you see in the example below, you can determine and assert the behaviour of your `REST API`. The `story`, `response`, `status` objects are some proxies for currently writing story(*inside the with Given( ... ): context*) and it's response. and the last response after a `Given` and or `when`. ```python import re import sys import json from bddrest.authoring import Given, when, response, status def wsgi_application(environ, start_response): path = environ['PATH_INFO'] if path.endswith('/None'): start_response( '404 Not Found', [('Content-Type', 'text/plain;charset=utf-8')] ) yield b'' else: start_response( '200 OK', [('Content-Type', 'application/json;charset=utf-8')] ) result = json.dumps(dict( foo='bar' )) yield result.encode() with Given( wsgi_application, title='Quickstart!', url='/books/id: 1', as_='visitor') as story: assert status == 200 assert status == '200 OK' assert 'foo' in response.json assert response.json['foo'] == 'bar' when( 'Trying invalid book id', url_parameters={'id': None} ) assert response.status == 404 ``` ### Dumping a `Story` ```python story.dumps() ``` Produces: ```yaml base_call: as_: visitor description: As a member I have to POST a book to the library. form: name: BDD Book query: a: b response: headers: - 'Content-Type: application/json;charset=utf-8' json: foo: bar status: 200 OK title: Posting a book url: /books/:id url_parameters: id: '1' verb: GET calls: - response: headers: - 'Content-Type: text/plain;charset=utf-8' status: 404 Not Found title: Trying invalid book id url_parameters: id: None ``` You may load the story again from this yaml with `Story.loads(yaml)`. There are two additional methods available to dump and load to and from a file: `story.load(file)` and `story.dump(file)` #### Auto Dumping You may pass the `autodump` argument of the `Given` function to configure the auto-dumping: Default is `None`, means autodump is disabled by default. #### Auto Documentation You may pass the `autodoc` argument of the `Given` function to configure the auto-documentation: Default is `None`, meana autodoc is disabled by default. ``markdown``. ### Markdown You can use `story.document([formatter_factory=MarkdownFormatter])` to generate documentation in arbitrary format for example: `Markdown`. There is also a CLI to do this: ```bash bddrest document < story.yml > story.md ``` ## Posting a book ### GET /books/:id As a member I have to POST a book to the library. ### Url Parameters %package -n python3-bddrest Summary: A toolchain for testing REST APIs in BDD manner. Provides: python-bddrest BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-bddrest * [Quick start](#quick-start) * [Writing tests](#writing-tests) * [Dumping a Story](#dumping-a-story) * [Auto Dumping](#auto-dumping) * [Markdown](#markdown) * [Command Line Interface](#command-line-interface) * [Enabling the bash autocompletion for bddrest](#enabling-the-bash-autocompletion-for-bddrest) ## Quick start ### Writing tests Using `Given`, `when`, functions as you see in the example below, you can determine and assert the behaviour of your `REST API`. The `story`, `response`, `status` objects are some proxies for currently writing story(*inside the with Given( ... ): context*) and it's response. and the last response after a `Given` and or `when`. ```python import re import sys import json from bddrest.authoring import Given, when, response, status def wsgi_application(environ, start_response): path = environ['PATH_INFO'] if path.endswith('/None'): start_response( '404 Not Found', [('Content-Type', 'text/plain;charset=utf-8')] ) yield b'' else: start_response( '200 OK', [('Content-Type', 'application/json;charset=utf-8')] ) result = json.dumps(dict( foo='bar' )) yield result.encode() with Given( wsgi_application, title='Quickstart!', url='/books/id: 1', as_='visitor') as story: assert status == 200 assert status == '200 OK' assert 'foo' in response.json assert response.json['foo'] == 'bar' when( 'Trying invalid book id', url_parameters={'id': None} ) assert response.status == 404 ``` ### Dumping a `Story` ```python story.dumps() ``` Produces: ```yaml base_call: as_: visitor description: As a member I have to POST a book to the library. form: name: BDD Book query: a: b response: headers: - 'Content-Type: application/json;charset=utf-8' json: foo: bar status: 200 OK title: Posting a book url: /books/:id url_parameters: id: '1' verb: GET calls: - response: headers: - 'Content-Type: text/plain;charset=utf-8' status: 404 Not Found title: Trying invalid book id url_parameters: id: None ``` You may load the story again from this yaml with `Story.loads(yaml)`. There are two additional methods available to dump and load to and from a file: `story.load(file)` and `story.dump(file)` #### Auto Dumping You may pass the `autodump` argument of the `Given` function to configure the auto-dumping: Default is `None`, means autodump is disabled by default. #### Auto Documentation You may pass the `autodoc` argument of the `Given` function to configure the auto-documentation: Default is `None`, meana autodoc is disabled by default. ``markdown``. ### Markdown You can use `story.document([formatter_factory=MarkdownFormatter])` to generate documentation in arbitrary format for example: `Markdown`. There is also a CLI to do this: ```bash bddrest document < story.yml > story.md ``` ## Posting a book ### GET /books/:id As a member I have to POST a book to the library. ### Url Parameters %package help Summary: Development documents and examples for bddrest Provides: python3-bddrest-doc %description help * [Quick start](#quick-start) * [Writing tests](#writing-tests) * [Dumping a Story](#dumping-a-story) * [Auto Dumping](#auto-dumping) * [Markdown](#markdown) * [Command Line Interface](#command-line-interface) * [Enabling the bash autocompletion for bddrest](#enabling-the-bash-autocompletion-for-bddrest) ## Quick start ### Writing tests Using `Given`, `when`, functions as you see in the example below, you can determine and assert the behaviour of your `REST API`. The `story`, `response`, `status` objects are some proxies for currently writing story(*inside the with Given( ... ): context*) and it's response. and the last response after a `Given` and or `when`. ```python import re import sys import json from bddrest.authoring import Given, when, response, status def wsgi_application(environ, start_response): path = environ['PATH_INFO'] if path.endswith('/None'): start_response( '404 Not Found', [('Content-Type', 'text/plain;charset=utf-8')] ) yield b'' else: start_response( '200 OK', [('Content-Type', 'application/json;charset=utf-8')] ) result = json.dumps(dict( foo='bar' )) yield result.encode() with Given( wsgi_application, title='Quickstart!', url='/books/id: 1', as_='visitor') as story: assert status == 200 assert status == '200 OK' assert 'foo' in response.json assert response.json['foo'] == 'bar' when( 'Trying invalid book id', url_parameters={'id': None} ) assert response.status == 404 ``` ### Dumping a `Story` ```python story.dumps() ``` Produces: ```yaml base_call: as_: visitor description: As a member I have to POST a book to the library. form: name: BDD Book query: a: b response: headers: - 'Content-Type: application/json;charset=utf-8' json: foo: bar status: 200 OK title: Posting a book url: /books/:id url_parameters: id: '1' verb: GET calls: - response: headers: - 'Content-Type: text/plain;charset=utf-8' status: 404 Not Found title: Trying invalid book id url_parameters: id: None ``` You may load the story again from this yaml with `Story.loads(yaml)`. There are two additional methods available to dump and load to and from a file: `story.load(file)` and `story.dump(file)` #### Auto Dumping You may pass the `autodump` argument of the `Given` function to configure the auto-dumping: Default is `None`, means autodump is disabled by default. #### Auto Documentation You may pass the `autodoc` argument of the `Given` function to configure the auto-documentation: Default is `None`, meana autodoc is disabled by default. ``markdown``. ### Markdown You can use `story.document([formatter_factory=MarkdownFormatter])` to generate documentation in arbitrary format for example: `Markdown`. There is also a CLI to do this: ```bash bddrest document < story.yml > story.md ``` ## Posting a book ### GET /books/:id As a member I have to POST a book to the library. ### Url Parameters %prep %autosetup -n bddrest-4.2.0 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-bddrest -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Fri May 05 2023 Python_Bot - 4.2.0-1 - Package Spec generated