Example #1
0
    def add_driver(self, name):
        """
        Adds the name of the driver as the key and the Driver object as the value

        :param name: the name of the driver
        """
        self.update({name: Driver()})
    def set_driver(env="ios", desired_capability=None, app_path=''):
        if DriverManage.driver is None:
            if env == "Android":
                app = os.path.abspath(
                    os.path.join(
                        os.path.dirname(__file__),
                        #                            '../../build/outputs/apk/app-dev-debug.apk'))
                        '../'))
                desired_capabilities = {
                    'app': app,
                    'platformName': 'Android',
                    'platformVersion': '7.0',
                    'deviceName': 'test',
                    'browserName': 'Android',
                    'unicodeKeyboard': True,
                    'noReset': True
                }

            elif env == "ios":
                app = os.path.abspath(
                    os.path.join(os.path.dirname(__file__), '../Panda.app'))
                desired_capabilities = {
                    'app': app,
                    'platformName': 'iOS',
                    'platformVersion': '13.3',
                    'deviceName': 'iPhone 8',
                    'noReset': False
                    #  'autoWebview': True
                }
            if app_path != '':
                app = app
            elif desired_capability is not None:
                desired_capabilities = desired_capability
            DriverManage.driver = Driver(
                "appium",
                command_executor='http://127.0.0.1:4723/wd/hub',
                desired_capabilities=desired_capabilities).get_driver()
        else:
            pass
        return DriverManage.driver
Example #3
0
 def test_get_trips(self, mock_trips):
     driver = Driver()
     expected_driver_trips_type = mock_trips()
     actual_driver_trips_type = driver.trips
     self.assertEqual(expected_driver_trips_type, actual_driver_trips_type)
Example #4
0
 def test_get_trip_total_average_speed(self, mock_trips):
     driver = Driver()
     type(mock_trips.return_value).total_average_speed = PropertyMock(return_value=0.02)
     expected_total_average_speed = 0.02
     actual_total_average_speed = driver.get_trip_total_average_speed()
     self.assertEqual(expected_total_average_speed, actual_total_average_speed)
Example #5
0
 def test_get_trip_total_time_driven(self, mock_trips):
     driver = Driver()
     type(mock_trips.return_value).total_time_driven = PropertyMock(return_value=0.44)
     expected_total_time_driven = 0.44
     actual_total_time_driven = driver.get_trip_total_time_driven()
     self.assertEqual(expected_total_time_driven, actual_total_time_driven)
Example #6
0
 def test_add_trip(self, mock_trips):
     driver = Driver()
     mock_trips.add_trip = Mock()
     driver.add_trip()
     mock_trips().add_trip.assert_called_once()