当前位置: 首页>>代码示例>>Python>>正文


Python PropertyMock.assert_called_once_with方法代码示例

本文整理汇总了Python中mock.PropertyMock.assert_called_once_with方法的典型用法代码示例。如果您正苦于以下问题:Python PropertyMock.assert_called_once_with方法的具体用法?Python PropertyMock.assert_called_once_with怎么用?Python PropertyMock.assert_called_once_with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mock.PropertyMock的用法示例。


在下文中一共展示了PropertyMock.assert_called_once_with方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_change_xy_log

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_once_with [as 别名]
    def test_change_xy_log(self):
        view_x_log_mock = PropertyMock()
        view_y_log_mock = PropertyMock()
        model_x_log_mock = PropertyMock(return_value=True)
        model_y_log_mock = PropertyMock(return_value=False)
        model_x_range_mock = PropertyMock(return_value=(1, 2))
        model_y_range_mock = PropertyMock(return_value=(3, 4))
        type(self.view).x_log = view_x_log_mock
        type(self.view).y_log = view_y_log_mock
        type(self.model).x_log = model_x_log_mock
        type(self.model).y_log = model_y_log_mock
        type(self.model).x_range = model_x_range_mock
        type(self.model).y_range = model_y_range_mock

        # model -> view
        self.presenter = CutPlotOptionsPresenter(self.view, self.model)
        view_x_log_mock.assert_called_once_with(True)
        view_y_log_mock.assert_called_once_with(False)

        # view -> model
        view_x_log_mock.return_value = False
        view_y_log_mock.return_value = True
        self.presenter._xy_config_modified('x_log')
        self.presenter._xy_config_modified('y_log')
        self.presenter.get_new_config()
        self.model.change_axis_scale.assert_called_once_with({'x_range': (1, 2), 'y_range': (3, 4), 'modified': True,
                                                              'x_log': False,    'y_log': True})
开发者ID:mantidproject,项目名称:mslice,代码行数:29,代码来源:plot_options_presenter_test.py

示例2: test_change_colorbar_config

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_once_with [as 别名]
    def test_change_colorbar_config(self):
        view_colorbar_range_mock = PropertyMock()
        view_colorbar_log_mock = PropertyMock()
        type(self.view).colorbar_range = view_colorbar_range_mock
        type(self.view).colorbar_log = view_colorbar_log_mock

        model_colorbar_range_mock = PropertyMock(return_value=(1, 5))
        model_colorbar_log_mock = PropertyMock(return_value=False)
        type(self.model).colorbar_range = model_colorbar_range_mock
        type(self.model).colorbar_log = model_colorbar_log_mock

        # passed model -> view
        self.presenter = SlicePlotOptionsPresenter(self.view, self.model)

        model_colorbar_range_mock.assert_called_with()
        model_colorbar_log_mock.assert_called_with()
        view_colorbar_range_mock.assert_called_once_with((1, 5))
        view_colorbar_log_mock.assert_called_once_with(False)

        # passed view -> model
        view_colorbar_range_mock.return_value = (2, 10)
        view_colorbar_log_mock.return_value = True
        self.presenter._set_c_range()
        self.presenter._set_colorbar_log()
        self.presenter.get_new_config()
        self.model.change_axis_scale.assert_called_once_with((2, 10), True)
开发者ID:mantidproject,项目名称:mslice,代码行数:28,代码来源:plot_options_presenter_test.py

示例3: test_change_xrange

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_once_with [as 别名]
    def test_change_xrange(self):

        view_x_range_mock = PropertyMock()
        type(self.view).x_range = view_x_range_mock

        model_x_range_mock = PropertyMock(return_value=(1, 5))
        type(self.model).x_range = model_x_range_mock

        # passed model -> view
        self.presenter1 = SlicePlotOptionsPresenter(self.view, self.model)

        model_x_range_mock.assert_called_with()
        view_x_range_mock.assert_called_once_with((1, 5))

        # passed view -> model through slice presenter
        model_x_range_mock.reset_mock()
        view_x_range_mock.return_value = (2, 10)
        self.presenter1._xy_config_modified('x_range')
        self.presenter1.get_new_config()
        model_x_range_mock.assert_called_once_with((2, 10))

        # passed view -> model through cut presenter
        self.presenter2 = CutPlotOptionsPresenter(self.view, self.model)
        self.presenter2._xy_config_modified('x_range')
        self.presenter2.get_new_config()
        self.model.change_axis_scale.assert_called_once()
开发者ID:mantidproject,项目名称:mslice,代码行数:28,代码来源:plot_options_presenter_test.py

示例4: test_propertymock_returnvalue

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_once_with [as 别名]
    def test_propertymock_returnvalue(self):
        m = MagicMock()
        p = PropertyMock()
        type(m).foo = p

        returned = m.foo
        p.assert_called_once_with()
        self.assertIsInstance(returned, MagicMock)
        self.assertNotIsInstance(returned, PropertyMock)
