def test_logs_are_chunked(self, mock_post):
        post_output_log(MOCK_LOG_URL, 'test', 'abcdefg', chunk_size=2)

        assert mock_post.call_count == 4

        mock_post.assert_any_call(MOCK_LOG_URL,
                                  json={
                                      'source': 'test',
                                      'output': b64string('ab')
                                  })
        mock_post.assert_any_call(MOCK_LOG_URL,
                                  json={
                                      'source': 'test',
                                      'output': b64string('cd')
                                  })
        mock_post.assert_any_call(MOCK_LOG_URL,
                                  json={
                                      'source': 'test',
                                      'output': b64string('ef')
                                  })
        mock_post.assert_any_call(MOCK_LOG_URL,
                                  json={
                                      'source': 'test',
                                      'output': b64string('g')
                                  })
 def test_it_works(self, mock_post):
     post_output_log(MOCK_LOG_URL, 'test', 'test output')
     mock_post.assert_called_once_with(MOCK_LOG_URL,
                                       json={
                                           'source': 'test',
                                           'output':
                                           b64string('test output'),
                                       })
    def test_it_works(self, mock_del, mock_post):
        post_build_error(MOCK_LOG_URL, MOCK_STATUS_URL, MOCK_BUILDER_URL,
                         'error message')

        assert mock_post.call_count == 2
        mock_post.assert_any_call(MOCK_LOG_URL,
                                  json={
                                      'source': 'ERROR',
                                      'output': b64string('error message')
                                  })

        mock_post.assert_any_call(MOCK_STATUS_URL,
                                  json={
                                      'status': 1,
                                      'message': b64string('error message')
                                  })

        mock_del.assert_called_once_with(MOCK_BUILDER_URL)
    def test_it_works(self, mock_del, mock_post):
        post_build_error(MOCK_STATUS_URL, 'error msg')

        assert mock_post.call_count == 1

        mock_post.assert_any_call(MOCK_STATUS_URL,
                                  json={
                                      'status': STATUS_ERROR,
                                      'message': b64string('error msg')
                                  })
    def test_it_works(self, mock_del, mock_post):
        commit_sha = 'testSha2'
        post_build_error(MOCK_STATUS_URL, 'error msg', commit_sha)

        assert mock_post.call_count == 1

        mock_post.assert_any_call(MOCK_STATUS_URL,
                                  json={
                                      'status': STATUS_ERROR,
                                      'message': b64string('error msg'),
                                      'commit_sha': commit_sha
                                  })
    def test_it_works(self, mock_del, mock_post):
        post_build_timeout(MOCK_STATUS_URL)

        expected_output = b64string(
            'The build did not complete. It may have timed out.')

        assert mock_post.call_count == 1
        mock_post.assert_any_call(MOCK_STATUS_URL,
                                  json={
                                      'status': STATUS_ERROR,
                                      'message': expected_output
                                  })
    def test_it_works(self, mock_del, mock_post):
        post_build_timeout(MOCK_LOG_URL, MOCK_STATUS_URL, MOCK_BUILDER_URL)

        expected_output = b64string(
            'The build did not complete. It may have timed out.')

        assert mock_post.call_count == 2
        mock_post.assert_any_call(MOCK_LOG_URL,
                                  json={
                                      'source': 'ERROR',
                                      'output': expected_output
                                  })

        mock_post.assert_any_call(MOCK_STATUS_URL,
                                  json={
                                      'status': 1,
                                      'message': expected_output
                                  })

        mock_del.assert_called_once_with(MOCK_BUILDER_URL)