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)
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)
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
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)
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'])
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'])
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'])
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'])
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='******')
def get_anydo_user(): passwd = os.popen("anydo_passwd").read() user = Client(email='*****@*****.**', password=passwd).get_user() return user
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)
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='******')
def login(self): return Client(email=self.email, password=self.password).get_user()