开发者ID:AaronJaramillo,项目名称:shopDPM,代码行数:11,代码来源:testhelpers.py

示例5: verify_super_property_called_with_wait

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_once_with [as 别名]
    def verify_super_property_called_with_wait(self, prop_name):
        """
        Verifies that accessing the given property calls the equally
        named property on the super class.
        """
        with patch(
                super_str
        ) as mock_super, patch.object(
            self.instance, 'wait_for_angular'
        ) as mock_wait_for_angular:
            # setup the mocked property
            mock_prop = PropertyMock(name='super.{}'.format(prop_name))
            setattr(type(mock_super.return_value), prop_name, mock_prop)

            result = getattr(self.instance, prop_name)

        mock_wait_for_angular.assert_called_once_with()
        mock_super.assert_called_once_with(WebDriverMixin, self.instance)
        mock_prop.assert_called_once_with()
        self.assertIs(result, mock_prop.return_value)
开发者ID:avi3tal,项目名称:pytractor,代码行数:22,代码来源:test_mixins.py

示例6: test_get_scheduler

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_once_with [as 别名]
  def test_get_scheduler(self):
    """Tests successful execution of the get_scheduler command."""
    mock_options = self.setup_mock_options()
    mock_proxy = create_autospec(spec=SchedulerProxy, instance=True)
    mock_scheduler_client = create_autospec(spec=SchedulerClient, instance=True)
    mock_raw_url = PropertyMock(return_value="url")
    mock_proxy.scheduler_client.return_value = mock_scheduler_client
    type(mock_scheduler_client).raw_url = mock_raw_url

    with contextlib.nested(
        patch('twitter.common.app.get_options', return_value=mock_options),
        patch('apache.aurora.admin.admin.make_admin_client',
              return_value=create_autospec(spec=AuroraClientAPI)),
        patch('apache.aurora.admin.admin.CLUSTERS', new=self.TEST_CLUSTERS),
    ) as (_, mock_make_admin_client, _):

      api = mock_make_admin_client.return_value
      type(api).scheduler_proxy = PropertyMock(return_value=mock_proxy)

      get_scheduler([self.TEST_CLUSTER])

      mock_raw_url.assert_called_once_with()
开发者ID:bmhatfield,项目名称:aurora,代码行数:24,代码来源:test_admin.py

示例7: test_change_title

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_once_with [as 别名]
    def test_change_title(self):

        mock_view_title = PropertyMock()
        type(self.view).title = mock_view_title

        mock_model_title = PropertyMock(return_value='Title 0')
        type(self.model).title = mock_model_title

        # title passed model -> view
        self.presenter = CutPlotOptionsPresenter(self.view, self.model)

        mock_model_title.assert_called_once_with()
        mock_view_title.assert_called_once_with('Title 0')

        # title passed view -> model
        mock_view_title.reset_mock()
        mock_model_title.reset_mock()
        mock_view_title.return_value = 'Title 1'
        self.presenter._value_modified('title')
        self.presenter.get_new_config()

        mock_view_title.assert_called_once_with()
        mock_model_title.assert_called_once_with('Title 1')
开发者ID:mantidproject,项目名称:mslice,代码行数:25,代码来源:plot_options_presenter_test.py

示例8: TestGeometry

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_once_with [as 别名]

#.........这里部分代码省略.........
        # Check that retrieving coordinates from `Location` objects works.
        # The supported location types of the geometry are tested.
        loc1 = LocationLocal(1.0, 2.0, -3.0)
        self.assertEqual(self.geometry.get_coordinates(loc1), (1.0, 2.0, 3.0))

        loc2 = self._make_relative_location(4.0, 5.0, 6.0)
        self.assertEqual(self.geometry.get_coordinates(loc2), (4.0, 5.0, 6.0))

        loc3 = self._make_global_location(7.0, 8.0, 9.0)
        self.assertEqual(self.geometry.get_coordinates(loc3), (7.0, 8.0, 9.0))

        # A `Location` object must be provided.
        with self.assertRaises(TypeError):
            self.geometry.get_coordinates(None)

    def test_bearing_to_angle(self):
        bearing = -45.0 * math.pi/180
        self.assertEqual(self.geometry.bearing_to_angle(bearing),
                         135.0 * math.pi/180)

    def test_angle_to_bearing(self):
        angle = 180.0 * math.pi/180
        self.assertEqual(self.geometry.angle_to_bearing(angle),
                         270.0 * math.pi/180)

    def test_get_location_local(self):
        local_location = LocationLocal(7.6, 5.4, -3.2)
        self.assertEqual(self.geometry.get_location_local(local_location),
                         local_location)

        self.local_mock.configure_mock(return_value=local_location)
        self.assertEqual(self.geometry.get_location_local(self.locations_mock),
                         local_location)
        self.local_mock.assert_called_once_with()

    def test_get_location_local_other(self):
        # Base geometry does not support relative or global locations.
        with self.assertRaises(TypeError):
            self.geometry.get_location_local(self.global_location)
        with self.assertRaises(TypeError):
            self.geometry.get_location_local(self.relative_location)

    def test_get_location_frame(self):
        local_location = LocationLocal(7.6, 5.4, -3.2)
        self.local_mock.configure_mock(return_value=local_location)
        self.assertEqual(self.geometry.get_location_frame(self.locations_mock),
                         local_location)
        self.local_mock.assert_called_once_with()

    def test_get_location_frame_other(self):
        # A `Locations` object must be given.
        with self.assertRaises(TypeError):
            self.geometry.get_location_frame(self.local_location)
        with self.assertRaises(TypeError):
            self.geometry.get_location_frame(self.global_location)
        with self.assertRaises(TypeError):
            self.geometry.get_location_frame(self.relative_location)

    def test_get_location_meters(self):
        loc = LocationLocal(5.4, 3.2, -1.0)
        loc2 = LocationLocal(5.4, 3.2, -11.0)
        self.assertEqual(self.geometry.get_location_meters(loc, 0, 0, 0), loc)
        self.assertEqual(self.geometry.get_location_meters(loc, 0, 0, 10), loc2)

    def test_get_distance_meters(self):
        loc = LocationLocal(5.4, 3.2, -1.0)
