import unittest
try:
    from unittest import mock
except ImportError:
    import mock
from binstar_client import errors
from conda_env.utils.uploader import Uploader


class UploaderTestCase(unittest.TestCase):
    def test_unauthorized(self):
        uploader = Uploader('package', 'filename')
        with mock.patch.object(uploader.binstar, 'user') as get_user_mock:
            get_user_mock.side_effect = errors.Unauthorized
            self.assertEqual(uploader.authorized(), False)

    def test_authorized(self):
        uploader = Uploader('package', 'filename')
        with mock.patch.object(uploader.binstar, 'user') as get_user_mock:
            get_user_mock.user.return_value = {}
            self.assertEqual(uploader.authorized(), True)

@@ -671,13 +671,8 @@
 ock.
-user.
 retu
@@ -743,8 +743,445 @@
 , True)%0A
+%0A    def test_package_already_exist(self):%0A        uploader = Uploader('package', 'filename')%0A        with mock.patch.object(uploader.binstar, 'user') as user_mock:%0A            user_mock.return_value = %7B'login': 'user'%7D%0A            with mock.patch.object(uploader.binstar, 'distribution') as distribution_mock:%0A                distribution_mock.return_value = True%0A                self.assertEqual(uploader.ensure_distribution(), False)%0A

Add uploder tests