예제 #1
0
 def test8_create_list(self):
     list_properties = ListCreationInformation()
     list_properties.AllowContentTypes = True
     list_properties.BaseTemplate = ListTemplateType.TasksWithTimelineAndHierarchy
     list_properties.Title = self.target_list_title
     list_to_create = self.client.web.lists.add(list_properties)
     self.client.execute_query()
     self.assertEqual(list_properties.Title, list_to_create.properties['Title'])
     self.__class__.target_list = list_to_create
예제 #2
0
 def setUpClass(cls):
     super(TestSPView, cls).setUpClass()
     cls.target_list = cls.ensure_list(
         cls.client.web,
         ListCreationInformation("Tasks", None, ListTemplateType.Tasks))
     cls.target_view_title = "My Tasks %s" % random_seed
     cls.target_view_title_updated = cls.target_view_title + "_updated"
 def setUpClass(cls):
     super(TestSharePointFile, cls).setUpClass()
     cls.target_list = cls.ensure_list(cls.client.web,
                                       ListCreationInformation(
                                           "Archive Documents N%s" % random_seed,
                                           None,
                                           ListTemplateType.DocumentLibrary))
예제 #4
0
def generate_contacts(context):
    contacts_list = ensure_list(
        context.web,
        ListCreationInformation("Contacts_Large", None,
                                ListTemplateType.Contacts))

    fake = Faker()
    total_amount = 200
    for idx in range(0, total_amount):
        contact_properties = {
            'Title': fake.name(),
            'FullName': fake.name(),
            'Email': fake.email(),
            'Company': fake.company(),
            'WorkPhone': fake.phone_number(),
            'WorkAddress': fake.street_address(),
            'WorkCity': fake.city(),
            'WorkZip': fake.postcode(),
            'WorkCountry': fake.country(),
            'WebPage': {
                'Url': fake.url()
            }
        }
        contact_item = contacts_list.add_item(contact_properties)
        context.execute_query()
        print("({0} of {1}) Contact '{2}' has been created".format(
            idx, total_amount, contact_item.properties["Title"]))
 def setUpClass(cls):
     super(TestSharePointFolder, cls).setUpClass()
     cls.target_list = cls.ensure_list(cls.client.web,
                                       ListCreationInformation(
                                           create_unique_name("Documents"),
                                           None,
                                           ListTemplateType.DocumentLibrary))
예제 #6
0
def generate_documents(context):
    lib = ensure_list(
        context.web,
        ListCreationInformation("Documents_Archive", None,
                                ListTemplateType.DocumentLibrary))

    include_files = False

    fake = Faker()
    total_amount = 200
    for idx in range(0, total_amount):
        # 1. Create a folder
        folder_name = fake.date()
        target_folder = lib.rootFolder.add(folder_name)
        context.execute_query()
        print("({0} of {1}) Folder '{2}' has been created".format(
            idx, total_amount, target_folder.serverRelativeUrl))

        if include_files:
            # 2. Upload a file into a folder
            path = "../../../tests/data/SharePoint User Guide.docx"
            with open(path, 'rb') as content_file:
                file_content = content_file.read()
            name = os.path.basename(path)
            target_file = target_folder.upload_file(name, file_content)
            context.execute_query()
            print("File '{0}' has been uploaded".format(
                target_file.serverRelativeUrl))
 def setUpClass(cls):
     super(TestFieldValue, cls).setUpClass()
     cls.target_list = cls.ensure_list(
         cls.client.web,
         ListCreationInformation(
             "Tasks N%s" % random_seed, None,
             ListTemplateType.TasksWithTimelineAndHierarchy))
 def setUpClass(cls):
     super(TestSharePointListItem, cls).setUpClass()
     cls.target_list = cls.ensure_list(cls.client.web,
                                       ListCreationInformation("Tasks",
                                                               None,
                                                               ListTemplateType.Tasks)
                                       )
     cls.default_title = "Task %s" % random_seed
 def setUpClass(cls):
     super(TestListItemAttachment, cls).setUpClass()
     cls.target_list = cls.ensure_list(
         cls.client.web,
         ListCreationInformation("Tasks", None, ListTemplateType.Tasks))
     item_properties = {'Title': 'Approval Task'}
     cls.target_item = cls.target_list.add_item(item_properties)
     cls.client.execute_query()
 def setUpClass(cls):
     super(TestSharePointListItem, cls).setUpClass()
     target_list_title = "Tasks" + str(randint(0, 10000))
     cls.target_list = cls.ensure_list(
         cls.client.web,
         ListCreationInformation(target_list_title, None,
                                 ListTemplateType.Tasks))
     cls.default_title = create_unique_name("Task")
     cls.batch_items_count = 3
    def setUpClass(cls):
        super(TestSPView, cls).setUpClass()
        cls.target_list = cls.ensure_list(
            cls.client.web,
            ListCreationInformation("Tasks", None, ListTemplateType.Tasks))

        field_info = FieldCreationInformation(
            "TaskComment_" + uuid.uuid4().hex, FieldType.Note)
        cls.target_field = cls.target_list.fields.add(
            field_info).execute_query()
def create_tasks_list(client):
    """

    :type client: ClientContext
    """
    list_title = create_unique_name("Tasks N")
    list_create_info = ListCreationInformation(list_title,
                                               None,
                                               ListTemplateType.TasksWithTimelineAndHierarchy)

    target_list = client.web.lists.add(list_create_info).execute_query()
    field_info = FieldCreationInformation("Manager", FieldType.User)
    user_field = target_list.fields.add(field_info).execute_query()
    return target_list
예제 #13
0
 def setUpClass(cls):
     super(TestFieldValue, cls).setUpClass()
     cls.multi_lookup_field_name = "PredecessorsAlt"
     cls.url_field_name = "DocumentationLink"
     cls.geo_field_name = "Place"
     cls.choice_field_name = "TaskStatus"
     cls.multi_choice_field_name = "TaskStatuses"
     cls.user_field_name = "PrimaryApprover"
     cls.lookup_field_name = "RelatedDocuments"
     cls.target_list = cls.ensure_list(cls.client.web,
                                       ListCreationInformation(
                                           create_unique_name("Tasks N"),
                                           None,
                                           ListTemplateType.TasksWithTimelineAndHierarchy))
     cls.lookup_list = cls.client.web.default_document_library().get().execute_query()
예제 #14
0
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.fields.field_multi_user_value import FieldMultiUserValue
from office365.sharepoint.fields.field_user_value import FieldUserValue
from office365.sharepoint.lists.list_creation_information import ListCreationInformation
from office365.sharepoint.lists.list_template_type import ListTemplateType
from tests import create_unique_name, test_site_url, test_client_credentials

ctx = ClientContext(test_site_url).with_credentials(test_client_credentials)
list_title = create_unique_name("Tasks N")
list_create_info = ListCreationInformation(
    list_title, None, ListTemplateType.TasksWithTimelineAndHierarchy)

tasks_list = ctx.web.lists.add(list_create_info).execute_query()
current_user = ctx.web.current_user.get().execute_query()

multi_user_value = FieldMultiUserValue()
multi_user_value.add(FieldUserValue.from_user(current_user))

item_to_create = tasks_list.add_item({
    "Title": "New Task",
    "AssignedTo": multi_user_value
}).execute_query()

multi_user_value_alt = FieldMultiUserValue()
multi_user_value_alt.add(FieldUserValue(current_user.id))

item_to_create_alt = tasks_list.add_item({
    "Title": "New Task 2",
    "AssignedTo": multi_user_value_alt
}).execute_query()
예제 #15
0
 def setUpClass(cls):
     super(TestSPView, cls).setUpClass()
     cls.target_list = cls.ensure_list(
         cls.client.web,
         ListCreationInformation("Tasks", None, ListTemplateType.Tasks))