• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python minimock.assert_same_trace函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中minimock.assert_same_trace函数的典型用法代码示例。如果您正苦于以下问题:Python assert_same_trace函数的具体用法?Python assert_same_trace怎么用?Python assert_same_trace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_run_analyse_custom_regulator

    def test_run_analyse_custom_regulator(self):
        '''Test run_analyze() with a custom regulator'''
        session_store = webdorina.SESSION_STORE.format(unique_id='fake-uuid')
        expected_trace = '''Called run.analyse(
    datadir='/fake/data/dir',
    genome='hg19',
    match_a='any',
    region_a='any',
    set_a=['scifi', '{session_store}/fake-uuid.bed'],
    set_b=None)'''.format(session_store=session_store)

        query = dict(genome='hg19', set_a=['scifi', 'fake-uuid'], match_a='any',
                     region_a='any', set_b=None)

        self.return_value = """chr1	doRiNA2	gene	1	1000	.	+	.	ID=gene01.01	chr1	250	260	PARCLIP#scifi*scifi_cds	5	+
chr1	doRiNA2	gene	2001	3000	.	+	.	ID=gene01.02	chr1	2350	2360	PARCLIP#scifi*scifi_intron	6	+"""

        run.run_analyse('/fake/data/dir', 'results:fake_key', 'results:fake_key_pending', query, 'fake-uuid')
        expected = self.return_value.split('\n')
        expected.sort(key=lambda x: float(x.split('\t')[13]), reverse=True)

        assert_same_trace(self.tt, expected_trace)

        self.assertTrue(self.r.exists('results:fake_key'))
        self.assertEqual(2, self.r.llen('results:fake_key'))
        self.assertEqual(expected, self.r.lrange('results:fake_key', 0, -1))

        self.assertTrue(self.r.exists('sessions:fake-uuid'))
        self.assertEqual(json.loads(self.r.get('sessions:fake-uuid')), dict(uuid='fake-uuid', state='done'))

        self.assertTrue(self.r.exists('results:sessions:fake-uuid'))
        self.assertEqual(json.loads(self.r.get('results:sessions:fake-uuid')), dict(redirect="results:fake_key"))
开发者ID:BIMSBbioinfo,项目名称:webdorina,代码行数:32,代码来源:test_dorina.py


示例2: test_unknown_error

 def test_unknown_error(self):
     # mock urlfetch
     response = Response(500)
     trace = TraceTracker()
     boxcargae.urlfetch = Mock("boxcargae.urlfetch")
     boxcargae.urlfetch.fetch = Mock("fetch", returns=response, tracker=trace)
     # unknown error(500)
     self.assertRaises(
         boxcargae.BoxcarException,
         self.boxcar.notify,
         "[email protected]",
         "test_error",
         "unknown error",
         message_id=500,
     )
     assert_same_trace(
         trace,
         "Called fetch(\n"
         "    'http://boxcar.io/devices/providers/xxxxxxxxxxxxxxxxxxxx/notifications',\n"
         "    headers={'User-Agent': 'Boxcar_Client'},\n"
         "    method='POST',\n"
         "    payload='notification%5Bfrom_remote_service_id%5D=500&"
         "notification%5Bicon_url%5D=xxxxxxxxx%40xxxxx.xxx&"
         "secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&"
         "token=xxxxxxxxxxxxxxxxxxxx&"
         "notification%5Bmessage%5D=unknown+error&"
         "email=fd2504c1a700746932666efec57e4b92&"
         "notification%5Bfrom_screen_name%5D=test_error')\n",
     )
开发者ID:morinatsu,项目名称:Boxcar-GAE-Python-Provider,代码行数:29,代码来源:test.py


示例3: test_set_password

    def test_set_password(self, mock_set_password):
        """Set password with `from` address as login."""
        tracker = mock_set_password

        email_from = '[email protected]'
        smtp_server = 'smtp.gmail.com'

        # argument to set_password
        email_config = {
            'enabled': True,
            'from': email_from,
            'to': '[email protected]',
            'subject': 'updatewatch',
            'smtp': {
                'host': smtp_server,
                'port': 587
            }
        }

        # expected trace from minimock
        want = dedent("""\
            Called getpass.getpass(
                prompt="Enter password for '{email_from}' using '{smtp_server}': ")
            Called keyring.set_password(
                '{smtp_server}',
                '{email_from}',
                'set_password_secret')""".format(
                    email_from=email_from, smtp_server=smtp_server))

        # set password with mockups
        mailer.set_password(email_config)

        # assert trace of all calls to smtplib are as expected
        minimock.assert_same_trace(tracker, want)
