init commit

This commit is contained in:
Justin Weins 2025-03-25 14:41:53 +01:00
parent dd619df7a2
commit 07d201d3ae
24 changed files with 411 additions and 303 deletions

View File

@ -21,4 +21,6 @@
#docs/*.md #docs/*.md
# Then explicitly reverse the ignore rule for a single file: # Then explicitly reverse the ignore rule for a single file:
#!docs/README.md #!docs/README.md
openapi_server/controllers/patchnotes_controller.py gen/openapi_server/controllers/patchnotes_controller.py
gen/openapi_server/__main__.py
gen/openapi_server/encoder.py

View File

@ -3,11 +3,13 @@ FROM python:3-alpine
RUN mkdir -p /usr/src/app RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY requirements.txt /usr/src/app/ COPY gen/requirements.txt /usr/src/app/
RUN pip install --upgrade pip
RUN pip3 install --no-cache-dir -r requirements.txt RUN pip3 install --no-cache-dir -r requirements.txt
COPY . /usr/src/app COPY gen /usr/src/app
EXPOSE 8080 EXPOSE 8080

View File

@ -5,37 +5,10 @@ info:
version: 1.0.0 version: 1.0.0
paths: paths:
/patchnotes: /patchnotes:
get:
tags:
- Patchnotes
description: returns list of all unseen Patch notes from the user
operationId: get_patchnotes
requestBody:
description: last seen patchnote by the user
required: true
content:
application/json:
schema:
title: date
type: string
responses:
"200":
content:
application/json:
schema:
items:
$ref: '#/components/schemas/patch_notes'
type: array
description: returns list of all unseen Patch notes from the user
"404":
description: no Patch notes found
"500":
description: Internal Server error, Failed to get Patch Notes
post: post:
tags: tags:
- Patchnotes - Patchnotes
description: creates new Patch notes description: creates new Patch notes
operationId: post_patchnotes
requestBody: requestBody:
content: content:
application/json: application/json:
@ -54,7 +27,6 @@ paths:
tags: tags:
- Patchnotes - Patchnotes
description: deletes one Patch note description: deletes one Patch note
operationId: patch_note_delete
parameters: parameters:
- in: path - in: path
name: patchID name: patchID
@ -70,6 +42,35 @@ paths:
description: patch not found description: patch not found
"500": "500":
description: Internal Server Error, Patch not deleted description: Internal Server Error, Patch not deleted
/patchnotes/{date}:
get:
description: returns list of all unseen Patch notes from the user
parameters:
- explode: false
in: path
name: date
required: true
schema:
format: date
type: string
style: simple
example: 2025-01-02
responses:
"200":
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/patch_notes'
description: returns list of all unseen Patch notes from the user
"404":
description: no Patch notes found
"500":
description: "Internal Server error, Failed to get Patch Notes"
tags:
- Patchnotes
x-openapi-router-controller: openapi_server.controllers.patchnotes_controller
components: components:
schemas: schemas:
patch_notes: patch_notes:
@ -77,7 +78,7 @@ components:
patchID: 29e80bcc-5981-4a52-99e1-373442dea9b9 patchID: 29e80bcc-5981-4a52-99e1-373442dea9b9
title: Patch note 1 title: Patch note 1
changes: changes changes: changes
date: date date: 2025-01-02
properties: properties:
patchID: patchID:
format: uuid format: uuid
@ -94,9 +95,9 @@ components:
type: string type: string
user: user:
example: example:
lastNoteChecked: f00fa08d-0cd8-4c05-9409-5e75aa2d4f68 lastSeenDate: 2025-01-02
properties: properties:
lastNoteChecked: lastSeenDate:
format: uuid format: date
title: lastNoteChecked title: lastNoteChecked
type: string type: string

24
app.py
View File

