def test_sync_creates_new_employee(database, data_source): """ Data source contains a user that we don't have in our database, we must create a new user in our database. """ sync_employees(data_source) user = User.query.filter(User.email == '*****@*****.**').one() assert user.first_name == 'Sam'
def test_sync_marks_employee_as_terminated(database, data_source): """ Data source contains a list of active users for beans. If the user is not present in the data source, but present in our database we mark the employee as terminated """ sync_employees(data_source) user = User.query.filter(User.email == '*****@*****.**').one() assert not user.terminated sync_employees({}) user = User.query.filter(User.email == '*****@*****.**').one() assert user.terminated
def test_sync_updates_current_employee(database, data_source): """ Data source contains a user that we are already tracking in our database, we must update the user in the database to reflect new information. Returns """ sync_employees(data_source) user = User.query.filter(User.email == '*****@*****.**').one() assert user.first_name == 'Sam' assert user.meta_data['department'] == 'Engineering' data = data_source[0] data['first_name'] = 'John' data['department'] = 'Design' data['metadata']['department'] = 'Design' sync_employees(data_source) user = User.query.filter(User.email == '*****@*****.**').one() assert user.first_name == 'John' assert user.meta_data['department'] == 'Design'
def populate_employees(): employees = DataIngestion().ingest() sync_employees([employee for employee in employees]) return "OK"
def populate_users_from_s3(): sync_employees([employee for employee in get_json_employee_data()]) return "OK"