Skip to content

Commit 339177a

Browse files
committed
Move/refactor map tests
- Move and refactor test_map.py - Bump Python dependency to 3.9 - Use latest flake8 revision
1 parent 9c57a58 commit 339177a

File tree

8 files changed

+236
-469
lines changed

8 files changed

+236
-469
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://gitlab.com/pycqa/flake8
3-
rev: 3.7.9
3+
rev: 7.0.0
44
hooks:
55
- id: flake8
66
args: ['--select=E501']

flask_googlemaps/tests/__init__.py

Whitespace-only changes.

flask_googlemaps/tests/test_map.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

poetry.lock

Lines changed: 178 additions & 398 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ packages = [
2323
include = ["flask_googlemaps/py.typed"]
2424

2525
[tool.poetry.dependencies]
26-
python = ">=3.8"
26+
python = ">=3.9"
2727
flask = ">=3.0.3"
2828
pre-commit = "3.7.0"
2929
mkdocs = "^1.5.3"

runtime.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.7
1+
3.9

tests/test_map.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from typing import Dict, List, Any
2+
3+
import pytest
4+
5+
from flask_googlemaps import Map
6+
7+
8+
@pytest.fixture
9+
def map_properties() -> Dict[str, Any]:
10+
return dict(identifier="gmap",
11+
varname="gmap",
12+
lat=37.4419,
13+
lng=-122.1419)
14+
15+
16+
@pytest.fixture
17+
def markers() -> List[Dict]:
18+
return [
19+
{
20+
"content": {"icon_url": "http://maps.google.com/"
21+
"mapfiles/ms/icons/green-dot.png"},
22+
"latitude": 37.4419,
23+
"longitude": -122.1419,
24+
"infobox": "<b>Hello World</b>",
25+
},
26+
{
27+
"latitude": 37.4300,
28+
"longitude": -122.1400,
29+
"infobox": "<b>Hello World from other place</b>",
30+
"content": {
31+
"border_color": "",
32+
"glyph_colors": "",
33+
"background": "",
34+
"glyph": "",
35+
"scale": 2.0,
36+
}
37+
},
38+
]
39+
40+
41+
def test_map_markers(markers: List[Dict], map_properties):
42+
assert len(Map(markers=markers, **map_properties).markers) == 2
43+
44+
45+
def test_map_markers_expected_errors(markers: List[Dict], map_properties):
46+
markers.append({"latitude": -1, "longitude": 250})
47+
with pytest.raises(AttributeError) as exception_info:
48+
Map(markers=markers, **map_properties)
49+
assert str(exception_info.value) == (
50+
"Longitude must be between -180 and 180 degrees inclusive."
51+
)

tests/test_marker.py

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import List, Dict
2-
31
import pytest
42

53
from flask_googlemaps.marker import Marker
@@ -23,31 +21,13 @@ def marker_pin_url() -> Marker:
2321
longitude=-122.1419,
2422
content={
2523
"icon_url": "https://developers.google.com/maps/"
26-
"documentation/javascript/examples/"
27-
"full/images/beachflag.png"
24+
"documentation/javascript/examples/"
25+
"full/images/beachflag.png"
2826
},
2927
infobox="<b>Hello World</b>",
3028
)
3129

3230

33-
@pytest.fixture
34-
def markers() -> List[Dict]:
35-
return [
36-
{
37-
"icon": "http://maps.google.com/mapfiles/ms/icons/green-dot.png",
38-
"latitude": 37.4419,
39-
"longitude": -122.1419,
40-
"infobox": "<b>Hello World</b>",
41-
},
42-
{
43-
"latitude": 37.4300,
44-
"longitude": -122.1400,
45-
"infobox": "<b>Hello World from other place</b>",
46-
"label": "1",
47-
},
48-
]
49-
50-
5131
def test_marker_without_lat_long():
5232
with pytest.raises(TypeError):
5333
Marker()
@@ -57,15 +37,15 @@ def test_marker_with_wrong_latitude():
5737
with pytest.raises(AttributeError) as exception_info:
5838
Marker(latitude=150, longitude=150)
5939
assert str(exception_info.value) == (
60-
"Latitude must be between " "-90 and 90 degrees inclusive."
40+
"Latitude must be between -90 and 90 degrees inclusive."
6141
)
6242

6343

6444
def test_marker_with_wrong_longitude():
6545
with pytest.raises(AttributeError) as exception_info:
6646
Marker(latitude=90, longitude=-190)
6747
assert str(exception_info.value) == (
68-
"Longitude must be between " "-180 and 180 degrees inclusive."
48+
"Longitude must be between -180 and 180 degrees inclusive."
6949
)
7050

7151

0 commit comments

Comments
 (0)