@ -1,4 +1,4 @@
from flask import Flask from flask import Flask, jsonify, request
app = Flask(__name__) app = Flask(__name__)
@ -7,6 +7,28 @@ app = Flask(__name__)
def hello_world(): # put application's code here def hello_world(): # put application's code here
return 'Hello World!' return 'Hello World!'
@app.route('/patchnotes', methods=['POST'])
def post_patchnotes():
patch_note = request.get_json()
patch_notes_db.append(patch_note)
return jsonify(patch_notes_db), 200
@app.route('/patchnotes/<string:patchID>', methods=['DELETE'])
def delete_patchnote(patchID):
global patch_notes_db
patch_notes_db = [note for note in patch_notes_db if note['patchID'] != patchID]
if any(note['patchID'] == patchID for note in patch_notes_db):
return jsonify({'error': 'Patch not deleted'}), 500
else:
return jsonify({'message': 'patch successfully deleted'}), 200
@app.route('/patchnotes/<string:date>', methods=['GET'])
def get_patchnotes(date):
unseen_notes = [note for note in patch_notes_db if note['date'] == date]
if unseen_notes:
return jsonify(unseen_notes), 200
else:
return jsonify({'error': 'no Patch notes found'}), 404
if __name__ == '__main__': if __name__ == '__main__':
app.run() app.run()

View File

@ -21,3 +21,5 @@
#docs/*.md #docs/*.md
# Then explicitly reverse the ignore rule for a single file: # Then explicitly reverse the ignore rule for a single file:
#!docs/README.md #!docs/README.md
openapi_server/controllers/patchnotes_controller.py
openapi_server/__main__.py

View File

@ -1,28 +1,22 @@
.github/workflows/python.yml .dockerignore
.gitignore .gitignore
.gitlab-ci.yml
.travis.yml .travis.yml
Dockerfile
README.md README.md
docs/PatchNotes.md
docs/PatchnotesApi.md
docs/User.md
git_push.sh git_push.sh
openapi_client/__init__.py openapi_server/__init__.py
openapi_client/api/__init__.py openapi_server/controllers/__init__.py
openapi_client/api/patchnotes_api.py openapi_server/controllers/security_controller.py
openapi_client/api_client.py openapi_server/encoder.py
openapi_client/api_response.py openapi_server/models/__init__.py
openapi_client/configuration.py openapi_server/models/base_model.py
openapi_client/exceptions.py openapi_server/models/patch_notes.py
openapi_client/models/__init__.py openapi_server/models/user.py
openapi_client/models/patch_notes.py openapi_server/openapi/openapi.yaml
openapi_client/models/user.py openapi_server/test/__init__.py
openapi_client/py.typed openapi_server/typing_utils.py
openapi_client/rest.py openapi_server/util.py
pyproject.toml
requirements.txt requirements.txt
setup.cfg
setup.py setup.py
test-requirements.txt test-requirements.txt
test/__init__.py
tox.ini tox.ini

View File

@ -1 +1 @@
7.7.0 7.12.0-SNAPSHOT

View File

@ -1,17 +1,14 @@
# ref: https://docs.travis-ci.com/user/languages/python # ref: https://docs.travis-ci.com/user/languages/python
language: python language: python
python: python:
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
- "3.7" - "3.7"
- "3.8" - "3.8"
- "3.9"
- "3.10"
- "3.11"
# uncomment the following if needed
#- "3.11-dev" # 3.11 development branch
#- "nightly" # nightly build
# command to install dependencies # command to install dependencies
install: install: "pip install -r requirements.txt"
- "pip install -r requirements.txt"
- "pip install -r test-requirements.txt"
# command to run tests # command to run tests
script: pytest --cov=openapi_client script: nosetests

View File

