Example #1
0
 def test_duplicate_user_creation_raises_conflict(self):
     with vcr.use_cassette('fixtures/vcr_cassettes/duplicate_user.json',
                           filter_post_data_parameters=['password']):
         with self.assertRaises(errors.ConflictError):
             Client.create_user(name=self.username,
                                email=self.email,
                                password=self.password)
Example #2
0
    def test_new_user_could_be_deleted_instanly(self):
        fake_email = '*****@*****.**'
        fake_password = '******'

        with vcr.use_cassette(
                'fixtures/vcr_cassettes/create_fake_user_to_destroy.json',
                before_record_response=scrub_string(fake_password),
                filter_post_data_parameters=['password', 'j_password']):
            user = Client.create_user(name='fake',
                                      email=fake_email,
                                      password=fake_password)

        with vcr.use_cassette(
                'fixtures/vcr_cassettes/user_destroy_valid.json',
                before_record_response=scrub_string(fake_password),
                filter_post_data_parameters=['password'],
        ):
            user.destroy()

        with vcr.use_cassette(
                'fixtures/vcr_cassettes/invalid_login_after_destroy.json',
                filter_post_data_parameters=['password', 'j_password'],
        ):
            with self.assertRaises(errors.UnauthorizedError):
                Client(email=fake_email, password=fake_password)
Example #3
0
 def get_session(self):
     """
     Returns a cached authenticated session.
     """
     with test_helper.vcr.use_cassette(
         'fixtures/vcr_cassettes/valid_login.json',
         filter_post_data_parameters=['j_password']
     ):
         session = Client(email=self.email, password=self.password)
     return session
Example #4
0
 def test_valid_user_creation_returns_user_intance(self):
     with vcr.use_cassette(
             'fixtures/vcr_cassettes/valid_create_user.json',
             before_record_response=scrub_string(self.password),
             filter_post_data_parameters=['password', 'j_password'],
             record_mode='new_episodes'):
         user = Client.create_user(name=self.username,
                                   email=self.email,
                                   password=self.password)
         self.assertIsInstance(user, User)
Example #5
0
    def test_task_could_be_approved_by_user(self):
        old_member = self.get_me()
        with vcr.use_cassette(
                'fixtures/vcr_cassettes/task_create_for_sharing.json'):
            task = Task.create(user=old_member,
                               title='Shared Task',
                               category='Personal',
                               priority='Normal',
                               status='UNCHECKED')

        fake_email = '*****@*****.**'
        fake_password = '******'
        with vcr.use_cassette(
                'fixtures/vcr_cassettes/task_create_user_for_sharing_and_approve.json',
                before_record_response=scrub_string(fake_password),
                filter_post_data_parameters=['password', 'j_password']):
            new_member = Client.create_user(name='fake',
                                            email=fake_email,
                                            password=fake_password)

        with vcr.use_cassette(
                'fixtures/vcr_cassettes/task_share_with_user_to_approve.json'):
            task.share_with(new_member)

        with vcr.use_cassette(
                'fixtures/vcr_cassettes/task_user_pending_tasks_before_approve.json'
        ):
            self.assertTrue(
                len(new_member.pending_tasks_ids(refresh=True)) == 1)

        with vcr.use_cassette(
                'fixtures/vcr_cassettes/task_user_approve_pending_task.json'):
            new_member.approve_pending_task(
                pending_task_id=new_member.pending_tasks_ids()[0])

        with vcr.use_cassette(
                'fixtures/vcr_cassettes/task_user_pending_tasks_after_approve.json'
        ):
            self.assertTrue(
                len(new_member.pending_tasks_ids(refresh=True)) == 0)

        with vcr.use_cassette(
                'fixtures/vcr_cassettes/task_members_after_refresh.json'):
            task.refresh()

            self.assertEqual([{
                old_member['email']: old_member['name']
            }, {
                new_member['email']: new_member['name']
            }], task.members())

        with vcr.use_cassette(
                'fixtures/vcr_cassettes/tasks_of_new_member.json'):
            shared_task = new_member.tasks(refresh=True)[0]
            self.assertEqual(task['title'], shared_task['title'])
