本文整理汇总了Python中unittest.mock.MagicMock.metric_source_name方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.metric_source_name方法的具体用法?Python MagicMock.metric_source_name怎么用?Python MagicMock.metric_source_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.metric_source_name方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_format_text_with_links
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import metric_source_name [as 别名]
def test_format_text_with_links(self, mock_metric_source_urls):
""" Test that comment formatting function is the same as the text formatting one."""
mock_metric_source_urls.return_value = ['http://url1']
mock_metric_source = MagicMock()
mock_metric_source.metric_source_name = "Text"
project = MagicMock()
project.metric_sources.return_value = [mock_metric_source]
test_metric = domain.Metric(subject=MagicMock(), project=project)
self.assertEqual("Some text... [{'href': 'http://url1', 'text': 'Text'}]",
test_metric.format_text_with_links('Some text...'))
示例2: test_url_from_metric_source_urls
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import metric_source_name [as 别名]
def test_url_from_metric_source_urls(self):
""" Test metric url when there is no source id. """
mock_metric_source = MagicMock()
mock_metric_source.metric_source_urls.return_value = ['http://url!']
mock_metric_source.metric_source_name = "Text"
subject = MagicMock()
subject.metric_source_id.return_value = "MsId"
project = MagicMock()
project.metric_sources.return_value = [mock_metric_source]
test_metric = domain.Metric(subject=subject, project=project)
self.assertEqual({"Text": 'http://url!'}, test_metric.url())
示例3: test_url_two_sources
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import metric_source_name [as 别名]
def test_url_two_sources(self):
""" Test metric url when there are two metric source ids. """
mock_metric_source = MagicMock()
mock_metric_source.metric_source_urls.return_value = ['http:/url1', 'http:/url2']
mock_metric_source.metric_source_name = "Text"
subject = MagicMock()
subject.metric_source_id.return_value = "MsId"
project = MagicMock()
project.metric_sources.return_value = [mock_metric_source]
test_metric = domain.Metric(subject=subject, project=project)
self.assertEqual({"Text (1/2)": "http:/url1", "Text (2/2)": "http:/url2"}, test_metric.url())
示例4: test_url_metric_source_different_display_two_links
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import metric_source_name [as 别名]
def test_url_metric_source_different_display_two_links(self):
""" Test metric url when there are two links - one with a display link and the other without. """
mock_metric_source = MagicMock()
mock_metric_source.metric_source_urls.return_value = ["metric source url"]
mock_metric_source.metric_source_name = "Text"
subject = MagicMock()
subject.metric_source_id.return_value = [{"source": 'http:\\link', "display": 'http:\\display.url'}, "simple"]
project = MagicMock()
project.metric_sources.return_value = [mock_metric_source]
test_metric = domain.Metric(subject=subject, project=project)
self.assertEqual({"Text": "metric source url"}, test_metric.url())
mock_metric_source.metric_source_urls.assert_called_once_with('http:\\display.url', "simple")
示例5: test_url_metric_source_different_display
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import metric_source_name [as 别名]
def test_url_metric_source_different_display(self):
""" Test metric url when there is a display link. """
mock_metric_source = MagicMock()
mock_metric_source.metric_source_urls.return_value = ["metric source url"]
mock_metric_source.metric_source_name = "Text"
subject = MagicMock()
subject.metric_source_id.return_value = {"source": 'http:\\link', "display": 'http:\\display.url'}
project = MagicMock()
project.metric_sources.return_value = [mock_metric_source]
test_metric = domain.Metric(subject=subject, project=project)
self.assertEqual({"Text": "metric source url"}, test_metric.url())
mock_metric_source.metric_source_urls.assert_called_once_with('http:\\display.url')
示例6: test_url_metric_source_different_metric_source_urls
# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import metric_source_name [as 别名]
def test_url_metric_source_different_metric_source_urls(self):
""" Test metric url when there are metric source urls. """
mock_metric_source = MagicMock()
mock_metric_source.metric_source_urls.return_value = ["metric source url"]
mock_metric_source.metric_source_name = "Text"
subject = MagicMock()
subject.metric_source_id.return_value = "MsId"
project = MagicMock()
project.metric_sources.return_value = [mock_metric_source]
test_metric = domain.Metric(subject=subject, project=project)
self.assertEqual({"Text": "metric source url"}, test_metric.url())
mock_metric_source.metric_source_urls.assert_called_once_with('MsId')