Skip to content

Commit 125d0fa

Browse files
authored
Merge pull request sixfab#101 from sixfab/refactor/gps_data_format_change
Refactor: gps data format change
2 parents 78bf3dc + 94aaf3d commit 125d0fa

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

pico_lte/modules/gps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def get_location(self):
101101
* "response" --> Response of the command
102102
* "value" --> [lat,lon] Location of the device
103103
"""
104-
command = "AT+QGPSLOC?"
104+
command = "AT+QGPSLOC=2"
105105
desired = "+QGPSLOC: "
106106
result = self.atcom.send_at_comm(command, desired)
107107

tests/test_modules_gps.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ def gps(self):
3131
@staticmethod
3232
def mock_send_at_comm(mocker, responses_to_return):
3333
"""This is a wrapper function to repeated long mocker.patch() statements."""
34-
return mocker.patch("pico_lte.utils.atcom.ATCom.send_at_comm", return_value=responses_to_return)
34+
return mocker.patch(
35+
"pico_lte.utils.atcom.ATCom.send_at_comm", return_value=responses_to_return
36+
)
3537

3638
def test_constructor(self, gps):
3739
"""This method tests the __init__ constructor."""
@@ -68,7 +70,8 @@ def test_set_priority(self, mocker, gps, mocked_response):
6870

6971
@pytest.mark.parametrize(
7072
"mocked_response",
71-
[{"status": Status.SUCCESS, "response": ["+CME ERROR: 504"]}] + default_response_types(),
73+
[{"status": Status.SUCCESS, "response": ["+CME ERROR: 504"]}]
74+
+ default_response_types(),
7275
)
7376
def test_turn_on_default_parameters(self, mocker, gps, mocked_response):
7477
"""This method tests the turn_on() with predefined parameters."""
@@ -90,7 +93,9 @@ def test_turn_on_with_different_parameters(
9093
mocking = TestGPS.mock_send_at_comm(mocker, mocked_response)
9194
result = gps.turn_on(mode, accuracy, fix_count, fix_rate)
9295

93-
mocking.assert_called_once_with(f"AT+QGPS={mode},{accuracy},{fix_count},{fix_rate}")
96+
mocking.assert_called_once_with(
97+
f"AT+QGPS={mode},{accuracy},{fix_count},{fix_rate}"
98+
)
9499
assert result == mocked_response
95100

96101
@pytest.mark.parametrize("mocked_response", default_response_types())
@@ -108,7 +113,7 @@ def test_turn_off(self, mocker, gps, mocked_response):
108113
{
109114
"status": Status.SUCCESS,
110115
"response": [
111-
"+QGPSLOC: 061951.00,3150.7223N,11711.9293E,0.7,62.2,2,0.00,0.0,0.0,110513,09",
116+
"+QGPSLOC: 061951.00,41.02044,28.99797,0.7,62.2,2,0.00,0.0,0.0,110513,09",
112117
"OK",
113118
],
114119
},
@@ -121,9 +126,9 @@ def test_get_location(self, mocker, gps, mocked_response):
121126
mocking = TestGPS.mock_send_at_comm(mocker, mocked_response)
122127
result = gps.get_location()
123128

124-
mocking.assert_called_once_with("AT+QGPSLOC?", "+QGPSLOC: ")
129+
mocking.assert_called_once_with("AT+QGPSLOC=2", "+QGPSLOC: ")
125130

126131
if result["status"] == Status.SUCCESS:
127-
assert result["value"] == ["3150.7223N", "11711.9293E"]
132+
assert result["value"] == ["41.02044", "28.99797"]
128133
assert result["status"] == mocked_response["status"]
129134
assert result["response"] == mocked_response["response"]

0 commit comments

Comments
 (0)