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


Python minimock.assert_same_trace函数代码示例

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


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


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