Exemplo n.º 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)
Exemplo n.º 2
0
    def test_existent_user_could_be_deleted(self):
        fake_email = '*****@*****.**'
        fake_password = '******'

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

        with vcr.use_cassette(
                'fixtures/vcr_cassettes/fake_user_login.json',
                before_record_response=scrub_string(fake_password),
                filter_post_data_parameters=['j_password'],
                record_mode='new_episodes'):
            user = Client(email=fake_email, password=fake_password).get_user()

        with vcr.use_cassette(
                'fixtures/vcr_cassettes/user_destroy_valid2.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)
Exemplo n.º 3
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)
Exemplo n.º 4
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'])
Exemplo n.º 5
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'])
Exemplo n.º 6
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'])
Exemplo n.º 7
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'])
Exemplo n.º 8
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='******')