Ejemplo n.º 1
0
def test_get_current_user_profile(app):
  with app.app_context():
    g.user_id = '1'
    service = AuthService('secret')
    profile = service.get_current_user_profile()._asdict()
    # Ignore created/updated time
    profile['created_at'], profile['updated_at'] = 0, 0

    # Profile._asdict() does not return match_history
    mocked_profile = {
      'id': 1,
      'user_id': 1,
      'first_name': 'Joe',
      'last_name': 'Bruin',
      'profile_picture': '',
      'gender': 'Male',
      'preferred_gender': 'Female',
      'color': '',
      'animal': '',
      'interests': {'interest1': 'value1'},
      'created_at': 0,
      'updated_at': 0
    }

    assert profile == mocked_profile

  with app.app_context():
    service = AuthService('secret')
    profile = service.get_current_user()
    assert profile is None
Ejemplo n.º 2
0
def test_create_threads(app):
    with app.app_context():
        g.user_id = '1'
        auth_service = AuthService('secret')
        thread_service = ThreadService()

        user = auth_service.get_current_user()
        matches = {'2': '', '3': '', '4': ''}

        # test threads are created for all matches
        threads = thread_service.create_threads(user, matches)
        assert threads is True
Ejemplo n.º 3
0
def test_get_current_user(app):
  with app.app_context():
    g.user_id = '1'
    service = AuthService('secret')
    user = service.get_current_user()._asdict()
    # Ignore created/updated time
    user['created_at'], user['updated_at'] = 0, 0

    mocked_user = {
      'id': 1,
      'email': '*****@*****.**',
      'created_at': 0,
      'updated_at': 0
    }

    assert user == mocked_user

  with app.app_context():
    service = AuthService('secret')
    user = service.get_current_user()
    assert user is None