Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
postmon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Matheus Horstmann
postmon
Commits
faa12fa1
Commit
faa12fa1
authored
10 years ago
by
Iuri de Silvio
Browse files
Options
Downloads
Patches
Plain Diff
Tratamento do CORS nos resultados de erro.
parent
9505acad
Branches
fix-404
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
PostmonServer.py
+3
-1
3 additions, 1 deletion
PostmonServer.py
test/postmon_test.py
+4
-0
4 additions, 0 deletions
test/postmon_test.py
with
7 additions
and
1 deletion
PostmonServer.py
+
3
−
1
View file @
faa12fa1
...
...
@@ -66,7 +66,9 @@ def make_error(message):
'
jsonp
'
:
'
application/javascript
'
,
}
format_
=
bottle
.
request
.
query
.
get
(
'
format
'
,
'
json
'
)
return
HTTPResponse
(
status
=
message
,
content_type
=
formats
[
format_
])
response
=
HTTPResponse
(
status
=
message
,
content_type
=
formats
[
format_
])
response
.
headers
[
'
Access-Control-Allow-Origin
'
]
=
'
*
'
return
response
def
_get_estado_info
(
db
,
sigla
):
...
...
This diff is collapsed.
Click to expand it.
test/postmon_test.py
+
4
−
0
View file @
faa12fa1
...
...
@@ -219,6 +219,7 @@ class PostmonErrors(unittest.TestCase):
response
=
self
.
get_cep
(
'
99999999
'
,
expect_errors
=
True
)
self
.
assertEqual
(
"
404 CEP 99999999 nao encontrado
"
,
response
.
status
)
self
.
assertEqual
(
'
application/json
'
,
response
.
headers
[
'
Content-Type
'
])
self
.
assertEqual
(
'
*
'
,
response
.
headers
[
'
Access-Control-Allow-Origin
'
])
self
.
assertEqual
(
''
,
response
.
body
)
@mock.patch
(
'
PostmonServer._get_info_from_source
'
)
...
...
@@ -227,6 +228,7 @@ class PostmonErrors(unittest.TestCase):
response
=
self
.
get_cep
(
'
99999999
'
,
format
=
'
xml
'
,
expect_errors
=
True
)
self
.
assertEqual
(
"
404 CEP 99999999 nao encontrado
"
,
response
.
status
)
self
.
assertEqual
(
'
application/xml
'
,
response
.
headers
[
'
Content-Type
'
])
self
.
assertEqual
(
'
*
'
,
response
.
headers
[
'
Access-Control-Allow-Origin
'
])
self
.
assertEqual
(
''
,
response
.
body
)
@mock.patch
(
'
PostmonServer._get_info_from_source
'
)
...
...
@@ -236,6 +238,7 @@ class PostmonErrors(unittest.TestCase):
self
.
assertEqual
(
"
503 Servico Temporariamente Indisponivel
"
,
response
.
status
)
self
.
assertEqual
(
'
application/json
'
,
response
.
headers
[
'
Content-Type
'
])
self
.
assertEqual
(
'
*
'
,
response
.
headers
[
'
Access-Control-Allow-Origin
'
])
self
.
assertEqual
(
''
,
response
.
body
)
@mock.patch
(
'
PostmonServer._get_info_from_source
'
)
...
...
@@ -245,6 +248,7 @@ class PostmonErrors(unittest.TestCase):
self
.
assertEqual
(
"
503 Servico Temporariamente Indisponivel
"
,
response
.
status
)
self
.
assertEqual
(
'
application/xml
'
,
response
.
headers
[
'
Content-Type
'
])
self
.
assertEqual
(
'
*
'
,
response
.
headers
[
'
Access-Control-Allow-Origin
'
])
self
.
assertEqual
(
''
,
response
.
body
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment