Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Commit c34c247

Browse files
committed
Update tests
1 parent 929761d commit c34c247

File tree

4 files changed

+43
-17
lines changed

4 files changed

+43
-17
lines changed

README.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ The Flood Tiles product give the ability to customize maps by layering on flood
361361
tile.<method>
362362
```
363363

364-
* `get_probability_depth`(coordinate `tuple of int`, year `int`, return_period `int`, image `bool`, [output_dir `str='cwd'`], [extra_param `str=None`]) - Returns an array of `Probability Depth Tile` product for the given coordinates, and optionally creates an image file
365-
* `get_historic_event`(coordinate `tuple of int`, event_id `int`, image `bool`, [output_dir `str='cwd'`], [extra_param `str=None`]) - Returns an array of `Historic Event Tile` product for the given coordinates, and optionally creates an image file
364+
* `get_probability_depth`(coordinate `list of tuple of int [(z, x, y)]`, year `int`, return_period `int`, image `bool`, [output_dir `str='cwd'`], [extra_param `str=None`]) - Returns an array of `Probability Depth Tile` product for the given coordinates, and optionally creates an image file
365+
* `get_historic_event`(coordinate `list of tuple of int [(z, x, y)]`, event_id `int`, image `bool`, [output_dir `str='cwd'`], [extra_param `str=None`]) - Returns an array of `Historic Event Tile` product for the given coordinates, and optionally creates an image file
366366

367367
<a name="examples"></a>
368368
# [Examples](#toc)
@@ -497,14 +497,14 @@ tile.<method>
497497
540651172,1,0,1,0,0
498498
```
499499

500-
5. Different Location Types Through the Client:
500+
5. Different Location Types Through the Command Line:
501501

502502
**Note that the separator for each item must be a semicolon `;`**
503503
```sh
504504
python -m firststreet -p location.get_detail -i "362493883;(40.792505,-73.951949);1220 5th Ave, New York, NY" -l property
505505
```
506506

507-
7. Different Locatio Types From File to CSV Through Command Line:
507+
6. Different Locatio Types From File to CSV Through Command Line:
508508

