FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
docker-python/tests/test_bigquery.py at master · Dhusanth/docker-python · GitHub
Dhusanth
/
docker-python
Public
forked from
Kaggle/docker-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
docker-python
/
tests
/
test_bigquery.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (29 loc) · 1.1 KB
Breadcrumbs
docker-python
/
tests
/
test_bigquery.py
Copy path
File metadata and controls
38 lines (29 loc) · 1.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import
unittest
import
os
import
threading
from
http
.
server
import
BaseHTTPRequestHandler
,
HTTPServer
from
google
.
cloud
import
bigquery
HOSTNAME
=
"127.0.0.1"
PORT
=
8000
URL
=
"http://%s:%s"
%
(
HOSTNAME
,
PORT
)
class
TestBigQuery
(
unittest
.
TestCase
):
def
test_proxy
(
self
):
httpd
=
HTTPServer
((
HOSTNAME
,
PORT
),
HTTPHandler
)
threading
.
Thread
(
target
=
httpd
.
serve_forever
).
start
()
client
=
bigquery
.
Client
()
try
:
for
ds
in
client
.
list_datasets
():
pass
except
:
pass
httpd
.
shutdown
()
self
.
assertTrue
(
HTTPHandler
.
called
,
msg
=
"Fake server did not recieve a request from the BQ client."
)
self
.
assertTrue
(
HTTPHandler
.
header_found
,
msg
=
"X-KAGGLE-PROXY-DATA header was missing from the BQ request."
)
class
HTTPHandler
(
BaseHTTPRequestHandler
):
called
=
False
header_found
=
False
def
do_HEAD
(
s
):
s
.
send_response
(
200
)
def
do_GET
(
s
):
HTTPHandler
.
called
=
True
HTTPHandler
.
header_found
=
any
(
k
for
k
in
s
.
headers
if
k
==
"X-KAGGLE-PROXY-DATA"
and
s
.
headers
[
k
]
==
"test-key"
)
s
.
send_response
(
200
)
Back
|
FazBrowse Home
|
New Git URL