Example #1
0
def test_guess_mime_guessed():
    mocker = Mox()

    old_guess_type = multipart.guess_type
    multipart.guess_type = mocker.CreateMockAnything()
    multipart.guess_type('should-be-a-path').AndReturn(('some-mimetype', None))

    mocker.ReplayAll()
    try:
        assert_equals(multipart.guess_mime('should-be-a-path'), 'some-mimetype')
        mocker.VerifyAll()
    finally:
        multipart.guess_type = old_guess_type
Example #2
0
def test_guess_mime_fallsback_to_octet_stream():
    mocker = Mox()

    old_guess_type = multipart.guess_type
    multipart.guess_type = mocker.CreateMockAnything()
    multipart.guess_type('should-be-a-path').AndReturn((None, None))

    mocker.ReplayAll()
    try:
        assert_equals(multipart.guess_mime('should-be-a-path'),
                      'application/octet-stream')
        mocker.VerifyAll()
    finally:
        multipart.guess_type = old_guess_type