def test_filter_by_one_condition(self): """Test filter_by returns a list of logs that meet the filtering condition""" project = ProjectFactory.create() AuditlogFactory.create_batch( size=3, project_id=project.id, project_short_name=project.short_name, user_id=project.owner.id, user_name=project.owner.name, ) project2 = ProjectFactory.create() should_be_missing = AuditlogFactory.create_batch( size=3, project_id=project2.id, project_short_name=project2.short_name, user_id=project2.owner.id, user_name=project2.owner.name, ) retrieved_logs = self.auditlog_repo.filter_by(user_id=project.owner.id) assert len(retrieved_logs) == 3, retrieved_logs assert should_be_missing not in retrieved_logs, retrieved_logs
def create_auditlogs(self): project = ProjectFactory.create(info={'task_presenter': 'version1', 'task_guidelines': 'version1'}) AuditlogFactory.create(project_id=project.id, project_short_name=project.short_name, user_id=project.owner.id, user_name=project.owner.name, attribute='task_presenter', old_value="old_task_presenter1", new_value="new_task_presenter2", created='2019-01-11T15:24:42.263980') AuditlogFactory.create_batch(size=3, project_id=project.id, project_short_name=project.short_name, user_id=project.owner.id, user_name=project.owner.name, attribute='task_guidelines', old_value="old_task_guidelines1", new_value="new_task_guidelines2", created='2019-01-11T15:24:42.263980') AuditlogFactory.create_batch(size=3, project_id=project.id, project_short_name=project.short_name, user_id=project.owner.id, user_name=project.owner.name, attribute='task_guidelines', old_value="old_task_guidelines1", new_value="new_task_guidelines2", created='2020-01-11T15:24:42.263980')
def test_filter_by_multiple_conditions(self): """Test filter_by supports multiple-condition queries""" app = AppFactory.create() user = UserFactory.create() AuditlogFactory.create_batch(size=3, app_id=app.id, app_short_name=app.short_name, user_id=app.owner.id, user_name=app.owner.name) log = AuditlogFactory.create(app_id=app.id, app_short_name=app.short_name, user_id=user.id, user_name=user.name) retrieved_logs = self.auditlog_repo.filter_by(app_id=app.id, user_id=user.id) assert len(retrieved_logs) == 1, retrieved_logs assert log in retrieved_logs, retrieved_logs
def test_filter_by_multiple_conditions(self): """Test filter_by supports multiple-condition queries""" project = ProjectFactory.create() user = UserFactory.create() AuditlogFactory.create_batch(size=3, project_id=project.id, project_short_name=project.short_name, user_id=project.owner.id, user_name=project.owner.name) log = AuditlogFactory.create(project_id=project.id, project_short_name=project.short_name, user_id=user.id, user_name=user.name) retrieved_logs = self.auditlog_repo.filter_by(project_id=project.id, user_id=user.id) assert len(retrieved_logs) == 1, retrieved_logs assert log in retrieved_logs, retrieved_logs
def test_filter_by_one_condition(self): """Test filter_by returns a list of logs that meet the filtering condition""" app = AppFactory.create() AuditlogFactory.create_batch(size=3, app_id=app.id, app_short_name=app.short_name, user_id=app.owner.id, user_name=app.owner.name) app2 = AppFactory.create() should_be_missing = AuditlogFactory.create_batch(size=3, app_id=app2.id, app_short_name=app2.short_name, user_id=app2.owner.id, user_name=app2.owner.name) retrieved_logs = self.auditlog_repo.filter_by(user_id=app.owner.id) assert len(retrieved_logs) == 3, retrieved_logs assert should_be_missing not in retrieved_logs, retrieved_logs
def test_filter_by_one_condition(self): """Test filter_by returns a list of logs that meet the filtering condition""" project = ProjectFactory.create() AuditlogFactory.create_batch(size=3, project_id=project.id, project_short_name=project.short_name, user_id=project.owner.id, user_name=project.owner.name) project2 = ProjectFactory.create() should_be_missing = AuditlogFactory.create_batch(size=3, project_id=project2.id, project_short_name=project2.short_name, user_id=project2.owner.id, user_name=project2.owner.name) retrieved_logs = self.auditlog_repo.filter_by(user_id=project.owner.id) assert len(retrieved_logs) == 3, retrieved_logs assert should_be_missing not in retrieved_logs, retrieved_logs
def test_filter_by_one_condition(self): """Test filter_by returns a list of logs that meet the filtering condition""" app = AppFactory.create() AuditlogFactory.create_batch(size=3, app_id=app.id, app_short_name=app.short_name, user_id=app.owner.id, user_name=app.owner.name) app2 = AppFactory.create() should_be_missing = AuditlogFactory.create_batch( size=3, app_id=app2.id, app_short_name=app2.short_name, user_id=app2.owner.id, user_name=app2.owner.name) retrieved_logs = self.auditlog_repo.filter_by(user_id=app.owner.id) assert len(retrieved_logs) == 3, retrieved_logs assert should_be_missing not in retrieved_logs, retrieved_logs