Esempio n. 1
0
    def test_get_all_users(self):
        self.assertEqual([], get_all_users())

        user1 = Users(
            user_id='eamanu',
            password_hash='hola',
            register_on=datetime.datetime.utcnow(),
            last_pass_change=datetime.datetime.utcnow(),
            name='Emmanuel',
            surname='Arias',
            email='eamanu@yaerobi',
            country_city_id='1',
        )
        user2 = Users(
            user_id='eamanu2',
            password_hash='hola',
            register_on=datetime.datetime.utcnow(),
            last_pass_change=datetime.datetime.utcnow(),
            name='Emmanuel',
            surname='Arias',
            email='eamanu2@yaerobi',
            country_city_id='1',
        )

        user3 = Users(
            user_id='eamanu3',
            password_hash='hola',
            register_on=datetime.datetime.utcnow(),
            last_pass_change=datetime.datetime.utcnow(),
            name='Emmanuel',
            surname='Arias',
            email='eamanu3@yaerobi',
            country_city_id='1',
        )
        db.session.add(user1)
        db.session.add(user2)
        db.session.add(user3)

        db.session.commit()

        all_users = get_all_users()

        self.assertEqual(3, len(all_users))
        for user in all_users:
            self.assertEqual('Emmanuel', user.name)
            self.assertEqual('Arias', user.surname)
Esempio n. 2
0
    def test_get_all_candidate(self):
        self.assertEqual([], get_all_users())

        user1 = Users(
            user_id='eamanu',
            password_hash='hola',
            register_on=datetime.datetime.utcnow(),
            last_pass_change=datetime.datetime.utcnow(),
            name='Emmanuel',
            surname='Arias',
            email='eamanu@yaerobi',
            country_city_id='1',
        )
        user2 = Users(
            user_id='eamanu2',
            password_hash='hola',
            register_on=datetime.datetime.utcnow(),
            last_pass_change=datetime.datetime.utcnow(),
            name='Emmanuel',
            surname='Arias',
            email='eamanu2@yaerobi',
            country_city_id='1',
        )
        candidate1 = Candidate(user_id='eamanu',
                               linkedin='linkedin',
                               other_webpage='other_webpage',
                               bio='bio',
                               github='github')

        candidate2 = Candidate(user_id='eamanu2',
                               linkedin='linkedin2',
                               other_webpage='other_webpage2',
                               bio='bio2',
                               github='github2')

        db.session.add(user1)
        db.session.add(user2)

        db.session.add(candidate1)
        db.session.add(candidate2)

        db.session.commit()

        all_candidate = get_all_candidate()

        self.assertEqual(2, len(all_candidate))
        for candidate, user in all_candidate:
            self.assertIn(f'eamanu', user.user_id)
            self.assertEqual('Emmanuel', user.name)
            self.assertEqual('Arias', user.surname)
            self.assertIn(f'bio', candidate.bio)
            self.assertIn(f'linkedin', candidate.linkedin)
Esempio n. 3
0
    def test_get_all_users(self, mock):
        user_1 =  User(fb_id='123', email=None, name='Jake')
        user_2 = User(fb_id='123', email=None, name='Jane')

        db.session.add(user_1)
        db.session.add(user_2)
        db.session.commit()

        mock.return_value = User(fb_id='123', email=None, name='Albert')
        user_list, status_code = user_service.get_all_users()

        expected = [{'email': None, 'name': 'Jane', 'id': 2, 'relationship_status': None}, {'email': None, 'name': 'Jake', 'id': 1, 'relationship_status': None}] 
        
        assert user_list == expected
        assert status_code == 200
Esempio n. 4
0
    def test_response_409_if_already_exist_candidate(self):
        self.assertEqual([], get_all_users())

        data = dict()
        data['user'] = '******'
        data['password'] = '******'
        data['name'] = 'Emmanuel'
        data['surname'] = 'Arias'
        data['email'] = '*****@*****.**'
        data['country_city_id'] = '1'

        response, code_status = save_new_user(data)

        data = dict()
        data['user'] = '******'
        data['linkedin'] = 'test'
        data['other_webpage'] = 'other_webpage'
        data['bio'] = 'This is a bio'
        data['github'] = 'github page'

        response, code_status = save_new_candidate(data)

        response_object = {
            'status': 'success',
            'message': 'Candidate Successfully registered.'
        }
        self.assertEqual(response_object, response)
        self.assertEqual(201, code_status)

        data = dict()
        data['user'] = '******'
        data['linkedin'] = 'test'
        data['other_webpage'] = 'other_webpage'
        data['bio'] = 'This is a bio'
        data['github'] = 'github page'

        response, code_status = save_new_candidate(data)

        response_object = {
            'status': 'fail',
            'message': 'Candidate already exists.'
        }

        self.assertEqual(response_object, response)
        self.assertEqual(409, code_status)
Esempio n. 5
0
    def test_response_409_if_already_exist_user(self):
        self.assertEqual([], get_all_users())

        data = dict()
        data['user'] = '******'
        data['password'] = '******'
        data['name'] = 'Emmanuel'
        data['surname'] = 'Arias'
        data['email'] = '*****@*****.**'
        data['country_city_id'] = '1'

        response, code_status = save_new_user(data)

        response_object = {
            'status': 'success',
            'message': 'Successfully registered.'
        }
        self.assertEqual(response_object, response)
        self.assertEqual(201, code_status)

        data = dict()
        data['user'] = '******'
        data['password'] = '******'
        data['name'] = 'Emmanuel'
        data['surname'] = 'Arias'
        data['email'] = '*****@*****.**'
        data['country_city_id'] = '1'

        response, code_status = save_new_user(data)

        response_object = {
            'status': 'fail',
            'message': 'User already exists. Please Log in.'
        }
        self.assertEqual(response_object, response)
        self.assertEqual(409, code_status)
Esempio n. 6
0
 def get(self):
     """List all registered users"""
     return get_all_users()
Esempio n. 7
0
 def get(self):
     """
     Fetch all admin users from database
     """
     return get_all_users()
Esempio n. 8
0
 def get(self):
     return get_all_users()
Esempio n. 9
0
 def get(self):
     return {
         'status': 'success',
         'message': 'list',
         'data': get_all_users()
     }