Example #6
0
    def test_user_knows_about_its_pending_tasks(self):
        task = self.__get_task()

        fake_email = '*****@*****.**'
        fake_password = '******'
        with vcr.use_cassette('fixtures/vcr_cassettes/task_create_user_for_share.json',
            before_record_response=scrub_string(fake_password),
            filter_post_data_parameters=['password', 'j_password']
        ):
            new_member = Client.create_user(name='fake', email=fake_email, password=fake_password)


        with vcr.use_cassette('fixtures/vcr_cassettes/task_share_with_user.json'):
            task.share_with(new_member)

        with vcr.use_cassette('fixtures/vcr_cassettes/task_user_pending_tasks.json'):
            self.assertTrue(len(new_member.pending_tasks_ids()) == 1)
            self.assertEqual(task['title'], new_member.pending_tasks()[0]['title'])
Example #7
0
    def test_task_could_be_approved_by_user(self):
        old_member = self.get_me()
        with vcr.use_cassette('fixtures/vcr_cassettes/task_create_for_sharing.json'):
            task = Task.create(user=old_member,
                title='Shared Task',
                category='Personal',
                priority='Normal',
                status='UNCHECKED'
            )

        fake_email = '*****@*****.**'
        fake_password = '******'
        with vcr.use_cassette('fixtures/vcr_cassettes/task_create_user_for_sharing_and_approve.json',
            before_record_response=scrub_string(fake_password),
            filter_post_data_parameters=['password', 'j_password']
        ):
            new_member = Client.create_user(name='fake', email=fake_email, password=fake_password)

        with vcr.use_cassette('fixtures/vcr_cassettes/task_share_with_user_to_approve.json'):
            task.share_with(new_member)

        with vcr.use_cassette('fixtures/vcr_cassettes/task_user_pending_tasks_before_approve.json'):
            self.assertTrue(len(new_member.pending_tasks_ids(refresh=True)) == 1)

        with vcr.use_cassette('fixtures/vcr_cassettes/task_user_approve_pending_task.json'):
            new_member.approve_pending_task(pending_task_id=new_member.pending_tasks_ids()[0])

        with vcr.use_cassette('fixtures/vcr_cassettes/task_user_pending_tasks_after_approve.json'):
            self.assertTrue(len(new_member.pending_tasks_ids(refresh=True)) == 0)

        with vcr.use_cassette('fixtures/vcr_cassettes/task_members_after_refresh.json'):
            task.refresh()

            self.assertEqual([
                { old_member['email']: old_member['name'] },
                { new_member['email']: new_member['name'] }],
                task.members()
            )

        with vcr.use_cassette('fixtures/vcr_cassettes/tasks_of_new_member.json'):
            shared_task = new_member.tasks(refresh=True)[0]
            self.assertEqual(task['title'], shared_task['title'])
Example #8
0
    def test_user_knows_about_its_pending_tasks(self):
        task = self.__get_task()

        fake_email = '*****@*****.**'
        fake_password = '******'
        with vcr.use_cassette(
                'fixtures/vcr_cassettes/task_create_user_for_share.json',
                before_record_response=scrub_string(fake_password),
                filter_post_data_parameters=['password', 'j_password']):
            new_member = Client.create_user(name='fake',
                                            email=fake_email,
                                            password=fake_password)

        with vcr.use_cassette(
                'fixtures/vcr_cassettes/task_share_with_user.json'):
            task.share_with(new_member)

        with vcr.use_cassette(
                'fixtures/vcr_cassettes/task_user_pending_tasks.json'):
            self.assertTrue(len(new_member.pending_tasks_ids()) == 1)
            self.assertEqual(task['title'],
                             new_member.pending_tasks()[0]['title'])
Example #9
0
 def test_user_creation_reraises_occured_errors(self):
     with vcr.use_cassette(
             'fixtures/vcr_cassettes/invalid_create_user.json'):
         with self.assertRaises(errors.BadRequestError):
             Client.create_user(name='*', email='*', password='******')
Example #10
0
def get_anydo_user():
    passwd = os.popen("anydo_passwd").read()
    user = Client(email='*****@*****.**', password=passwd).get_user()
    return user
Example #11
0
 def test_valid_session_initialized_silently(self):
     with vcr.use_cassette('fixtures/vcr_cassettes/valid_login.json',
                           filter_post_data_parameters=['j_password']):
         client = Client(email=self.email, password=self.password)
         self.assertIsInstance(client, Client)
Example #12
0
 def test_new_client_reraises_occured_errors(self):
     with vcr.use_cassette('fixtures/vcr_cassettes/invalid_login.json'):
         with self.assertRaises(errors.UnauthorizedError):
             Client(email='***', password='******')
Example #13
0
 def login(self):
     return Client(email=self.email, password=self.password).get_user()