509509
Content of sample.txt:
510510
```text
@@ -516,6 +516,25 @@ tile.<method>
516516
```sh
517517
python -m firststreet -p location.get_summary -f sample.txt -l property
518518
```
519+
520+
7. Getting a Tile from the API Tile Product Through the Client:
521+
```python
522+
# Contents of sample.py
523+
import firststreet
524+
fs = firststreet.FirstStreet("api-key")
525+
526+
fs.tile.get_probability_depth(year=2050, return_period=500, coordinate=[(14, 2633, 5694)], image=True)
527+
tile_image = fs.tile.get_historic_event(event_id=2, coordinate=[(12, 942, 1715)], image=False)
528+
```
529+
530+
8. Getting a Tile from the API Tile Product Through the Command Line:
531+
532+
**Note that the separator for each coordinate must be a semicolon `;`, and the spacing within the coordinates**
533+
```sh
534+
python -m firststreet -p tile.get_probability_depth -i (12,942,1715);(11,942,1715) -year 2050 -return_period 500
535+
python -m firststreet -p tile.get_historic_event -i (12,942,1715) -event_id 14
536+
```
537+
519538

520539
<a name="csv-output"></a>
521540
# [CSV File Output:](#toc)

firststreet/http_util.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ async def execute(self, endpoint, session, throttler):
107107
try:
108108
async with session.get(endpoint[0], headers=headers) as response:
109109

110-
print(response)
111-
112110
# Read a tile response
113111
if endpoint[2] == 'tile':
114112
return await self.tile_response(response, endpoint)

tests/test_command_line.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ python -m firststreet -p adaptation.get_detail -i 39 -log False
1212
python -m firststreet -p adaptation.get_details_by_location -i 3807200 -l city -log True
1313
python -m firststreet -p historic.get_events_by_location -i 3807200 -l city -log False
1414

15-
python -m firststreet -p tile.get_probability_depth -i [(12, 942, 1715)] -year 2050 -return_period 500
16-
python -m firststreet -p tile.get_historic_event -i 3807200 -l city -log False
15+
python -m firststreet -p tile.get_probability_depth -i (12,942,1715) -year 2050 -return_period 500
16+
python -m firststreet -p tile.get_historic_event -i (12,942,1715) -event_id 14

tests/test_http.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,60 +12,69 @@ def test_error_400(self, setup_connection):
1212
loop = asyncio.get_event_loop()
1313
endpoint = ("https://httpstat.us/400", "test_item", "test_product", "test_subtype")
1414
response = loop.run_until_complete(setup_connection.endpoint_execute([endpoint]))
15-
print(response)
15+
assert len(response) == 1
16+
assert response[0]['search_item'] == "test_item"
1617

1718
def test_error_403(self, setup_connection):
1819

1920
loop = asyncio.get_event_loop()
2021
endpoint = ("https://httpstat.us/403", "test_item", "test_product", "test_subtype")
2122
response = loop.run_until_complete(setup_connection.endpoint_execute([endpoint]))
22-
print(response)
23+
assert len(response) == 1
24+
assert response[0]['search_item'] == "test_item"
2325

2426
def test_error_404(self, setup_connection):
2527

2628
loop = asyncio.get_event_loop()
2729
endpoint = ("https://httpstat.us/404", "test_item", "test_product", "test_subtype")
2830
response = loop.run_until_complete(setup_connection.endpoint_execute([endpoint]))
29-
print(response)
31+
assert len(response) == 1
32+
assert response[0]['search_item'] == "test_item"
3033

3134
def test_error_500(self, setup_connection):
3235

3336
loop = asyncio.get_event_loop()
3437
endpoint = ("https://httpstat.us/500", "test_item", "test_product", "test_subtype")
3538
response = loop.run_until_complete(setup_connection.endpoint_execute([endpoint]))
36-
print(response)
39+
assert len(response) == 1
40+
assert response[0]['search_item'] == "test_item"
3741

3842
def test_error_501(self, setup_connection):
3943

4044
loop = asyncio.get_event_loop()
4145
endpoint = ("https://httpstat.us/501", "test_item", "test_product", "test_subtype")
4246
response = loop.run_until_complete(setup_connection.endpoint_execute([endpoint]))
43-
print(response)
47+
assert len(response) == 1
48+
assert response[0]['search_item'] == "test_item"
4449

4550
def test_error_502(self, setup_connection):
4651

4752
loop = asyncio.get_event_loop()
4853
endpoint = ("https://httpstat.us/502", "test_item", "test_product", "test_subtype")
4954
response = loop.run_until_complete(setup_connection.endpoint_execute([endpoint]))
50-
print(response)
55+
assert len(response) == 1
56+
assert response[0]['search_item'] == "test_item"
5157

5258
def test_error_503(self, setup_connection):
5359

5460
loop = asyncio.get_event_loop()
5561
endpoint = ("https://httpstat.us/503", "test_item", "test_product", "test_subtype")
5662
response = loop.run_until_complete(setup_connection.endpoint_execute([endpoint]))
57-
print(response)
63+
assert len(response) == 1
64+
assert response[0]['search_item'] == "test_item"
5865

5966
def test_error_522(self, setup_connection):
6067

6168
loop = asyncio.get_event_loop()
6269
endpoint = ("https://httpstat.us/522", "test_item", "test_product", "test_subtype")
6370
response = loop.run_until_complete(setup_connection.endpoint_execute([endpoint]))
64-
print(response)
71+
assert len(response) == 1
72+
assert response[0]['search_item'] == "test_item"
6573

6674
def test_error_524(self, setup_connection):
6775

6876
loop = asyncio.get_event_loop()
6977
endpoint = ("https://httpstat.us/524", "test_item", "test_product", "test_subtype")
7078
response = loop.run_until_complete(setup_connection.endpoint_execute([endpoint]))
71-
print(response)
79+
assert len(response) == 1
80+
assert response[0]['search_item'] == "test_item"

0 commit comments

Comments
 (0)