Exemplo n.º 1
0
def test_add_and_delete_transfer_from_file(core_org, context):
    """
    <b>Description:</b>
    Checks if a file can be uploaded from disk to the platform.

    <b>Input data:</b>
    1. File name.
    2. Transfer title.
    3. Transfer category.

    <b>Expected results:</b>
    Test passes when a file from disk was uploaded to the platform and corresponding transfer and dataset were
    successfully created and removed from the platform.

    <b>Steps:</b>
    1. Create a transfer using generated csv file.
    2. Check if transfer finished with correct state and verify that it is present on the transfers list.
    3. Check if the transfer has corresponding dataset.
    4. Delete dataset and transfer from the platform.
    5. Verify that transfer and dataset were removed from the platform.
    """
    step("Generate a test csv file")
    file_path = generate_csv_file(column_count=10, row_count=100)
    step("Create a transfer by file upload")
    transfer = Transfer.api_create_by_file_upload(context,
                                                  category="health",
                                                  org_guid=core_org.guid,
                                                  file_path=file_path)
    transfer_flow(transfer, core_org)
    def test_no_token_in_create_transfer_response(self, test_org):
        """
        <b>Description:</b>
        Check that create transfer from a file response doesn't contain a 'token' field.

        <b>Input data:</b>
        1. organization id
        2. test file

        <b>Expected results:</b>
        Test passes when create transfer response doesn't contain a 'token' field.

        <b>Steps:</b>
        1. Send valid create transfer request.
        2. Check that in the response there is no 'token' field.
        """
        step("Generate sample csv file")
        file_path = generate_csv_file(column_count=10, row_count=10)
        step(
            "Create new transfer and check that 'token' field was not returned in response"
        )
        response = hdfs_uploader.api_create_transfer_by_file_upload(
            source=file_path,
            title="test-transfer-{}".format(time.time()),
            is_public=False,
            org_guid=test_org.guid,
            category=self.DEFAULT_CATEGORY)
        assert "token" not in response, "token field was returned in response"
    def test_submit_transfer_from_csv_file_all_categories(
            self, context, category, test_org):
        """
        <b>Description:</b>
        Check that transfer can be created from a csv file in any category.

        <b>Input data:</b>
        1. organization id
        2. transfer category
        3. test file

        <b>Expected results:</b>
        Test passes when transfer and dataset are successfully created from a csv file
        and are visible in the test organization.

        <b>Steps:</b>
        1. Create transfer from a csv file.
        2. Retrieve created transfer and dataset.
        3. Check that created transfer and dataset are visible in the test organization.
        """
        step("Create a transfer with chosen category")
        transfer, dataset = create_dataset_from_file(
            context=context,
            org_guid=test_org.guid,
            file_path=generate_csv_file(),
            category=category)
        TestSubmitTransfer.check_transfer_and_dataset_are_visible_in_test_org(
            transfer=transfer, dataset=dataset, test_org=test_org)
Exemplo n.º 4
0
def test_add_and_delete_transfer_from_file(core_org, context):
    """Create and Delete Transfer from File"""
    step("Generate a test csv file")
    file_path = generate_csv_file(column_count=10, row_count=100)
    step("Create a transfer by file upload")
    transfer = Transfer.api_create_by_file_upload(context,
                                                  category="health",
                                                  org_guid=core_org.guid,
                                                  file_path=file_path)
    transfer_flow(transfer, core_org)
Exemplo n.º 5
0
 def test_no_token_in_create_transfer_response(self, test_org):
     step("Generate sample csv file")
     file_path = generate_csv_file(column_count=10, row_count=10)
     step(
         "Create new transfer and check that 'token' field was not returned in response"
     )
     response = hdfs_uploader.api_create_transfer_by_file_upload(
         source=file_path,
         title="test-transfer-{}".format(time.time()),
         is_public=False,
         org_guid=test_org.guid,
         category=self.DEFAULT_CATEGORY)
     assert "token" not in response, "token field was returned in response"
 def test_3_upload_dataset(self, class_context, core_hdfs_instance):
     step("Create dataset from uploaded file")
     _, self.__class__.dataset = create_dataset_from_file(
         class_context,
         self.test_org,
         generate_csv_file(),
         client=self.test_org_manager_client)
     step("Check dataset directory in hdfs")
     hdfs_dirs = self._list_hdfs_directories(
         self.USERSPACE_PATH.format(self.test_org.guid,
                                    core_hdfs_instance.guid))
     self._assert_directory_in_hdfs(hdfs_dirs,
                                    name=self.dataset.object_store_id,
                                    owner=self.test_org_manager.guid,
                                    group=self.test_org.guid)
Exemplo n.º 7
0
 def _create_transfer(self,
                      context,
                      org_guid,
                      column_count=10,
                      row_count=10,
                      category=TestSubmitTransfer.DEFAULT_CATEGORY,
                      size=None,
                      file_name=None):
     step("Generate sample csv file")
     file_path = generate_csv_file(column_count=column_count,
                                   row_count=row_count,
                                   size=size,
                                   file_name=file_name)
     step("Create a transfer with new category")
     transfer = Transfer.api_create_by_file_upload(context,
                                                   category=category,
                                                   org_guid=org_guid,
                                                   file_path=file_path)
     transfer.ensure_finished()
     return transfer
Exemplo n.º 8
0
    def test_add_user(self, test_org, context):
        """ Verify if user data are properly saved in HDFS while creating user and uploading data file to TAP.

            After create user test verifies that user is synchronized. Then login to platform as new user.
            Create transfer to HDFS and check that transfer is completed.

            Input data:
                user name: name for new user
                data file: file which is transferred to HDFS
                organization: organization wherein will be new user

            Expected results:
               It is possible to create new user and login to platform as new user. New user is able to create
               transfer to HDFS. User data are properly saved on HDFS.

            Steps:
                1. Create new user
                2. Check that user is created completely
                3. Login as new registered user
                4. Check that the user is able to create a transfer
                5. Ensure that transfer is completed successfully
        """
        step("Create new user")
        user = User.create_by_adding_to_organization(
            context=context,
            org_guid=test_org.guid,
            role=User.ORG_ROLE["user"])
        step("Check that user was synchronized")
        ag_user = AuthGatewayUser.get_user_state(org_guid=test_org.guid,
                                                 user_id=user.guid)
        assert ag_user.is_synchronized, "User {} was not synchronized".format(
            user.username)
        step("Login new registered user")
        client = user.login()
        step("Check that the user is able to create a transfer")
        transfer = Transfer.api_create_by_file_upload(
            context,
            test_org.guid,
            file_utils.generate_csv_file(),
            client=client)
        transfer.ensure_finished()