Skip to content

Commit 95ca3d0

Browse files
ki4070maKazuCocoa
authored andcommitted
Add network unittest (#308)
* Add network connection test * Added set network connection test * Add toggle wifi test * Removed unnecessary codes from toggle wifi test * Changed assertion for set network connection test
1 parent 9733c60 commit 95ca3d0

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from appium.webdriver.webdriver import WebDriver
16+
from test.unit.helper.test_helper import appium_command, android_w3c_driver
17+
18+
import httpretty
19+
import json
20+
21+
22+
class TestWebDriverNetwork(object):
23+
24+
@httpretty.activate
25+
def test_network_connection(self):
26+
driver = android_w3c_driver()
27+
httpretty.register_uri(
28+
httpretty.GET,
29+
appium_command('/session/1234567890/network_connection'),
30+
body='{"value": 2}'
31+
)
32+
assert driver.network_connection == 2
33+
34+
@httpretty.activate
35+
def test_set_network_connection(self):
36+
driver = android_w3c_driver()
37+
httpretty.register_uri(
38+
httpretty.POST,
39+
appium_command('/session/1234567890/network_connection'),
40+
body='{"value": ""}'
41+
)
42+
driver.set_network_connection(2)
43+
44+
d = json.loads(httpretty.last_request().body.decode('utf-8'))
45+
assert d['parameters']['type'] == 2
46+
47+
@httpretty.activate
48+
def test_toggle_wifi(self):
49+
driver = android_w3c_driver()
50+
httpretty.register_uri(
51+
httpretty.POST,
52+
appium_command('/session/1234567890/appium/device/toggle_wifi'),
53+
)
54+
assert isinstance(driver.toggle_wifi(), WebDriver) is True

0 commit comments

Comments
 (0)