开发者ID:brbsix,项目名称:updatewatch,代码行数:34,代码来源:test_mailer.py


示例4: test_set_password_with_login

    def test_set_password_with_login(self, mock_set_password):
        """Set password with login account that differs from `from` address."""
        tracker = mock_set_password

        login = '[email protected]'
        smtp_server = 'smtp.gmail.com'

        # argument to set_password
        email_config = {
            'enabled': True,
            'from': '[email protected]',
            'to': '[email protected]',
            'subject': 'updatewatch',
            'smtp': {
                'login': login,
                'host': smtp_server,
                'port': 587
            }
        }

        # expected trace from minimock
        want = dedent("""\
            Called getpass.getpass(
                prompt="Enter password for '{login}' using '{smtp_server}': ")
            Called keyring.set_password(
                '{smtp_server}',
                '{login}',
                'set_password_secret')""".format(
                    login=login, smtp_server=smtp_server))

        # set password with mockups
        mailer.set_password(email_config)

        # assert trace of all calls to smtplib are as expected
        minimock.assert_same_trace(tracker, want)
开发者ID:brbsix,项目名称:updatewatch,代码行数:35,代码来源:test_mailer.py


示例5: test_get_sensor

    def test_get_sensor(self):
        "Test get_sensor()"
        temp_alert = TempAlert()

        # Everything is fine
        mock("temp_alert.get_data",
             returns={u'temp':23.45, u'alarm': False, u'panic': False},
             tracker=self.tt)
        sensor = temp_alert.get_sensor('foo')
        self.assertAlmostEqual(23.45, sensor['temp'])
        self.assertFalse(sensor['alarm'])
        self.assertFalse(sensor['panic'])

        # Alarm state
        mock("temp_alert.get_data",
             returns={u'temp':23.45, u'alarm': True, u'panic': False},
             tracker=self.tt)
        sensor = temp_alert.get_sensor('foo')
        self.assertAlmostEqual(23.45, sensor['temp'])
        self.assertTrue(sensor['alarm'])
        self.assertFalse(sensor['panic'])

        # Panic state
        mock("temp_alert.get_data",
             returns={u'temp':23.45, u'alarm': True, u'panic': True},
             tracker=self.tt)
        sensor = temp_alert.get_sensor('foo')
        self.assertAlmostEqual(23.45, sensor['temp'])
        self.assertTrue(sensor['alarm'])
        self.assertTrue(sensor['panic'])

        expected = "Called temp_alert.get_data('foo')\n" * 3
        assert_same_trace(self.tt, expected)
开发者ID:kblin,项目名称:temp-alert,代码行数:33,代码来源:test_temp_alert.py


示例6: test_shard_find_one

 def test_shard_find_one(self):
     object_id = ObjectId()
     MongoResource.find_one(object_id)
     minimock.assert_same_trace(self.tt, '\n'.join([
         "Called Collection.find_one(",
         "    {'_id': ObjectId('...'), 'shard': '...'})"
     ]))
开发者ID:gilles,项目名称:mongothin,代码行数:7,代码来源:test_resource.py


