コード例 #1
0
 def test_report(self):
     mr = MockRequestable()
     (response,) = report('UA-123456-78', 'CID', mr)
     data = response.json()
     self.assertEqual(data['cid'], ['CID'])
     self.assertEqual(data['tid'], ['UA-123456-78'])
     self.assertEqual(data['t'], ['mock'])
コード例 #2
0
ファイル: tests.py プロジェクト: brianb1/FlashlightO
 def test_report(self):
     mr = MockRequestable()
     (response, ) = report('UA-123456-78', 'CID', mr)
     data = response.json()
     self.assertEqual(data['cid'], ['CID'])
     self.assertEqual(data['tid'], ['UA-123456-78'])
     self.assertEqual(data['t'], ['mock'])
コード例 #3
0
ファイル: tests.py プロジェクト: brianb1/FlashlightO
 def test_extra_info(self):
     empty_info = SystemInfo()
     self.assertEqual(empty_info.get_payload(), {})
     mr = MockRequestable()
     info = SystemInfo(language='en-gb')
     (response, ) = report('UA-123456-78', 'CID', mr, extra_info=info)
     data = response.json()
     self.assertEqual(data['ul'], ['en-gb'])
コード例 #4
0
 def test_extra_info(self):
     empty_info = SystemInfo()
     self.assertEqual(empty_info.get_payload(), {})
     mr = MockRequestable()
     info = SystemInfo(language='en-gb')
     (response,) = report('UA-123456-78', 'CID', mr, extra_info=info)
     data = response.json()
     self.assertEqual(data['ul'], ['en-gb'])
コード例 #5
0
ファイル: test_report.py プロジェクト: RadekD/gmp
def test_report():
    (response, ) = report('UA-123456-78', 'CID', [{'t': 'mock'}])
    data = response.json()
    assert data == {
        'cid': ['CID'],
        'tid': ['UA-123456-78'],
        'v': ['1'],
        'aip': ['1'],
        't': ['mock']
    }
コード例 #6
0
ファイル: tests.py プロジェクト: garetht/httmock
    def test_python_version_encoding_differences(self):
        # Previous behavior would result in this test failing in Python3 due
        # to how requests checks for utf-8 JSON content in requests.utils with:
        #
        # TypeError: Can't convert 'bytes' object to str implicitly
        @all_requests
        def get_mock(url, request):
            return {'content': self.content,
                    'headers': {'content-type': 'application/json'},
                    'status_code': 200,
                    'elapsed': 5}

        with HTTMock(get_mock):
            response = requests.get('http://foo_bar')
            self.assertEqual(self.content, response.json())
コード例 #7
0
    def test_python_version_encoding_differences(self):
        # Previous behavior would result in this test failing in Python3 due
        # to how requests checks for utf-8 JSON content in requests.utils with:
        #
        # TypeError: Can't convert 'bytes' object to str implicitly
        @all_requests
        def get_mock(url, request):
            return {'content': self.content,
                    'headers': {'content-type': 'application/json'},
                    'status_code': 200,
                    'elapsed': 5}

        with HTTMock(get_mock):
            response = requests.get('http://example.com/')
            self.assertEqual(self.content, response.json())
コード例 #8
0
def test_create_jira():
    with HTTMock(response_content):
        mock_story = MagicMock(spec=dict)
        response = create_jira_issue(mock_story)
        assert response.json().get('some') == 'data'
コード例 #9
0
def test_create_jira():
    with HTTMock(response_content):
        mock_story = MagicMock(spec=dict)
        response = create_jira_issue(mock_story)
        assert response.json().get('some') == 'data'
コード例 #10
0
ファイル: test_report.py プロジェクト: RadekD/gmp
def test_extra_params():
    (response, ) = report('UA-123456-78', 'CID', [{'t': 'mock'}], ex='extra')
    data = response.json()
    assert data['ex'] == ['extra']