@ -1,108 +1,49 @@
# openapi-client # OpenAPI generated server
Announcing patchnotes for KanzleiApp
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: ## Overview
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the
[OpenAPI-Spec](https://openapis.org) from a remote server, you can easily generate a server stub. This
is an example of building a OpenAPI-enabled Flask server.
- API version: 1.0.0 This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask.
- Package version: 1.0.0
- Generator version: 7.7.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
## Requirements. ## Requirements
Python 3.5.2+
Python 3.7+ ## Usage
To run the server, please execute the following from the root directory:
## Installation & Usage
### pip install
If the python package is hosted on a repository, you can install directly using:
```sh
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
```
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)
Then import the package:
```python
import openapi_client
```
### Setuptools
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
```sh
python setup.py install --user
```
(or `sudo python setup.py install` to install the package for all users)
Then import the package:
```python
import openapi_client
```
### Tests
Execute `pytest` to run the tests.
## Getting Started
Please follow the [installation procedure](#installation--usage) and then run the following:
```python
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
host = "http://localhost"
)
# Enter a context with an instance of the API client
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = openapi_client.PatchnotesApi(api_client)
body = 'body_example' # str | last seen patchnote by the user
try:
api_response = api_instance.get_patchnotes(body)
print("The response of PatchnotesApi->get_patchnotes:\n")
pprint(api_response)
except ApiException as e:
print("Exception when calling PatchnotesApi->get_patchnotes: %s\n" % e)
```
pip3 install -r requirements.txt
python3 -m openapi_server
``` ```
## Documentation for API Endpoints and open your browser to here:
All URIs are relative to *http://localhost* ```
http://localhost:8080/ui/
```
Class | Method | HTTP request | Description Your OpenAPI definition lives here:
------------ | ------------- | ------------- | -------------
*PatchnotesApi* | [**get_patchnotes**](docs/PatchnotesApi.md#get_patchnotes) | **GET** /patchnotes | gets all unseen Patchnotes from the User
*PatchnotesApi* | [**patch_note_delete**](docs/PatchnotesApi.md#patch_note_delete) | **DELETE** /patchnotes/{patchID} | Deletes selected Patchnote
*PatchnotesApi* | [**post_patchnotes**](docs/PatchnotesApi.md#post_patchnotes) | **POST** /patchnotes | Creates a new Patchnote
```
http://localhost:8080/openapi.json
```
## Documentation For Models To launch the integration tests, use tox:
```
sudo pip install tox
tox
```
- [PatchNotes](docs/PatchNotes.md) ## Running with Docker
- [User](docs/User.md)
To run the server on a Docker container, please execute the following from the root directory:
<a id="documentation-for-authorization"></a> ```bash
## Documentation For Authorization # building the image
docker build -t openapi_server .
Endpoints do not require authorization.
## Author
Justin Weins
# starting up a container
docker run -p 8080:8080 openapi_server
```

10
gen/entrypoint.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
PORT=${PORT:-8080}
gunicorn --workers 4 \
--forwarded-allow-ips="*" \
--bind 0.0.0.0:$PORT \
--worker-class uvicorn.workers.UvicornWorker \
--preload \
openapi_server.__main__:app

View File

@ -1,20 +1,22 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import logging
import connexion import connexion
from openapi_server import encoder from openapi_server import encoder
from pymongo import MongoClient
client = MongoClient(host='mongodb://localhost:27017/')
db = client["MainDB"]
collection = db['patch_notes']
def main(): app = connexion.App(__name__, specification_dir='./openapi/')
app = connexion.App(__name__, specification_dir='./openapi/') app.app.logger.setLevel(logging.DEBUG)
app.app.json_encoder = encoder.JSONEncoder app.app.json_encoder = encoder.JSONEncoder
app.add_api('openapi.yaml', app.add_api('openapi.yaml',
base_path='/api', base_path='/api',
arguments={'title': 'announcementService'}, arguments={'title': 'announcementService'},
pythonic_params=True) pythonic_params=True)
app.run(port=8080)
if __name__ == '__main__': if __name__ == '__main__':
main() app.run(port=8080, host='0.0.0.0')

View File

@ -1,25 +1,45 @@
import logging
import connexion import connexion
from typing import Dict from typing import Dict
from typing import Tuple from typing import Tuple
from typing import Union from typing import Union
from bson import json_util
from flask import Response
from pymongo import MongoClient
from openapi_server.__main__ import collection
from openapi_server.models.patch_notes import PatchNotes # noqa: E501 from openapi_server.models.patch_notes import PatchNotes # noqa: E501
from openapi_server import util from openapi_server import util
def get_patchnotes(): # noqa: E501
"""get_patchnotes def patchnotes_date_get(date): # noqa: E501
"""patchnotes_date_get
returns list of all unseen Patch notes from the user # noqa: E501 returns list of all unseen Patch notes from the user # noqa: E501
:param date:
:type date: str
:rtype: Union[List[PatchNotes], Tuple[List[PatchNotes], int], Tuple[List[PatchNotes], int, Dict[str, str]] :rtype: Union[List[PatchNotes], Tuple[List[PatchNotes], int], Tuple[List[PatchNotes], int, Dict[str, str]]
""" """
return 'do some magic!' # TODO Implement this:
# try:
# formatted_date = response_data.strftime('%Y-%m-%d')
# logging.error(formatted_date)
# logging.info("valid date")
# except ValueError:
# logging.error("Not valid date")
return date
# _date = util.deserialize_date(date)
# return 'do some magic!'
def patch_note_delete(patch_id): # noqa: E501 def patchnotes_patch_iddelete(patch_id): # noqa: E501
"""patch_note_delete """patchnotes_patch_iddelete
deletes one Patch note # noqa: E501 deletes one Patch note # noqa: E501
@ -32,8 +52,8 @@ def patch_note_delete(patch_id): # noqa: E501
return 'do some magic!' return 'do some magic!'
def post_patchnotes(body=None): # noqa: E501 def patchnotes_post(body=None): # TODO done for now
"""post_patchnotes """patchnotes_post
creates new Patch notes # noqa: E501 creates new Patch notes # noqa: E501
@ -43,9 +63,11 @@ def post_patchnotes(body=None): # noqa: E501
:rtype: Union[List[PatchNotes], Tuple[List[PatchNotes], int], Tuple[List[PatchNotes], int, Dict[str, str]] :rtype: Union[List[PatchNotes], Tuple[List[PatchNotes], int], Tuple[List[PatchNotes], int, Dict[str, str]]
""" """
patch_notes = body patch_notes = body
with conn.cursor() as cur: logging.error('patch notes' + str(patch_notes))
player_name = player_post_request.name if patch_notes is None:
player_id = uuid.uuid4() return Response(json_util.dumps({'error': 'No patch notes provided'}), status=400)
cur.execute(f"INSERT INTO player VALUES ('{player_id}','{player_name}');") # Insert the document into the MongoDB collection
conn.commit() # noqa: E501 posted_patch_id = collection.insert_one(patch_notes)
return 'do some magic!'
return Response(json_util.dumps(f'patch with ID: {posted_patch_id} was created'), mimetype='application/json',
status=200)

View File

@ -1,9 +1,8 @@
from connexion.apps.flask_app import FlaskJSONEncoder from connexion.jsonifier import JSONEncoder as ConnexionJSONEncoder
from openapi_server.models.base_model import Model from openapi_server.models.base_model import Model
class JSONEncoder(FlaskJSONEncoder): class JSONEncoder(ConnexionJSONEncoder):
include_nulls = False include_nulls = False
def default(self, o): def default(self, o):
@ -16,4 +15,4 @@ class JSONEncoder(FlaskJSONEncoder):
attr = o.attribute_map[attr] attr = o.attribute_map[attr]
dikt[attr] = value dikt[attr] = value
return dikt return dikt
return FlaskJSONEncoder.default(self, o) return ConnexionJSONEncoder.default(self, o)

View File

@ -12,21 +12,21 @@ class User(Model):
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, last_note_checked=None): # noqa: E501 def __init__(self, last_seen_date=None): # noqa: E501
"""User - a model defined in OpenAPI """User - a model defined in OpenAPI
:param last_note_checked: The last_note_checked of this User. # noqa: E501 :param last_seen_date: The last_seen_date of this User. # noqa: E501
:type last_note_checked: str :type last_seen_date: date
""" """
self.openapi_types = { self.openapi_types = {
'last_note_checked': str 'last_seen_date': date
} }
self.attribute_map = { self.attribute_map = {
'last_note_checked': 'lastNoteChecked' 'last_seen_date': 'lastSeenDate'
} }
self._last_note_checked = last_note_checked self._last_seen_date = last_seen_date
@classmethod @classmethod
def from_dict(cls, dikt) -> 'User': def from_dict(cls, dikt) -> 'User':
@ -40,22 +40,22 @@ class User(Model):
return util.deserialize_model(dikt, cls) return util.deserialize_model(dikt, cls)
@property @property
def last_note_checked(self) -> str: def last_seen_date(self) -> date:
"""Gets the last_note_checked of this User. """Gets the last_seen_date of this User.
:return: The last_note_checked of this User. :return: The last_seen_date of this User.
:rtype: str :rtype: date
""" """
return self._last_note_checked return self._last_seen_date
@last_note_checked.setter @last_seen_date.setter
def last_note_checked(self, last_note_checked: str): def last_seen_date(self, last_seen_date: date):
"""Sets the last_note_checked of this User. """Sets the last_seen_date of this User.
:param last_note_checked: The last_note_checked of this User. :param last_seen_date: The last_seen_date of this User.
:type last_note_checked: str :type last_seen_date: date
""" """
self._last_note_checked = last_note_checked self._last_seen_date = last_seen_date

View File

@ -4,31 +4,12 @@ info:
title: announcementService title: announcementService
version: 1.0.0 version: 1.0.0
servers: servers:
- url: / - url: http://127.0.0.1:8080/api
paths: paths:
/patchnotes: /patchnotes:
get:
description: returns list of all unseen Patch notes from the user
operationId: get_patchnotes
responses:
"200":
content:
application/json:
schema:
items:
$ref: '#/components/schemas/patch_notes'
type: array
description: returns list of all unseen Patch notes from the user
"404":
description: no Patch notes found
"500":
description: "Internal Server error, Failed to get Patch Notes"
tags:
- Patchnotes
x-openapi-router-controller: openapi_server.controllers.patchnotes_controller
post: post:
description: creates new Patch notes description: creates new Patch notes
operationId: post_patchnotes operationId: patchnotes_post
requestBody: requestBody:
content: content:
application/json: application/json:
@ -46,10 +27,40 @@ paths:
tags: tags:
- Patchnotes - Patchnotes
x-openapi-router-controller: openapi_server.controllers.patchnotes_controller x-openapi-router-controller: openapi_server.controllers.patchnotes_controller
/patchnotes/{date}:
get:
description: returns list of all unseen Patch notes from the user
operationId: patchnotes_date_get
parameters:
- example: 2025-01-02
explode: false
in: path
name: date
required: true
schema:
format: date
type: string
style: simple
responses:
"200":
content:
application/json:
schema:
items:
$ref: '#/components/schemas/patch_notes'
type: array
description: returns list of all unseen Patch notes from the user
"404":
description: no Patch notes found
"500":
description: "Internal Server error, Failed to get Patch Notes"
tags:
- Patchnotes
x-openapi-router-controller: openapi_server.controllers.patchnotes_controller
/patchnotes/{patchID}: /patchnotes/{patchID}:
delete: delete:
description: deletes one Patch note description: deletes one Patch note
operationId: patch_note_delete operationId: patchnotes_patch_iddelete
parameters: parameters:
- explode: false - explode: false
in: path in: path
@ -76,7 +87,7 @@ components:
patchID: 29e80bcc-5981-4a52-99e1-373442dea9b9 patchID: 29e80bcc-5981-4a52-99e1-373442dea9b9
title: Patch note 1 title: Patch note 1
changes: changes changes: changes
date: date date: 2025-01-02
properties: properties:
patchID: patchID:
format: uuid format: uuid
@ -94,9 +105,9 @@ components:
title: patch_notes title: patch_notes
user: user:
example: example:
lastNoteChecked: f00fa08d-0cd8-4c05-9409-5e75aa2d4f68 lastSeenDate: 2025-01-02
properties: properties:
lastNoteChecked: lastSeenDate:
format: uuid format: date
title: lastNoteChecked title: lastNoteChecked
type: string type: string

View File

@ -10,7 +10,7 @@ class BaseTestCase(TestCase):
def create_app(self): def create_app(self):
logging.getLogger('connexion.operation').setLevel('ERROR') logging.getLogger('connexion.operation').setLevel('ERROR')
app = connexion.App(__name__, specification_dir='../openapi/') app = connexion.App(__name__ , specification_dir='../openapi/')
app.app.json_encoder = JSONEncoder app.app.json_encoder = JSONEncoder
app.add_api('openapi.yaml', pythonic_params=True) app.add_api('openapi.yaml', pythonic_params=True, base_path='/api')
return app.app return app.app

View File

@ -2,10 +2,12 @@ import unittest
from flask import json from flask import json
import openapi_server
from openapi_server.models.patch_notes import PatchNotes # noqa: E501 from openapi_server.models.patch_notes import PatchNotes # noqa: E501
from openapi_server.test import BaseTestCase from openapi_server.test import BaseTestCase
class TestDefaultController(BaseTestCase): class TestDefaultController(BaseTestCase):
"""DefaultController integration test stubs""" """DefaultController integration test stubs"""
@ -23,7 +25,8 @@ class TestDefaultController(BaseTestCase):
headers=headers) headers=headers)
self.assert200(response, self.assert200(response,
'Response body is : ' + response.data.decode('utf-8')) 'Response body is : ' + response.data.decode('utf-8'))
response = self.client.get('/patchnotes',)
assert response.status_code == 200
def test_patch_note_delete(self): def test_patch_note_delete(self):
"""Test case for patch_note_delete """Test case for patch_note_delete

View File

@ -1,62 +1,167 @@
import datetime
import logging
import unittest import unittest
import unittest.mock as mock
from datetime import datetime
from flask import json from flask import json, url_for
import openapi_server import app
from openapi_server.models.patch_notes import PatchNotes # noqa: E501
from openapi_server.test import BaseTestCase from openapi_server.test import BaseTestCase
logging.basicConfig(level=logging.DEBUG)
class TestPatchnotesController(BaseTestCase): class TestPatchnotesController(BaseTestCase):
"""PatchnotesController integration test stubs""" """PatchnotesController integration test stubs"""
def test_get_patchnotes(self): def setUp(self):
"""Test case for get_patchnotes self.app = app.app
self.app.config['SERVER_NAME'] = '127.0.0.1:8080'
print('url map:' + str(self.app.url_map))
@unittest.mock.patch(
'openapi_server.controllers.patchnotes_controller.patchnotes_date_get')
def test_get_patchnotes(self, mock_get_patchnotes):
"""Test case for get_patchnotes
""" """
headers = { headers = {
'Accept': 'application/json', 'Accept': 'application/json',
} }
logging.error('self client:' + str(self.client))
logging.error('mock get patchnotes' + str(mock_get_patchnotes))
response = self.client.open( response = self.client.open(
'/patchnotes', '/patchnotes/2025-01-02',
method='GET', method='GET',
headers=headers) headers=headers
self.assert200(response, )
'Response body is : ' + response.data.decode('utf-8')) response_data = response.data.decode('utf-8').strip().strip('\"')
logging.error(response_data + "response_data")
response_data_type = type(response_data)
logging.error("response_data_type:" + str(response_data_type))
logging.error("response data" + response_data)
response_data = datetime.strptime(response_data, '%Y-%m-%d').date()
logging.error(str(response_data) + "response_data after format")
try:
formatted_date = response_data.strftime('%Y-%m-%d')
logging.error(formatted_date)
logging.info("valid date")
except ValueError:
logging.error("Not valid date")
self.assert200(response, 'Response body is : ' + response.data.decode('utf-8'))
@unittest.mock.patch('openapi_server.controllers.patchnotes_controller.patchnotes_date_get')
def test_get_patchnotes_404(self, mock_get_patchnotes): # DONE
"""Test case for get_patchnotes
"""
headers = {
'Accept': 'application/json',
}
with self.app.test_request_context():
full_url = url_for('get_patchnotes', date='2023-01-01', _external=True)
logging.error("Full URL: " + full_url)
url = '/api/patchnotes/{date}'.format(date='2023-01-01')
logging.error(f"request URL: {url}")
logging.error('self client:' + str(self.client))
logging.error('mock get patchnotes' + str(mock_get_patchnotes))
logging.error('self name stuff:' + str(self.app.config['SERVER_NAME']))
response = self.client.open(
url,
method='GET',
headers=headers
)
logging.error(f"Response Status Code: {response.status_code}")
logging.error(f"Response Data: {response.data.decode('utf-8')}")
self.assert404(response, 'Response body is : ' + response.data.decode('utf-8'))
@unittest.mock.patch('openapi_server.controllers.patchnotes_controller.patchnotes_patch_iddelete')
def test_patch_note_delete(self, balala):
def test_patch_note_delete(self):
"""Test case for patch_note_delete """Test case for patch_note_delete
""" """
headers = { headers = {
} }
patch_note_mock = {
"changes": "test changes",
"date": "2025-01-02",
"patchID": "29e80bcc-5981-4a52-99e1-373442dea9b9",
"title": "test patch"
}
self.client.open(
'/patchnotes',
method='POST',
headers=headers,
data=json.dumps(patch_note_mock),
content_type='application/json'
)
response = self.client.open( response = self.client.open(
'/patchnotes/{patch_id}'.format(patch_id='patch_id_example'), '/patchnotes/{patch_id}'.format(patch_id=patch_note_mock['patchID']),
method='DELETE', method='DELETE',
headers=headers) headers=headers
self.assert200(response, )
'Response body is : ' + response.data.decode('utf-8'))
def test_post_patchnotes(self): self.assert200(response, 'Response body is : ' + response.data.decode('utf-8'))
"""Test case for post_patchnotes
@unittest.mock.patch('openapi_server.controllers.patchnotes_controller.patchnotes_patch_iddelete')
def test_patch_note_delete_not_found(self, balala):
"""Test case for patch_note_delete
""" """
patch_notes = openapi_server.PatchNotes() headers = {
}
patch_note_mock = {
"changes": "test changes",
"date": "2025-01-02",
"patchID": "29e80bcc-5981-4a52-99e1-373442dea9b9",
"title": "test patch"
}
response = self.client.open(
'/patchnotes/{patch_id}'.format(patch_id=''),
method='DELETE',
headers=headers
)
self.assert404(response, 'Response body is : ' + response.data.decode('utf-8'))
@unittest.mock.patch('openapi_server.controllers.patchnotes_controller.patchnotes_post')
def test_post_patchnotes(self, balala):
"""Test case for post_patchnotes
"""
post_patchnotes_mock = {
"changes": "test changes",
"date": "2025-01-02",
"patchID": "29e80bcc-5981-4a52-99e1-373442dea9b9",
"title": "test patch"
}
headers = { headers = {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
} }
response = self.client.open( response = self.client.open(
'/patchnotes', '/patchnotes',
method='POST', method='POST',
headers=headers, headers=headers,
data=json.dumps(patch_notes), data=json.dumps(post_patchnotes_mock),
content_type='application/json') content_type='application/json'
self.assert200(response, )
'Response body is : ' + response.data.decode('utf-8'))
self.assert200(response, 'Response body is : ' + response.data.decode('utf-8'))
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -1,5 +1,8 @@
python_dateutil >= 2.5.3 connexion[swagger-ui, flask, uvicorn] >= 3.2.0
werkzeug == 3.1.3
swagger-ui-bundle >= 0.0.2
python_dateutil >= 2.6.0
setuptools >= 21.0.0 setuptools >= 21.0.0
urllib3 >= 1.25.3, < 2.1.0 Flask >= 3.1.0
pydantic >= 2 Flask-PyMongo >= 3.0.1
typing-extensions >= 4.7.1 pymongo >= 4.11.3

View File

@ -1,18 +1,8 @@
# coding: utf-8 import sys
from setuptools import setup, find_packages
""" NAME = "openapi_server"
announcementService VERSION = "1.0.0"
Announcing patchnotes for KanzleiApp
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
from setuptools import setup, find_packages # noqa: H301
# To install the library, run the following # To install the library, run the following
# #
@ -20,30 +10,28 @@ from setuptools import setup, find_packages # noqa: H301
# #
# prerequisite: setuptools # prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools # http://pypi.python.org/pypi/setuptools
NAME = "openapi-client"
VERSION = "1.0.0"
PYTHON_REQUIRES = ">=3.7"
REQUIRES = [ REQUIRES = [
"urllib3 >= 1.25.3, < 2.1.0", "connexion>=2.0.2",
"python-dateutil", "swagger-ui-bundle>=0.0.2",
"pydantic >= 2", "python_dateutil>=2.6.0"
"typing-extensions >= 4.7.1",
] ]
setup( setup(
name=NAME, name=NAME,
version=VERSION, version=VERSION,
description="announcementService", description="announcementService",
author="OpenAPI Generator community", author_email="",
author_email="team@openapitools.org",
url="", url="",
keywords=["OpenAPI", "OpenAPI-Generator", "announcementService"], keywords=["OpenAPI", "announcementService"],
install_requires=REQUIRES, install_requires=REQUIRES,
packages=find_packages(exclude=["test", "tests"]), packages=find_packages(),
package_data={'': ['openapi/openapi.yaml']},
include_package_data=True, include_package_data=True,
long_description_content_type='text/markdown', entry_points={
'console_scripts': ['openapi_server=openapi_server.__main__:main']},
long_description="""\ long_description="""\
Announcing patchnotes for KanzleiApp Announcing patchnotes for KanzleiApp
""", # noqa: E501 """
package_data={"openapi_client": ["py.typed"]},
) )

View File

@ -1,5 +1,4 @@
pytest~=7.1.3 pytest~=7.1.0
pytest-cov>=2.8.1 pytest-cov>=2.8.1
pytest-randomly>=3.12.0 pytest-randomly>=1.2.3
mypy>=1.4.1 Flask-Testing==0.8.1
types-python-dateutil>=2.8.19

View File

@ -1,9 +1,11 @@
[tox] [tox]
envlist = py3 envlist = py3
skipsdist=True
[testenv] [testenv]
deps=-r{toxinidir}/requirements.txt deps=-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
{toxinidir}
commands= commands=
pytest --cov=openapi_client pytest --cov=openapi_server

View File

@ -3,7 +3,10 @@ setuptools >= 21.0.0
urllib3 >= 2.2.2, < 2.3.0 urllib3 >= 2.2.2, < 2.3.0
pydantic >= 2 pydantic >= 2
typing-extensions >= 4.7.1 typing-extensions >= 4.7.1
Flask Flask >= 3.1.0
pymongo[srv] Flask-PyMongo >= 3.0.1
Flask-PyMongo pymongo >= 4.11.3
connexion[swagger-ui] >= 2.6.6 connexion[swagger-ui, flask] >= 3.2.0
werkzeug == 3.1.3
swagger-ui-bundle >= 0.0.2
uvicorn >= 0.21.1

View File

@ -24,7 +24,7 @@ NAME = "openapi-client"
VERSION = "1.0.0" VERSION = "1.0.0"
PYTHON_REQUIRES = ">=3.7" PYTHON_REQUIRES = ">=3.7"
REQUIRES = [ REQUIRES = [
"urllib3 >= 1.25.3, < 2.1.0", "urllib3 >= 2.3.0",
"python-dateutil", "python-dateutil",
"pydantic >= 2", "pydantic >= 2",
"typing-extensions >= 4.7.1", "typing-extensions >= 4.7.1",