示例7: test_users_from_url

    def test_users_from_url(self):
        mock('obswatch.http_GET', tracker=self.tt,
             returns=StringIO('''<?xml version="1.0" encoding="UTF-8"?>
           <project name="superkde" created="2005-01-01T00:00:02+01:00" updated="2007-01-19T10:44:45+01:00">
             <title>SuperKDE</title>
             <description>SuperKDE is a heavily tuned version of KDE.</description>
             <link project="openSUSE:11.2:Update" />
             <link project="openSUSE:11.2" />
             <person role="maintainer" userid="Geeko"/>
             <person role="maintainer" userid="BrownGeeko"/>
             <group  role="reviewer"  groupid="release_team"/>
             <build>
               <disable />
             </build>
             <repository name="kde4:factory" rebuild="transitive">
               <path project="kde4" repository="factory"/>
               <arch>i386</arch>

               <arch>x86_64</arch>
             </repository>
           </project>'''))
        mock('obswatch.get_user_email', returns='[email protected]')

        result = obswatch.get_users_from_url('%ssource/superkde/_meta' %
                                            obswatch.APIURL)
        assert_same_trace(self.tt, """Called obswatch.http_GET(
            '%ssource/superkde/_meta')""" % obswatch.APIURL)
        self.assertEqual(len(result), 2)
        self.assertEqual(result['Geeko'], '[email protected]')
        self.assertEqual(result['BrownGeeko'], '[email protected]')        
开发者ID:mapleoin,项目名称:obswatch,代码行数:30,代码来源:tests.py


示例8: test_init_exists

    def test_init_exists(self):
        """DictDB inits reading a previously existing file"""

        json.load.mock_returns = {}

        assert DictDB(self.file.name) == {}
        assert_same_trace(self.trace, "Called json.load(<open file '%s', mode 'r' at 0x...>)" % self.file.name)
开发者ID:faulkner,项目名称:pif,代码行数:7,代码来源:tests.py


示例9: test_unknown_error

    def test_unknown_error(self):
        # mock urlfetch
        response = Response(500) 
        trace = TraceTracker()
        boxcar.fetch = Mock('fetch',
                                returns=response, 
                                tracker=trace)
        # unknown error(500)
        self.assertRaises(boxcar.BoxcarException, 
                          self.boxcar.notify, '[email protected]',
                                              'test_error',
                                              'unknown error',
                                              message_id=500)
        assert_same_trace(trace,
            "Called fetch(\n"
            "    'http://boxcar.io/devices/providers/xxxxxxxxxxxxxxxxxxxx/notifications',\n"
            "    headers={'User-Agent': 'Boxcar_Client'},\n"

            "    payload='"
                         "email=yyyyyyyy%40yyyyy.yyy&"
                         "notification%5Bfrom_remote_service_id%5D=500&"
                         "notification%5Bfrom_screen_name%5D=test_error&"
                         "notification%5Bicon_url%5D=xxxxxxxxx%40xxxxx.xxx&"
                         "notification%5Bmessage%5D=unknown+error&"
                         "secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&"
                         "token=xxxxxxxxxxxxxxxxxxxx"
                         "')\n")
开发者ID:jondb,项目名称:Boxcar-Python-Provider,代码行数:27,代码来源:test.py


示例10: test_notify

    def test_notify(self):
        # mock urlfetch
        trace = TraceTracker()
        response = Response(200) 
        boxcar.fetch = Mock('fetch',
                                returns=response, 
                                tracker=trace)
        # send a notification
        self.boxcar.notify('[email protected]',
                           'test_normal',
                           'notification message',
                            message_id=200)
        assert_same_trace(trace,
            "Called fetch(\n"
            "    'http://boxcar.io/devices/providers/xxxxxxxxxxxxxxxxxxxx/notifications',\n"
            "    headers={'User-Agent': 'Boxcar_Client'},\n"

            "    payload='"
                         "email=yyyyyyyy%40yyyyy.yyy&"
                         "notification%5Bfrom_remote_service_id%5D=200&"
                         "notification%5Bfrom_screen_name%5D=test_normal&"
                         "notification%5Bicon_url%5D=xxxxxxxxx%40xxxxx.xxx&"
                         "notification%5Bmessage%5D=notification+message&"
                         "secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&"
                         "token=xxxxxxxxxxxxxxxxxxxx"
                         "')\n")
开发者ID:jondb,项目名称:Boxcar-Python-Provider,代码行数:26,代码来源:test.py


