1
- from datetime import datetime
2
1
from pathlib import Path
3
2
4
- import pytest
5
3
from flask import request
6
- from flask_first .first .exceptions import FirstRequestJSONValidation
7
- from flask_first .first .exceptions import FirstResponseJSONValidation
8
4
9
5
from .conftest import BASEDIR
10
6
@@ -20,48 +16,3 @@ def default_responses() -> dict:
20
16
r = test_client .post ('/message' , json = {'message' : 'OK' })
21
17
assert r .status_code == 200
22
18
assert r .json ['message' ] == 'OK'
23
-
24
-
25
- def test_responses__datetime (fx_create_app ):
26
- def create_datetime () -> dict :
27
- datetime = request .extensions ['first' ]['json' ]['datetime' ].strftime ("%Y-%m-%dT%H:%M:%S.%fZ" )
28
- return {'datetime' : datetime }
29
-
30
- test_client = fx_create_app (
31
- Path (BASEDIR , 'specs/v3.1.0/datetime.openapi.yaml' ), [create_datetime ]
32
- )
33
-
34
- json = {'datetime' : datetime .utcnow ().strftime ("%Y-%m-%dT%H:%M:%S.%fZ" )}
35
- r = test_client .post ('/datetime' , json = json )
36
- assert r .status_code == 200
37
- assert r .json ['datetime' ] == json ['datetime' ]
38
-
39
-
40
- def test_responses__request_datetime_error (fx_create_app ):
41
- def create_datetime () -> dict :
42
- datetime = request .extensions ['first' ]['json' ]['datetime' ]
43
- return {'datetime' : datetime }
44
-
45
- test_client = fx_create_app (
46
- Path (BASEDIR , 'specs/v3.1.0/datetime.openapi.yaml' ), [create_datetime ]
47
- )
48
-
49
- json = {'datetime' : datetime .utcnow ().isoformat ()}
50
-
51
- with pytest .raises (FirstRequestJSONValidation ):
52
- test_client .post ('/datetime' , json = json )
53
-
54
-
55
- def test_responses__response_datetime_error (fx_create_app ):
56
- def create_datetime () -> dict :
57
- datetime = request .extensions ['first' ]['json' ]['datetime' ].isoformat ()
58
- return {'datetime' : datetime }
59
-
60
- test_client = fx_create_app (
61
- Path (BASEDIR , 'specs/v3.1.0/datetime.openapi.yaml' ), [create_datetime ]
62
- )
63
-
64
- json = {'datetime' : datetime .utcnow ().strftime ("%Y-%m-%dT%H:%M:%S.%fZ" )}
65
-
66
- with pytest .raises (FirstResponseJSONValidation ):
67
- test_client .post ('/datetime' , json = json )
0 commit comments