def test_get_all_by_workspace_data_ordering(self): # Arrange workspace = self.fixture.workspace_1.id ascending_order_by_field = ["+title"] descending_order_by_field = ["-title"] # Act ascending_result = Data.get_all_by_workspace(workspace, ascending_order_by_field) descending_result = Data.get_all_by_workspace(workspace, descending_order_by_field) # Assert for i in range(len(ascending_result)): self.assertTrue(ascending_result.all()[i].title == descending_result.all()[len(ascending_result) - i - 1].title)
def test_get_all_by_workspace_multi_field_sorting(self): # Arrange ascending_order_by_multi_field = ["+workspace", "+title"] descending_order_by_multi_field = ["+workspace", "-title"] workspace = self.fixture.workspace_1.id # Act ascending_result = Data.get_all_by_workspace(workspace, ascending_order_by_multi_field) descending_result = Data.get_all_by_workspace(workspace, descending_order_by_multi_field) # Assert self.assertEqual(self.fixture.data_3.user_id, ascending_result.all()[0].user_id) self.assertEqual(self.fixture.data_5.user_id, ascending_result.all()[1].user_id) self.assertEqual(self.fixture.data_3.user_id, descending_result.all()[1].user_id) self.assertEqual(self.fixture.data_5.user_id, descending_result.all()[0].user_id)
def test_get_all_by_workspace_data_descending_sorting(self): # Arrange descending_order_by_field = ["-title"] workspace = self.fixture.workspace_1.id # Act descending_result = Data.get_all_by_workspace(workspace, descending_order_by_field) # Assert self.assertTrue(self.fixture.data_5.title == descending_result.all()[len(descending_result)-2].title) self.assertTrue(self.fixture.data_3.title == descending_result.all()[len(descending_result)-1].title)
def test_get_all_by_workspace_data_ascending_sorting(self): # Arrange ascending_order_by_field = ["+title"] workspace = self.fixture.workspace_1.id # Act ascending_result = Data.get_all_by_workspace(workspace, ascending_order_by_field) # Assert self.assertTrue(self.fixture.data_3.title == ascending_result.all()[0].title) self.assertTrue(self.fixture.data_5.title == ascending_result.all()[1].title)
def get_all_by_workspace(workspace, user): """ Get all data that belong to the workspace. Args: workspace: Returns: """ return Data.get_all_by_workspace(workspace)
def get_all_by_workspace(workspace, user, order_by_field=DATA_SORTING_FIELDS): """Get all data that belong to the workspace. Args: workspace: order_by_field: Returns: """ return Data.get_all_by_workspace(workspace, order_by_field)