示例11: test_search_query_pending

    def test_search_query_pending(self):
        '''Test search() with a query for this key pending'''
        self.r.set('sessions:fake-uuid', json.dumps(dict(uuid='fake-uuid', state='done')))
        key = 'results:{"combine": "or", "genes": ["all"], "genome": "hg19", '
        key += '"match_a": "any", "match_b": "any", "region_a": "any", '
        key += '"region_b": "any", "set_a": ["scifi"], "set_b": null}'
        key_pending = '{0}_pending'.format(key)
        self.r.set(key_pending, True)

        data = dict(match_a='any', assembly='hg19', uuid='fake-uuid')
        data['set_a[]']=['scifi']
        rv = self.client.post('/api/v1.0/search', data=data)

        # Should return "pending"
        self.assertEqual(rv.json, dict(uuid='fake-uuid', state="pending"))

        # This query should trigger a defined set of calls
        expected_trace = '''Called fake_store.exists('sessions:fake-uuid')
Called fake_store.exists(
    '{0}')
Called fake_store.set(
    'sessions:fake-uuid',
    '{{"state": "pending", "uuid": "fake-uuid"}}')
Called fake_store.expire('sessions:fake-uuid', {2})
Called fake_store.get(
    '{1}')'''.format(key, key_pending, webdorina.SESSION_TTL)
        assert_same_trace(self.tt, expected_trace)
开发者ID:BIMSBbioinfo,项目名称:webdorina,代码行数:27,代码来源:test_dorina.py


示例12: test_post_put_hook_sends_log_line_to_channel

 def test_post_put_hook_sends_log_line_to_channel(self):
     tracker = minimock.TraceTracker()
     minimock.mock('channel.ServerChannels.get_client_ids', returns=['client_id'], tracker=None)
     minimock.mock('channel.ServerChannels.send_message', tracker=tracker)
     log_line = models.LogLine.create(self.server, LOG_LINE, TIME_ZONE)
     minimock.assert_same_trace(
         tracker, """Called channel.ServerChannels.send_message({0}, u'chat')""".format(log_line)
     )
开发者ID:RubyCoin,项目名称:mc-coal,代码行数:8,代码来源:test_models.py


示例13: test_get_available_sensors

    def test_get_available_sensors(self):
        "Test get_available_sensors()"
        temp_alert = TempAlert()
        mock("temp_alert.get_data", returns={u'sensors': [u'first', u'second']},
             tracker=self.tt)
        self.assertEqual(['first', 'second'], temp_alert.get_available_sensors())

        expected = "Called temp_alert.get_data('available')"
        assert_same_trace(self.tt, expected)
开发者ID:kblin,项目名称:temp-alert,代码行数:9,代码来源:test_temp_alert.py


示例14: test_context_should_increment_failed_and_raise

    def test_context_should_increment_failed_and_raise(self):
        def foo():
            with counter.counter('countername'):
                raise Exception

        self.assertRaises(Exception, foo)
        minimock.assert_same_trace(self.tt, '\n'.join([
            "Called counter.increment('countername_failed')"
        ]))
开发者ID:gilles,项目名称:gilles-fresh,代码行数:9,代码来源:counters.py


示例15: test_decorator_should_increment_failed_and_raise

    def test_decorator_should_increment_failed_and_raise(self):
        @counter.counted('countername')
        def foo():
            raise Exception('argh')

        self.assertRaises(Exception, foo)

        minimock.assert_same_trace(self.tt, '\n'.join([
            "Called counter.increment('countername_failed')"
        ]))
开发者ID:gilles,项目名称:gilles-fresh,代码行数:10,代码来源:counters.py


示例16: test_decorator_should_increment

    def test_decorator_should_increment(self):
        @counter.counted('countername')
        def foo():
            pass

        foo()

        minimock.assert_same_trace(self.tt, '\n'.join([
            "Called counter.increment('countername')"
        ]))
开发者ID:gilles,项目名称:gilles-fresh,代码行数:10,代码来源:counters.py


示例17: test_get_data

    def test_get_data(self):
        "Test get_data()"
        temp_alert = TempAlert()
        mock("orig_ta.urlopen", returns=StringIO('{"test": "passed"}'),
             tracker=self.tt)

        self.assertEqual({'test': 'passed'}, temp_alert.get_data('test'))

        expected = "Called orig_ta.urlopen('http://localhost:8367/test')"
        assert_same_trace(self.tt, expected)
开发者ID:kblin,项目名称:temp-alert,代码行数:10,代码来源:test_temp_alert.py