开发者ID:lhelwerd,项目名称:mobile-radio-tomography,代码行数:70,代码来源:geometry.py

示例9: test_change_grid

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_once_with [as 别名]
    def test_change_grid(self):

        view_x_grid_mock = PropertyMock()
        view_y_grid_mock = PropertyMock()
        model_x_grid_mock = PropertyMock(return_value=False)
        model_y_grid_mock = PropertyMock(return_value=False)

        type(self.view).x_grid = view_x_grid_mock
        type(self.view).y_grid = view_y_grid_mock
        type(self.model).x_grid = model_x_grid_mock
        type(self.model).y_grid = model_y_grid_mock

        # labels passed model -> view
        self.presenter = SlicePlotOptionsPresenter(self.view, self.model)
        model_x_grid_mock.assert_called_once_with()
        model_y_grid_mock.assert_called_once_with()
        view_x_grid_mock.assert_called_once_with(False)
        view_y_grid_mock.assert_called_once_with(False)

        # labels passed view -> model
        model_x_grid_mock.reset_mock()
        model_y_grid_mock.reset_mock()
        view_x_grid_mock.reset_mock()
        view_y_grid_mock.reset_mock()

        view_x_grid_mock.return_value = True
        view_y_grid_mock.return_value = True
        self.presenter._value_modified('x_grid')
        self.presenter._value_modified('y_grid')
        self.presenter.get_new_config()

        view_x_grid_mock.assert_called_once_with()
        view_y_grid_mock.assert_called_once_with()
        model_x_grid_mock.assert_called_once_with(True)
        model_y_grid_mock.assert_called_once_with(True)
开发者ID:mantidproject,项目名称:mslice,代码行数:37,代码来源:plot_options_presenter_test.py

示例10: test_change_axis

# 需要导入模块: from mock import PropertyMock [as 别名]
# 或者: from mock.PropertyMock import assert_called_once_with [as 别名]
    def test_change_axis(self):

        view_x_label_mock = PropertyMock()
        view_y_label_mock = PropertyMock()
        model_x_label_mock = PropertyMock(return_value='x0')
        model_y_label_mock = PropertyMock(return_value='y0')

        type(self.view).x_label = view_x_label_mock
        type(self.view).y_label = view_y_label_mock
        type(self.model).x_label = model_x_label_mock
        type(self.model).y_label = model_y_label_mock

        # labels passed model -> view
        self.presenter = SlicePlotOptionsPresenter(self.view, self.model)
        model_x_label_mock.assert_called_once_with()
        model_y_label_mock.assert_called_once_with()
        view_x_label_mock.assert_called_once_with('x0')
        view_y_label_mock.assert_called_once_with('y0')

        # labels passed view -> model
        model_x_label_mock.reset_mock()
        model_y_label_mock.reset_mock()
        view_x_label_mock.reset_mock()
        view_y_label_mock.reset_mock()

        view_x_label_mock.return_value = 'x1'
        view_y_label_mock.return_value = 'y1'
        self.presenter._value_modified('x_label')
        self.presenter._value_modified('y_label')
        self.presenter.get_new_config()

        view_x_label_mock.assert_called_once_with()
        view_y_label_mock.assert_called_once_with()
        model_x_label_mock.assert_called_once_with('x1')
        model_y_label_mock.assert_called_once_with('y1')
开发者ID:mantidproject,项目名称:mslice,代码行数:37,代码来源:plot_options_presenter_test.py


注:本文中的mock.PropertyMock.assert_called_once_with方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。