Created
December 8, 2015 18:15
-
-
Save hallvors/9061f046236c275060e1 to your computer and use it in GitHub Desktop.
Boar test example: testing the window.orientation plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
import requests | |
import sys | |
import time | |
import unittest | |
from ../shared_config import do_command | |
class TestConsoleLogging(unittest.TestCase): | |
# Note: the order matters. This API reports *accumulated* messages | |
# during the session. Hence, the tests expected to be no-ops must be first | |
def test_no_orientation_getter(self): | |
# Open URL | |
data = {'url': 'data:text/html,<html><script>void(\'foo\');</script><p>Hello test</p></html>'} | |
response = do_command(url, "open", data) | |
response = do_command(url, "getPluginsResults") | |
data = json.loads(response.text.encode('utf-8').strip()) | |
self.assertTrue('results' in data) | |
self.assertEqual(data['results']['window-orientation-usage'], False) | |
def test_orientation_getter(self): | |
# Open URL | |
data = {'url': 'data:text/html,<html><script>void(window.orientation);</script><p>Hello test</p></html>'} | |
response = do_command(url, "open", data) | |
response = do_command(url, "getPluginsResults") | |
data = json.loads(response.text.encode('utf-8').strip()) | |
self.assertTrue('results' in data) | |
self.assertEqual(data['results']['window-orientation-usage'], True) | |
@classmethod | |
def tearDownClass(self): | |
# Destroy Tab | |
response = do_command(url, "destroy") | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment