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


Python segmentio.track_segmentio_event函数代码示例

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


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

示例1: post_segmentio_event

 def post_segmentio_event(self, **kwargs):
     """Post a fake segment.io event to the view that processes it"""
     request = self.create_request(
         data=self.create_segmentio_event_json(**kwargs),
         content_type='application/json'
     )
     segmentio.track_segmentio_event(request)
开发者ID:189140879,项目名称:edx-platform,代码行数:7,代码来源:test_segmentio.py

示例2: test_invalid_course_id

 def test_invalid_course_id(self):
     request = self.create_request(
         data=self.create_segmentio_event_json(course_id='invalid'),
         content_type='application/json'
     )
     segmentio.track_segmentio_event(request)
     self.assert_events_emitted()
开发者ID:cpennington,项目名称:edx-platform,代码行数:7,代码来源:test_segmentio.py

示例3: test_invalid_course_id

 def test_invalid_course_id(self):
     request = self.create_request(
         data=self.create_segmentio_event_json(course_id='invalid'),
         content_type='application/json'
     )
     User.objects.create(pk=USER_ID, username=str(sentinel.username))
     segmentio.track_segmentio_event(request)
     self.assert_events_emitted()
开发者ID:189140879,项目名称:edx-platform,代码行数:8,代码来源:test_segmentio.py

示例4: test_missing_received_at

    def test_missing_received_at(self):
        sample_event_raw = self.create_event_without_fields('receivedAt')
        request = self.create_request(
            data=json.dumps(sample_event_raw),
            content_type='application/json'
        )

        segmentio.track_segmentio_event(request)
开发者ID:cpennington,项目名称:edx-platform,代码行数:8,代码来源:test_segmentio.py

示例5: test_missing_received_at

    def test_missing_received_at(self):
        sample_event_raw = self.create_event_without_fields('receivedAt')
        request = self.create_request(
            data=json.dumps(sample_event_raw),
            content_type='application/json'
        )
        User.objects.create(pk=USER_ID, username=str(sentinel.username))

        segmentio.track_segmentio_event(request)
开发者ID:189140879,项目名称:edx-platform,代码行数:9,代码来源:test_segmentio.py

示例6: test_missing_timestamp

    def test_missing_timestamp(self):
        sample_event_raw = self.create_event_without_fields('timestamp')
        request = self.create_request(
            data=json.dumps(sample_event_raw),
            content_type='application/json'
        )
        User.objects.create(pk=SEGMENTIO_TEST_USER_ID, username=str(sentinel.username))

        segmentio.track_segmentio_event(request)
开发者ID:appsembler,项目名称:edx-platform,代码行数:9,代码来源:test_segmentio.py

示例7: test_missing_data

    def test_missing_data(self):
        sample_event_raw = self.create_segmentio_event()
        del sample_event_raw['properties']['data']
        request = self.create_request(
            data=json.dumps(sample_event_raw),
            content_type='application/json'
        )

        segmentio.track_segmentio_event(request)
开发者ID:cpennington,项目名称:edx-platform,代码行数:9,代码来源:test_segmentio.py

示例8: test_missing_data

    def test_missing_data(self):
        sample_event_raw = self.create_segmentio_event()
        del sample_event_raw['properties']['data']
        request = self.create_request(
            data=json.dumps(sample_event_raw),
            content_type='application/json'
        )
        User.objects.create(pk=USER_ID, username=str(sentinel.username))

        segmentio.track_segmentio_event(request)
开发者ID:189140879,项目名称:edx-platform,代码行数:10,代码来源:test_segmentio.py

示例9: test_segmentio_tracking_invalid_course_id

 def test_segmentio_tracking_invalid_course_id(self):
     request = self.create_request(
         data=self.create_segmentio_event_json(course_id='invalid'),
         content_type='application/json'
     )
     User.objects.create(pk=USER_ID, username=str(sentinel.username))
     response = segmentio.track_segmentio_event(request)
     self.assertEquals(response.status_code, 200)
     self.assertTrue(self.mock_tracker.send.called)  # pylint: disable=maybe-no-member
开发者ID:DevCode1,项目名称:edx-platform,代码行数:9,代码来源:test_segmentio.py

示例10: test_segmentio_tracking_missing_received_at

    def test_segmentio_tracking_missing_received_at(self):
        sample_event_raw = self.create_event_without_fields('receivedAt')
        request = self.create_request(
            data=json.dumps(sample_event_raw),
            content_type='application/json'
        )
        User.objects.create(pk=USER_ID, username=str(sentinel.username))

        response = segmentio.track_segmentio_event(request)
        self.assert_segmentio_uncommitted_response(response, segmentio.ERROR_MISSING_RECEIVED_AT, 400)
开发者ID:DevCode1,项目名称:edx-platform,代码行数:10,代码来源:test_segmentio.py

示例11: test_segmentio_tracking_missing_event_type

    def test_segmentio_tracking_missing_event_type(self):
        sample_event_raw = self.create_segmentio_event()
        sample_event_raw['properties'] = {}
        request = self.create_request(
            data=json.dumps(sample_event_raw),
            content_type='application/json'
        )
        User.objects.create(pk=USER_ID, username=str(sentinel.username))

        response = segmentio.track_segmentio_event(request)
        self.assert_segmentio_uncommitted_response(response, segmentio.ERROR_MISSING_EVENT_TYPE, 400)
开发者ID:DevCode1,项目名称:edx-platform,代码行数:11,代码来源:test_segmentio.py

示例12: test_success

    def test_success(self, course_id):
        middleware = TrackMiddleware()

        request = self.create_request(
            data=self.create_segmentio_event_json(event_type=str(sentinel.event_type), event={'foo': 'bar'}, course_id=course_id),
            content_type='application/json'
        )
        User.objects.create(pk=USER_ID, username=str(sentinel.username))

        middleware.process_request(request)
        # The middleware normally emits an event, make sure it doesn't in this case.
        self.assertFalse(self.mock_tracker.send.called)  # pylint: disable=maybe-no-member
        try:
            response = segmentio.track_segmentio_event(request)
            self.assertEquals(response.status_code, 200)

            expected_event = {
                'username': str(sentinel.username),
                'ip': '',
                'event_source': 'mobile',
                'event_type': str(sentinel.event_type),
                'name': str(sentinel.name),
                'event': {'foo': 'bar'},
                'agent': str(sentinel.user_agent),
                'page': None,
                'time': datetime.strptime("2014-08-27T16:33:39.215Z", "%Y-%m-%dT%H:%M:%S.%fZ"),
                'host': 'testserver',
                'context': {
                    'user_id': USER_ID,
                    'course_id': course_id,
                    'org_id': 'foo',
                    'path': ENDPOINT,
                    'client': {
                        'library': {
                            'name': 'unknown',
                            'version': 'unknown'
                        },
                        'userAgent': str(sentinel.user_agent)
                    },
                    'received_at': datetime.strptime("2014-08-27T16:33:39.100Z", "%Y-%m-%dT%H:%M:%S.%fZ"),
                },
            }
        finally:
            middleware.process_response(request, None)

        self.mock_tracker.send.assert_called_once_with(expected_event)  # pylint: disable=maybe-no-member
开发者ID:NATI-UNIFOR,项目名称:edx-platform,代码行数:46,代码来源:test_segmentio.py

示例13: test_segmentio_tracking_secret_mismatch

 def test_segmentio_tracking_secret_mismatch(self):
     request = self.create_request(key='y')
     response = segmentio.track_segmentio_event(request)
     self.assert_segmentio_uncommitted_response(response, segmentio.ERROR_UNAUTHORIZED, 401)
开发者ID:DevCode1,项目名称:edx-platform,代码行数:4,代码来源:test_segmentio.py

示例14: test_segmentio_tracking_no_secret_provided

 def test_segmentio_tracking_no_secret_provided(self):
     request = self.request_factory.post(ENDPOINT)
     response = segmentio.track_segmentio_event(request)
     self.assert_segmentio_uncommitted_response(response, segmentio.ERROR_UNAUTHORIZED, 401)
开发者ID:DevCode1,项目名称:edx-platform,代码行数:4,代码来源:test_segmentio.py

示例15: test_segmentio_tracking_get_request

 def test_segmentio_tracking_get_request(self):
     request = self.request_factory.get(ENDPOINT)
     response = segmentio.track_segmentio_event(request)
     self.assertEquals(response.status_code, 405)
     self.assertFalse(self.mock_tracker.send.called)  # pylint: disable=maybe-no-member
开发者ID:DevCode1,项目名称:edx-platform,代码行数:5,代码来源:test_segmentio.py


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