示例18: likes_test

    def likes_test(self):
        self.client.likes()
        assert_same_trace(self.trackar, """\
            Called pyblr.Pyblr.get('/v2/user/likes', %s)
        """ % ({}))

        self.trackar.clear()
        self.client.likes({"limit": 10})
        assert_same_trace(self.trackar, """\
            Called pyblr.Pyblr.get('/v2/user/likes', %s)
        """ % ({"limit": 10}))
开发者ID:GunioRobot,项目名称:python-tumblr-v2,代码行数:11,代码来源:test_pyblr.py


示例19: test_search_cached_results

    def test_search_cached_results(self):
        '''Test search() with cached_results'''
        key = 'results:{"combine": "or", "genes": ["all"], "genome": "hg19", '
        key += '"match_a": "any", "match_b": "any", "region_a": "any", '
        key += '"region_b": "any", "set_a": ["scifi"], "set_b": null}'
        results = [
        'chr1	doRiNA2	gene	1	1000	.	+	.	ID=gene01.01	chr1	250	260	PARCLIP#scifi*scifi_cds	6	+	250	260',
        'chr1	doRiNA2	gene	2001	3000	.	+	.	ID=gene01.02	chr1	2350	2360	PARCLIP#scifi*scifi_intron	5	+	2350	2360',
        'chr1	doRiNA2	gene	3001	4000	.	+	.	ID=gene01.03	chr1	3350	3360	PARCLIP#scifi*scifi_intron	7	+	3350	3360'
        ]
        for res in results:
            self.r.rpush(key, res)

        self.r.set('sessions:fake-uuid', json.dumps(dict(uuid='fake-uuid', state='done')))

        data = dict(match_a='any', assembly='hg19', uuid='fake-uuid')
        data['set_a[]']=['scifi']
        rv = self.client.post('/api/v1.0/search', data=data)

        self.assertEqual(rv.json, dict(state='done', uuid="fake-uuid"))

        rv = self.client.get('/api/v1.0/result/fake-uuid')
        expected = dict(state='done', results=results, more_results=False, next_offset=100, total_results=3)
        self.assertEqual(rv.json, expected)

        # This query should trigger a defined set of calls
        expected_trace = '''Called fake_store.exists('sessions:fake-uuid')
Called fake_store.exists(
    '{0}')
Called fake_store.expire(
    '{0}',
    {1})
Called fake_store.set(
    'sessions:{3}',
    '{{"state": "done", "uuid": "{3}"}}')
Called fake_store.expire('sessions:{3}', {4})
Called fake_store.set(
    'results:sessions:{3}',
    {5!r})
Called fake_store.expire('results:sessions:{3}', {4})
Called fake_store.exists('results:sessions:{3}')
Called fake_store.get('results:sessions:{3}')
Called fake_store.expire(
    '{0}',
    {1})
Called fake_store.lrange(
    '{0}',
    0,
    {2})
Called fake_store.llen(
    '{0}')
    '''.format(key, webdorina.RESULT_TTL, webdorina.MAX_RESULTS - 1,
               'fake-uuid', webdorina.SESSION_TTL, json.dumps(dict(redirect=key)))
        assert_same_trace(self.tt, expected_trace)
开发者ID:BIMSBbioinfo,项目名称:webdorina,代码行数:54,代码来源:test_dorina.py


示例20: followers_test

    def followers_test(self):
        self.client.followers("toqoz.tumblr.com")
        assert_same_trace(self.trackar, """\
            Called pyblr.Pyblr.get('/v2/blog/toqoz.tumblr.com/followers', %s)
        """ % ({}))

        self.trackar.clear()
        self.client.followers("toqoz.tumblr.com", {"limit": 10})
        assert_same_trace(self.trackar, """\
            Called pyblr.Pyblr.get('/v2/blog/toqoz.tumblr.com/followers', %s)
        """ % ({'limit': 10}))
开发者ID:GunioRobot,项目名称:python-tumblr-v2,代码行数:11,代码来源:test_pyblr.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python minimock.mock函数代码示例发布时间:2022-05-27
下一篇:
Python minimize.minimize函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap