Example #1
0
    def test_plot_and_download(self):  # workflow for mobile-client plotting
        polling_timeout_in_seconds = 30
        delay_between_polls = 1

        file_system_entries, msg = TestUtils.get_internal_partition(
            auth=self.auth, extra_data=self.extra_data)
        self.assertIsNotNone(file_system_entries,
                             msg + self.extra_data.get_all())
        entry = TestUtils.get_first_drawing_from_internal_file_system(
            file_system_entries)
        self.extra_data.add_test_data('entry', entry)

        version_id_to_plot = TestUtils.get_entry_data_by_keys(
            entry, 'versionId')
        self.assertTrue(
            version_id_to_plot > 0, 'Expected integer version id but got: ' +
            str(version_id_to_plot) + self.extra_data.get_all())
        self.extra_data.add_test_data('version id to plot', version_id_to_plot)

        prepare_file_to_plot_response = self.files_management_client.prepare_file_to_download(
            auth=self.auth, version_id=version_id_to_plot, format='plot')
        status_code = ClientUtils.get_response_status_code(
            prepare_file_to_plot_response)
        self.assertEqual(
            httplib.ACCEPTED, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'prepare_file_to_download response',
            ClientUtils.get_response_body(prepare_file_to_plot_response))

        download_id = ClientUtils.get_value_from_body(
            prepare_file_to_plot_response,
            FilesManagementClient.KEY_DOWNLOAD_ID)
        self.assertIsInstance(
            download_id, unicode, 'Expected unicode download id but got: ' +
            str(download_id) + self.extra_data.get_all())
        self.extra_data.add_test_data('download id', download_id)

        default_name, msg = TestUtils.poll_for_download(
            auth=self.auth,
            download_id=download_id,
            sleep_period=delay_between_polls,
            timeout_in_seconds=polling_timeout_in_seconds,
            extra_data=self.extra_data)
        self.assertIsNotNone(default_name, msg + self.extra_data.get_all())

        download_response = self.files_management_client.download_file(
            auth=self.auth,
            download_id=download_id,
            download_file_name=default_name)
        status_code = ClientUtils.get_response_status_code(download_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())

        downloaded_content = ClientUtils.get_response_raw_content(
            download_response)
        self.assertIsNotNone(
            downloaded_content,
            'Expected non empty content download' + self.extra_data.get_all())
Example #2
0
    def test_post_user_preferences(self):
        expected_country = 'UK'

        response = self.user_preferences_client.post_user_preferences(
            auth=self.auth, country=expected_country)
        self.assertIsNotNone(
            response, 'Response is None. user_name: ' + str(self.user_name))
        status_code = ClientUtils.get_response_status_code(response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.assertTrue(
            ClientUtils.is_response_body_empty(response),
            'Expected empty body in response but got ' +
            str(ClientUtils.get_response_body(response)) +
            self.extra_data.get_all())

        get_user_preferences_response = self.user_preferences_client.get_user_preferences(
            auth=self.auth)
        status_code = ClientUtils.get_response_status_code(
            get_user_preferences_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'get_user_preferences_response',
            ClientUtils.get_response_body(get_user_preferences_response))

        country = ClientUtils.get_value_from_body(
            get_user_preferences_response, UserClient.KEY_COUNTRY)
        self.assertEqual(
            expected_country, country,
            'Expected changed country: ' + str(expected_country) +
            ' but got: ' + str(country) + self.extra_data.get_all())
Example #3
0
    def test_post_drawing_preferences(self):
        file_name = 'test_file_post_drawing_prefs' + str(int(time())) + '.dwg'
        expected_orth_on = True
        expected_line_weight_on = False
        self.extra_data.add_test_data('file name', file_name)

        created_file_id, msg = TestUtils.create_file(
            auth=self.auth, file_name=file_name, extra_data=self.extra_data)
        self.assertIsNotNone(created_file_id, msg + self.extra_data.get_all())

        user_specific_drawing_prefs = {}
        user_specific_drawing_prefs.__setitem__('orthoOn', expected_orth_on)
        user_specific_drawing_prefs.__setitem__('lineWeightOn',
                                                expected_line_weight_on)
        post_drawing_prefs_response = self.files_management_client.post_drawing_preferences(
            auth=self.auth,
            file_id=created_file_id,
            user_specific_drawing_preferences=user_specific_drawing_prefs)
        self.assertIsNotNone(post_drawing_prefs_response,
                             'Response is None' + self.extra_data.get_all())
        status_code = ClientUtils.get_response_status_code(
            post_drawing_prefs_response)
        self.assertEqual(
            httplib.NO_CONTENT, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.assertTrue(
            ClientUtils.is_response_body_empty(post_drawing_prefs_response),
            'Expected empty response body but got: ' +
            str(ClientUtils.get_response_body(post_drawing_prefs_response)) +
            self.extra_data.get_all())

        get_drawing_prefs_response = self.files_management_client.get_drawing_preferences(
            auth=self.auth, file_id=created_file_id)
        status_code = ClientUtils.get_response_status_code(
            get_drawing_prefs_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'get_drawing_preferences response',
            ClientUtils.get_response_body(get_drawing_prefs_response))

        orth_on = ClientUtils.get_value_from_body(
            response=get_drawing_prefs_response,
            json_path='userSpecificDrawingPreferences.orthoOn')
        self.assertEqual(
            expected_orth_on, orth_on,
            'Expected orth_on: ' + str(expected_orth_on) + 'but got: ' +
            str(orth_on) + self.extra_data.get_all())

        line_weight_on = ClientUtils.get_value_from_body(
            response=get_drawing_prefs_response,
            json_path='userSpecificDrawingPreferences.lineWeightOn')
        self.assertEqual(
            expected_line_weight_on, line_weight_on,
            'Expected line_weight_on: ' + str(expected_line_weight_on) +
            'but got: ' + str(line_weight_on) + self.extra_data.get_all())
Example #4
0
    def test_get_user_share_suggestions(self):
        file_name = 'test_file_get_user_share_suggestions' + str(int(
            time())) + '.dwg'
        user_name_to_share_with = 'rest_tests_share_with_user' + str(
            int(time())) + '@autodesk.com'
        first_name_share_with = 'Rest'
        last_name_share_with = 'Test'
        password_share_with = 'Moomoo123'

        self.extra_data.add_test_data('file name', file_name)
        self.extra_data.add_test_data('user name to share with',
                                      user_name_to_share_with)

        created_file_id, msg = TestUtils.create_file(
            auth=self.auth, file_name=file_name, extra_data=self.extra_data)
        self.assertIsNotNone(created_file_id, msg + self.extra_data.get_all())

        login_data = self.main_register_and_login_mixin.login_or_register(
            user_name=user_name_to_share_with,
            password=password_share_with,
            first_name=first_name_share_with,
            last_name=last_name_share_with)
        self.assertIsNotNone(
            login_data, 'Failed to register user_name_to_share_with' +
            self.extra_data.get_all())

        share_response = self.files_management_client.share_file_v2(
            auth=self.auth,
            file_id=created_file_id,
            emails=[user_name_to_share_with])
        status_code = ClientUtils.get_response_status_code(share_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'share_file response',
            ClientUtils.get_response_body(share_response))

        user_share_suggestions_response = self.user_client.get_user_share_suggestions(
            auth=self.auth)
        status_code = ClientUtils.get_response_status_code(
            user_share_suggestions_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'get_user_share_suggestions response',
            ClientUtils.get_response_body(user_share_suggestions_response))

        response_contact_addresses = TestUtils.get_addresses_from_share_suggestions_response(
            user_share_suggestions_response)
        self.assertTrue(
            len(response_contact_addresses) == 1,
            'Expected 1 share suggestion only but got: ' +
            str(response_contact_addresses) + self.extra_data.get_all())
Example #5
0
    def test_get_file_shares(self):
        file_name = 'test_file_get_file_shares_' + str(int(time())) + '.dwg'
        user_name_to_share_with = 'rest_tests_share_with_user_' + str(
            int(time())) + '@autodesk.com'

        self.extra_data.add_test_data('file name', file_name)
        self.extra_data.add_test_data('user name to share with',
                                      user_name_to_share_with)

        login_data = self.main_register_and_login_mixin.login_or_register(
            user_name=user_name_to_share_with,
            password=self.password,
            first_name=self.first_name,
            last_name=self.last_name)

        self.assertIsNotNone(
            login_data, 'Failed to register user_name_to_share_with' +
            self.extra_data.get_all())

        created_file_id, msg = TestUtils.create_file(
            auth=self.auth, file_name=file_name, extra_data=self.extra_data)
        self.assertIsNotNone(created_file_id, msg + self.extra_data.get_all())

        share_response = self.files_management_client.share_file_v2(
            auth=self.auth,
            file_id=created_file_id,
            emails=[user_name_to_share_with])
        status_code = ClientUtils.get_response_status_code(share_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'share_file response',
            ClientUtils.get_response_body(share_response))

        get_shares_response = self.files_management_client.get_file_shares(
            auth=self.auth, file_id=created_file_id)
        status_code = ClientUtils.get_response_status_code(get_shares_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'get_file_shares response',
            ClientUtils.get_response_body(get_shares_response))

        user_names = TestUtils.get_user_names_from_get_file_shares_response(
            get_shares_response)
        expected_user_names = [self.user_name, user_name_to_share_with]
        self.assertItemsEqual(
            expected_user_names, user_names,
            'Expected users ' + str(expected_user_names) +
            ' to have permissions on file but got: ' + str(user_names) +
            self.extra_data.get_all())
Example #6
0
    def test_remove_folder_share(self):
        folder_name = 'test_folder_remove_folder_share_' + str(int(time()))
        expected_code_and_description = (0, 'SUCCESS')

        user_name_to_share_with = 'rest_tests_share_with_user' + str(int(time())) + '@autodesk.com'

        self.extra_data.add_test_data('folder name', folder_name)
        self.extra_data.add_test_data('user name to share with', user_name_to_share_with)

        login_data = self.main_register_and_login.login_or_register(user_name=user_name_to_share_with,
                                                                    password=self.password,
                                                                    first_name=self.first_name,
                                                                    last_name=self.last_name)
        user_id_to_share_with = self.main_register_and_login.get_user_id_from_login_data(login_data)
        auth_user_to_share_with = self.main_register_and_login.get_auth_from_login_data(login_data)

        self.assertIsInstance(auth_user_to_share_with, str,
                              'Invalid auth: ' + str(auth_user_to_share_with) + self.extra_data.get_all())

        created_folder_id, msg = TestUtils.create_folder(auth=self.auth, folder_name=folder_name,
                                                         extra_data=self.extra_data)
        self.assertIsNotNone(created_folder_id, msg + self.extra_data.get_all())

        share_response = self.folders_management_client.share_folder(auth=self.auth, folder_id=created_folder_id,
                                                                     emails=[user_name_to_share_with])
        status_code = ClientUtils.get_response_status_code(share_response)
        self.assertEqual(httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data('share_folder response', ClientUtils.get_response_body(share_response))

        delete_share_response = self.folders_management_client.delete_folder_share(auth=self.auth,
                                                                                   folder_id=created_folder_id,
                                                                                   user_id=user_id_to_share_with)
        status_code = ClientUtils.get_response_status_code(delete_share_response)
        self.assertEqual(httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data('deleted_folder_share response',
                                      ClientUtils.get_response_body(delete_share_response))

        code_desc = ClientUtils.get_code_and_description_from_response(delete_share_response)
        self.assertEqual(expected_code_and_description, code_desc,
                         'Expected ' + str(expected_code_and_description) + ' but got: ' + str(
                             code_desc) + self.extra_data.get_all())

        file_system_entries, msg = TestUtils.get_internal_partition(auth=auth_user_to_share_with,
                                                                    extra_data=self.extra_data)
        self.assertIsNotNone(file_system_entries, msg + self.extra_data.get_all())

        shared_folder = TestUtils.get_entry_from_internal_file_system_entries(created_folder_id, file_system_entries)

        self.assertIsNone(shared_folder,
                          'Folder no longer shared should not exist in partition' + self.extra_data.get_all())
Example #7
0
    def test_recent_files(self):
        response = self.files_management_client.recent_files(self.auth)
        status_code = ClientUtils.get_response_status_code(response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data('response',
                                      ClientUtils.get_response_body(response))

        self.assertTrue(
            ClientUtils.is_key_in_body(response, 'limit'),
            'Expected key limit in response body' + self.extra_data.get_all())
        self.assertTrue(
            ClientUtils.is_key_in_body(response, 'lastFileDate'),
            'Expected key lastFileDate in response body' +
            self.extra_data.get_all())
        self.assertTrue(
            ClientUtils.is_key_in_body(response, 'page'),
            'Expected key page in response body' + self.extra_data.get_all())

        drawings = ClientUtils.get_value_from_body(
            response, FilesManagementClient.KEY_DRAWINGS)
        self.assertTrue(
            len(drawings) > 0,
            'Expected at least one drawing in response body' +
            self.extra_data.get_all())
Example #8
0
 def test_login_v2_no_password(self):
     response = self.login_client.login_v2(user_name=self.user_name,
                                           password=self.empty_password)
     status_code = ClientUtils.get_response_status_code(response)
     self.assertEqual(
         httplib.UNAUTHORIZED, status_code,
         'Got status code: ' + str(status_code) + self.extra_data.get_all())
Example #9
0
    def test_get_external_file_info(self):
        file_name_in_box_folder = 'LiveView_Clean.dwg'

        external_file_info_response = self.files_management_client.get_external_file_info(
            auth=self.auth, host_id=self.host_id, path=file_name_in_box_folder)
        status_code = ClientUtils.get_response_status_code(
            external_file_info_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'get_external_file_info response',
            ClientUtils.get_response_body(external_file_info_response))

        file_primary_version = ClientUtils.get_value_from_body(
            external_file_info_response,
            FilesManagementClient.KEY_PRIMARY_VERSION_ID)
        file_type = ClientUtils.get_value_from_body(
            external_file_info_response, FilesManagementClient.KEY_TYPE)
        file_size = ClientUtils.get_value_from_body(
            external_file_info_response, FilesManagementClient.KEY_SIZE)
        self.assertTrue(
            file_primary_version > 0,
            'Expected valid primary version id but got: ' +
            str(file_primary_version) + self.extra_data.get_all())
        self.assertEquals(
            'EXTERNAL_DRAWING', file_type,
            'Expected file type: EXTERNAL_DRAWING but got: ' + str(file_type) +
            self.extra_data.get_all())
        self.assertEquals(
            62, file_size, 'Expected file size: 62 but got: ' +
            str(file_size) + self.extra_data.get_all())
Example #10
0
    def test_get_drawing_preferences(self):
        file_name = 'test_file_get_drawing_prefs_' + str(int(time())) + '.dwg'
        self.extra_data.add_test_data('file name', file_name)

        created_file_id, msg = TestUtils.create_file(
            auth=self.auth, file_name=file_name, extra_data=self.extra_data)
        self.assertIsNotNone(created_file_id, msg + self.extra_data.get_all())

        get_drawing_prefs_response = self.files_management_client.get_drawing_preferences(
            auth=self.auth, file_id=created_file_id)
        status_code = ClientUtils.get_response_status_code(
            get_drawing_prefs_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data('get_drawing_preferences response',
                                      get_drawing_prefs_response)

        user_specific_drawing_prefs_in_response_body = ClientUtils.is_key_in_body(
            response=get_drawing_prefs_response,
            nested_keys='userSpecificDrawingPreferences')
        self.assertTrue(
            user_specific_drawing_prefs_in_response_body,
            'Exepected key userSpecificDrawingPreferences to exist in repsonse body'
            + self.extra_data.get_all())

        shared_drawing_prefs_in_response_body = ClientUtils.is_key_in_body(
            response=get_drawing_prefs_response,
            nested_keys='sharedDrawingPreferences')
        self.assertTrue(
            shared_drawing_prefs_in_response_body,
            'Exepected key sharedDrawingPreferences to exist in repsonse body'
            + self.extra_data.get_all())
Example #11
0
    def test_connect_to_box(self):
        active_hosts_response = self.external_storage_client.webdav_active_hosts(
            auth=self.auth)
        status_code = ClientUtils.get_response_status_code(
            active_hosts_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'webdav_active_hosts response',
            ClientUtils.get_response_body(active_hosts_response))

        active_hosts = ClientUtils.get_response_body(active_hosts_response)
        self.assertIsNotNone(
            active_hosts, 'active_hosts is None' + self.extra_data.get_all())

        found_host_in_active_hosts = False
        for host in active_hosts:
            if host['hostId'] == self.host_id:
                found_host_in_active_hosts = True
                break
        self.assertTrue(
            found_host_in_active_hosts,
            'Expected to find hostId 61043 in active hosts' +
            self.extra_data.get_all())
Example #12
0
    def test_get_partition_external(self):
        expected_entries_names = [
            'xref with block - Standard.zip', 'LiveView_Clean.dwg',
            'Permanent_Folder'
        ]

        response = self.partition_client.get_external_partition(
            auth=self.auth, host_id=self.host_id)
        status_code = ClientUtils.get_response_status_code(response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data('external_partition response',
                                      ClientUtils.get_response_body(response))

        file_system_entries = ClientUtils.get_value_from_body(
            response, PartitionClient.KEY_FILE_SYSTEM_ENTRIES)
        self.assertIsNotNone(
            file_system_entries,
            'Expected non empty partition' + self.extra_data.get_all())

        file_system_entries_names = TestUtils.get_entries_names_from_file_system_entries(
            file_system_entries)
        self.assertItemsEqual(
            expected_entries_names, file_system_entries_names,
            'Expected entries names: ' + str(expected_entries_names) +
            ' but got: ' + str(file_system_entries_names) +
            self.extra_data.get_all())
Example #13
0
    def test_get_user_details(self):
        response = self.user_client.get_user_details(auth=self.auth)
        status_code = ClientUtils.get_response_status_code(response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())

        self.assertTrue(
            len(response.history) > 1,
            'Expected at least one redirect url in response history. response history: '
            + str(response.history) + self.extra_data.get_all())
Example #14
0
    def test_create_file_v2(self):
        file_name = 'test_file_create_file_v2_' + str(int(time())) + '.dwg'
        self.extra_data.add_test_data('file name', file_name)

        create_file_response = self.files_management_client.create_file_v2(
            auth=self.auth, new_drawing_name=file_name)
        status_code = ClientUtils.get_response_status_code(
            create_file_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'create_file response',
            ClientUtils.get_response_body(create_file_response))

        response_file_id, response_file_name = ClientUtils.get_multiple_values_from_body(
            create_file_response, [
                FilesManagementClient.KEY_VERSION_ID,
                FilesManagementClient.KEY_NAME
            ])
        self.assertTrue(
            response_file_id > 0, 'Expected valid file id but got: ' +
            str(response_file_id) + self.extra_data.get_all())
        self.assertEqual(
            file_name, response_file_name,
            'Expected file name: ' + str(file_name) + 'but got: ' +
            str(response_file_name) + self.extra_data.get_all())

        self.extra_data.add_test_data('response file id', response_file_id)
        self.extra_data.add_test_data('response file name', response_file_name)

        file_system_entries, msg = TestUtils.get_internal_partition(
            auth=self.auth, extra_data=self.extra_data)
        self.assertIsNotNone(file_system_entries,
                             msg + self.extra_data.get_all())

        entry = TestUtils.get_entry_from_internal_file_system_entries(
            response_file_id, file_system_entries)
        self.assertIsNotNone(
            entry, 'Created file should exist in partition' +
            self.extra_data.get_all())

        partition_file_name = TestUtils.get_entry_data_by_keys(
            entry=entry, keys=PartitionClient.KEY_ENTRY_NAME)
        self.assertEqual(
            file_name, partition_file_name,
            'Expected file name: ' + str(file_name) + 'but got: ' +
            str(partition_file_name) + self.extra_data.get_all())

        partition_nitrous_id = TestUtils.get_entry_data_by_keys(
            entry=entry, keys=PartitionClient.KEY_NITROUS_ID)
        self.assertIsNotNone(
            partition_nitrous_id,
            'Expected nitrous ID not None' + self.extra_data.get_all())
Example #15
0
    def test_register_v1_valid_account_already_exists(self):
        self.make_sure_user_already_registered(self.user_name, self.valid_password)

        response = self.register_client.register_v1(user_name=self.user_name, password=self.valid_password,
                                                    first_name=self.first_name,
                                                    last_name=self.last_name)
        status_code = ClientUtils.get_response_status_code(response)
        self.assertEqual(httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data('register response', ClientUtils.get_response_body(response))

        email = ClientUtils.get_value_from_body(response, RegisterClient.KEY_MAIL)
        self.assertEquals(self.user_name, email, 'Expected user_name: ' + str(self.user_name) + ' but got: ' + str(
            email) + self.extra_data.get_all())
Example #16
0
    def test_user_status(self):
        response = self.user_client.get_user_status(auth=self.auth)
        status_code = ClientUtils.get_response_status_code(response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data('get_user_status response',
                                      ClientUtils.get_response_body(response))

        status = ClientUtils.get_value_from_body(response, 'status')
        self.assertEqual(
            1, status, 'Expected status: 1 but got: ' + str(status) +
            self.extra_data.get_all())
Example #17
0
    def test_rename_folder_v2(self):
        folder_name = 'test_folder_rename_folder_v2_' + str(int(time()))
        folder_new_name = 'test_folder_rename_folder_v2_renamed_' + str(
            int(time()))
        expected_code_and_description = (0, 'SUCCESS')

        self.extra_data.add_test_data('folder name', folder_name)
        self.extra_data.add_test_data('folder new name', folder_new_name)

        created_folder_id, msg = TestUtils.create_folder(
            auth=self.auth,
            folder_name=folder_name,
            extra_data=self.extra_data)
        self.assertIsNotNone(created_folder_id,
                             msg + self.extra_data.get_all())

        rename_folder_response = self.folders_management_client.rename_folder_v2(
            auth=self.auth, folder_id=created_folder_id, name=folder_new_name)
        status_code = ClientUtils.get_response_status_code(
            rename_folder_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'rename_folder response',
            ClientUtils.get_response_body(rename_folder_response))

        code_desc = ClientUtils.get_code_and_description_from_response(
            rename_folder_response)
        self.assertEqual(
            expected_code_and_description, code_desc,
            'Expected ' + str(expected_code_and_description) + ' but got: ' +
            str(code_desc) + self.extra_data.get_all())

        file_system_entries, msg = TestUtils.get_internal_partition(
            auth=self.auth, extra_data=self.extra_data)
        self.assertIsNotNone(file_system_entries,
                             msg + self.extra_data.get_all())

        entry = TestUtils.get_entry_from_internal_file_system_entries(
            created_folder_id, file_system_entries)

        self.assertIsNotNone(
            entry, 'Renamed folder should exist in partition' +
            self.extra_data.get_all())
        partition_folder_name = TestUtils.get_entry_data_by_keys(
            entry=entry, keys=PartitionClient.KEY_ENTRY_NAME)
        self.assertEqual(
            folder_new_name, partition_folder_name,
            'Expected folder name: ' + str(folder_new_name) + ' but got: ' +
            str(partition_folder_name) + self.extra_data.get_all())
Example #18
0
    def get_internal_partition(auth, extra_data, partition_folder_id=0):
        partition_client = PartitionClient()
        response = partition_client.get_partition_v2(auth=auth, parent_folder_id=partition_folder_id)

        status_code = ClientUtils.get_response_status_code(response)
        if not httplib.OK == status_code:
            return None, 'Expected status: ' + str(httplib.OK) + ' but got: ' + str(status_code)
        extra_data.add_test_data('get_partition response', ClientUtils.get_response_body(response))

        file_system_entries = ClientUtils.get_value_from_body(response, PartitionClient.KEY_FILE_SYSTEM_ENTRIES)
        if file_system_entries is None:
            return None, 'Expected a non-empty partition'

        return file_system_entries, ''
Example #19
0
    def test_register_v1_empty_password(self):
        expected_code_and_description = (400, 'One or more parameters are missing.')

        response = self.register_client.register_v1(user_name=self.user_name, password=self.empty_password,
                                                    first_name=self.first_name,
                                                    last_name=self.last_name)
        status_code = ClientUtils.get_response_status_code(response)
        self.assertEqual(httplib.BAD_REQUEST, status_code,
                         'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data('register response', ClientUtils.get_response_body(response))

        code_desc = ClientUtils.get_code_and_description_from_response(response)
        self.assertEqual(expected_code_and_description, code_desc,
                         'Expected ' + str(expected_code_and_description) + ' but got: ' + str(
                             code_desc) + self.extra_data.get_all())
Example #20
0
    def test_register_v1_invalid_password(self):
        expected_code_and_description = (2, 'PASSWORD REJECTED')

        response = self.register_client.register_v1(user_name=self.user_name, password=self.invalid_password,
                                                    first_name=self.first_name,
                                                    last_name=self.last_name)
        status_code = ClientUtils.get_response_status_code(response)
        self.assertEqual(httplib.BAD_REQUEST, status_code,
                         'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data('register response', ClientUtils.get_response_body(response))

        code_desc = ClientUtils.get_code_and_description_from_response(response)
        self.assertEqual(expected_code_and_description, code_desc,
                         'Expected ' + str(expected_code_and_description) + ' but got: ' + str(
                             code_desc) + self.extra_data.get_all())
Example #21
0
    def create_file(auth, file_name, extra_data):
        files_management_client = FilesManagementClient()
        response = files_management_client.create_file_v2(auth=auth, new_drawing_name=file_name)

        status_code = ClientUtils.get_response_status_code(response)
        if not httplib.OK == status_code:
            return None, 'Expected status: ' + str(httplib.OK) + ' but got: ' + str(status_code)
        extra_data.add_test_data('create_file response', ClientUtils.get_response_body(response))

        created_file_id = ClientUtils.get_value_from_body(response, FilesManagementClient.KEY_VERSION_ID)
        if not created_file_id > 0:
            return None, 'Expected a valid file id but got: ' + str(created_file_id)
        extra_data.add_test_data('created file id', created_file_id)

        return created_file_id, ''
Example #22
0
    def test_get_user_preferences(self):
        response = self.user_preferences_client.get_user_preferences(
            auth=self.auth)

        status_code = ClientUtils.get_response_status_code(response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data('get_user_preferences response',
                                      ClientUtils.get_response_body(response))

        version = ClientUtils.get_value_from_body(response,
                                                  UserClient.KEY_VERSION)
        self.assertIsInstance(
            version, int, 'Expected an integer version but got: ' +
            str(version) + self.extra_data.get_all())
Example #23
0
    def test_get_partition_path_internal(self):
        expected_entries_names = ['Clean Canvas.dwg', 'Dog House Plan Sample.dwg', 'Drive Roller Assembly Sample.dwg',
                                  'Geospatial Sample.dwg', 'Villa Project Sample.dwg']

        response = self.partition_client.get_partition_path(auth=self.auth, path='')
        status_code = ClientUtils.get_response_status_code(response)
        self.assertEqual(httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data('response', response)

        file_system_entries = ClientUtils.get_value_from_body(response, PartitionClient.KEY_FILE_SYSTEM_ENTRIES)
        self.assertIsNotNone(file_system_entries, 'Expected non empty partition' + self.extra_data.get_all())

        file_system_entries_names = TestUtils.get_entries_names_from_file_system_entries(file_system_entries)
        self.assertItemsEqual(expected_entries_names, file_system_entries_names,
                              'Expected entries names: ' + str(expected_entries_names) + ' but got: ' + str(
                                  file_system_entries_names) + self.extra_data.get_all())
Example #24
0
    def test_get_xrefs_all_missing(self):
        file_name = 'xref with block.dwg'
        file_full_path = settings.BASE_DIR + '/rest_test/main_rest_tests/sharding/testfiles/file_with_xref/' + file_name
        file_size = 64687
        file_xref_name = '\one block.dwg'

        compression_type = 1
        polling_timeout_in_seconds = 60
        delay_between_polls = 2

        version_id = self.upload_file_to_s3_and_compress(
            compression_type, delay_between_polls, file_full_path, file_name,
            file_size, polling_timeout_in_seconds)

        xrefs_client = XrefsClient()
        get_xrefs_response = xrefs_client.get_all_xrefs(auth=self.auth,
                                                        version_id=version_id)
        status_code = ClientUtils.get_response_status_code(get_xrefs_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())

        response_xrefs = ClientUtils.get_response_body(get_xrefs_response)
        self.assertIsNotNone(
            response_xrefs, 'Expected non empty get_all_xrefs response body' +
            self.extra_data.get_all())

        self.assertTrue(
            len(response_xrefs) > 0, 'Expected at least one xref, but got: ' +
            str(response_xrefs) + self.extra_data.get_all())
        self.extra_data.add_test_data('get_all_xrefs response', response_xrefs)

        for xref in response_xrefs:
            xref_name = xref['name']
            xref_is_missing = xref['missing']
            xref_type = xref['type']
            self.assertEqual(
                file_xref_name, xref_name,
                'Expected xref name: ' + str(file_xref_name) + ' but got: ' +
                str(xref_name) + self.extra_data.get_all())
            self.assertTrue(
                xref_is_missing,
                'Xref was not uploaded to s3, should be missing' +
                self.extra_data.get_all())
            self.assertIsNotNone(
                xref_type,
                'Expected non empty xref type' + self.extra_data.get_all())
Example #25
0
    def create_external_folder(auth, host_id, folder_path, new_folder_name, extra_data):
        expected_code_and_description = (0, 'SUCCESS')
        folders_management_client = FoldersManagementClient()
        response = folders_management_client.create_external_folder_v2(auth=auth, host_id=host_id,
                                                                       folder_path=folder_path,
                                                                       new_folder_name=new_folder_name)
        status_code = ClientUtils.get_response_status_code(response)
        if not httplib.OK == status_code:
            return None, 'Expected status: ' + str(httplib.OK) + ' but got: ' + str(status_code)
        extra_data.add_test_data('create_external_folder response', ClientUtils.get_response_body(response))

        code_and_description = ClientUtils.get_code_and_description_from_response(response)
        if not expected_code_and_description == code_and_description:
            return None, 'Expected code and description: ' + str(expected_code_and_description) + ' but got: ' + str(
                code_and_description)

        return True, ''
Example #26
0
    def poll_master(auth, extra_data, event, search_key, search_value, return_key, sleep_period, timeout_in_seconds,
                    failure_msg='polling received error code'):
        """
        returns a 2-tuple s.t.:
            first item is the requested data of caller
            second item is the error message if failed
        """
        last_notification_id = 0
        polling_start_time = int(time())
        polling_end_time = polling_start_time

        poll_client = PollClient()

        while polling_end_time - polling_start_time < timeout_in_seconds:
            poll_response = poll_client.poll(auth=auth, last_notification_id=last_notification_id, event=event)
            status_code = ClientUtils.get_response_status_code(poll_response)
            if httplib.OK != status_code:
                return None, 'Expected status: ' + str(httplib.OK) + ' but got: ' + str(status_code)
            extra_data.add_test_data('poll response', ClientUtils.get_response_body(poll_response))

            notifications = ClientUtils.get_value_from_body(poll_response, PollClient.KEY_NOTIFICATIONS)
            if notifications is not None:

                for notif in notifications:
                    notif_id = notif[PollClient.KEY_NOTIFICATION_ID]

                    if notif_id > last_notification_id:
                        last_notification_id = notif_id

                    if notif[PollClient.KEY_NOTIFICATION_TYPE].lower() == event.lower() and \
                                    notif[search_key] == search_value:
                        notif_status = notif[PollClient.KEY_NOTIFICATION_STATUS]
                        if notif_status == 0:  # Successful
                            if return_key is not None:
                                return_value = notif[return_key]
                                extra_data.add_test_data(return_key, return_value)
                                return return_value, ''
                            else:
                                return True, ''
                        elif notif_status == 2:  # Failed
                            return None, failure_msg
            polling_end_time = int(time())
            sleep(sleep_period)
        return None, 'Timeout while polling for event: ' + str(event)
Example #27
0
    def test_get_external_file_provider(self):
        file_name_in_box_folder = 'LiveView_Clean.dwg'

        external_file_info_response = self.files_management_client.get_external_file_provider_v2(
            auth=self.auth, host_id=self.host_id, path=file_name_in_box_folder)
        status_code = ClientUtils.get_response_status_code(
            external_file_info_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'get_external_file_provider response',
            ClientUtils.get_response_body(external_file_info_response))

        provider = ClientUtils.get_value_from_body(
            external_file_info_response, FilesManagementClient.KEY_PROVIDER)
        self.assertEquals(
            'BOX', provider, 'Expected provider: BOX but got: ' +
            str(provider) + self.extra_data.get_all())
Example #28
0
    def test_delete_folder(self):
        folder_name = 'test_folder_delete_folder_' + str(int(time()))
        expected_code_and_description = (0, 'SUCCESS')

        self.extra_data.add_test_data('folder name', folder_name)

        created_folder_id, msg = TestUtils.create_folder(
            auth=self.auth,
            folder_name=folder_name,
            extra_data=self.extra_data)
        self.assertIsNotNone(created_folder_id,
                             msg + self.extra_data.get_all())

        delete_folder_response = self.folders_management_client.delete_folder(
            auth=self.auth, folder_id=created_folder_id)
        status_code = ClientUtils.get_response_status_code(
            delete_folder_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'delete_folder response',
            ClientUtils.get_response_body(delete_folder_response))

        code_desc = ClientUtils.get_code_and_description_from_response(
            delete_folder_response)
        self.assertEqual(
            expected_code_and_description, code_desc,
            'Expected ' + str(expected_code_and_description) + ' but got: ' +
            str(code_desc) + self.extra_data.get_all())

        file_system_entries, msg = TestUtils.get_internal_partition(
            auth=self.auth, extra_data=self.extra_data)
        self.assertIsNotNone(file_system_entries,
                             msg + self.extra_data.get_all())

        entry = TestUtils.get_entry_from_internal_file_system_entries(
            created_folder_id, file_system_entries)

        self.assertIsNone(
            entry, 'Deleted folder should not exist in partition' +
            self.extra_data.get_all())
Example #29
0
    def create_folder(auth, folder_name, extra_data):
        expected_code_and_description = (0, 'SUCCESS')
        folders_management_client = FoldersManagementClient()
        response = folders_management_client.create_folder_v2(auth=auth, new_folder_name=folder_name)

        status_code = ClientUtils.get_response_status_code(response)
        if not httplib.OK == status_code:
            return None, 'Expected status: ' + str(httplib.OK) + ' but got: ' + str(status_code)
        extra_data.add_test_data('create_folder response', ClientUtils.get_response_body(response))

        code_and_description = ClientUtils.get_code_and_description_from_response(response)
        if not expected_code_and_description == code_and_description:
            return None, 'Expected code and description: ' + str(expected_code_and_description) + ' but got: ' + str(
                code_and_description)

        created_folder_id = ClientUtils.get_value_from_body(response, FoldersManagementClient.KEY_FOLDER_ID)
        if not created_folder_id > 0:
            return None, 'Expected a valid folder id but got: ' + str(created_folder_id)
        extra_data.add_test_data('created folder id', created_folder_id)

        return created_folder_id, ''
Example #30
0
    def test_register_v1_valid(self):
        response = self.register_client.register_v1(user_name=self.user_name, password=self.valid_password,
                                                    first_name=self.first_name,
                                                    last_name=self.last_name)
        status_code = ClientUtils.get_response_status_code(response)
        self.assertEqual(httplib.OK, status_code, 'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data('register response', ClientUtils.get_response_body(response))

        eidm_user_id = ClientUtils.get_value_from_body(response, RegisterClient.KEY_EIDM_USER_ID)
        self.assertIsNotNone(eidm_user_id, 'Expected eidm user id in response but got None' + self.extra_data.get_all())
        self.assertTrue(len(eidm_user_id) > 0, 'Expected a non-empty string as eidm user id but got: ' + str(
            eidm_user_id) + self.extra_data.get_all())

        eidm_user_name = ClientUtils.get_value_from_body(response, RegisterClient.KEY_EIDM_USER_NAME)
        self.assertIsNotNone(eidm_user_name, 'Expected eidm user name in response but got None' + self.extra_data.get_all())
        self.assertTrue(len(eidm_user_name) > 0, 'Expected a non-empty string as eidm user name but got: ' + str(
            eidm_user_name) + self.extra_data.get_all())

        email = ClientUtils.get_value_from_body(response, RegisterClient.KEY_MAIL)
        self.assertEquals(self.user_name, email, 'Expected user_name: ' + str(self.user_name) + ' but got: ' + str(
            email) + self.extra_data.get_all())