Пример #1
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())
Пример #2
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())
Пример #3
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())
Пример #4
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())
Пример #5
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())
Пример #6
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())
Пример #7
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())
Пример #8
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())
Пример #9
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())
Пример #10
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, ''
Пример #11
0
    def test_login_v2_valid_credentials(self):
        response = self.login_client.login_v2(user_name=self.user_name,
                                              password=self.valid_password)

        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())

        response_user_name = ClientUtils.get_value_from_body(
            response,
            LoginClient.KEY_USER_INFO + '.' + LoginClient.KEY_USERNAME)
        self.assertEqual(
            self.user_name, response_user_name, 'Expected user_name: ' +
            str(self.user_name) + ' but got: ' + str(response_user_name))

        response_eidm_user_id = ClientUtils.get_value_from_body(
            response,
            LoginClient.KEY_USER_INFO + '.' + LoginClient.KEY_EIDM_USER_ID)
        self.assertEqual(
            LoginTests.eidm_user_id, response_eidm_user_id,
            'Expected eidm user id: ' + str(self.eidm_user_id) + ' but got: ' +
            str(response_eidm_user_id) + self.extra_data.get_all())
Пример #12
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, ''
Пример #13
0
    def test_create_folder_v2(self):
        folder_name = 'test_folder_create_folder_v2_' + str(int(time()))
        expected_code_and_description = (0, 'SUCCESS')

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

        create_folder_response = self.folders_management_client.create_folder_v2(
            auth=self.auth, new_folder_name=folder_name)
        status_code = ClientUtils.get_response_status_code(
            create_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(
            'create_folder response',
            ClientUtils.get_response_body(create_folder_response))

        code_desc = ClientUtils.get_code_and_description_from_response(
            create_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())

        response_folder_id = ClientUtils.get_value_from_body(
            create_folder_response, FoldersManagementClient.KEY_FOLDER_ID)
        self.assertTrue(
            response_folder_id > 0, 'Expected valid folder id but got: ' +
            str(response_folder_id) + self.extra_data.get_all())
        self.extra_data.add_test_data('response folder id', response_folder_id)

        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_folder_id, file_system_entries)

        self.assertIsNotNone(
            entry, 'Created 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_name, partition_folder_name,
            'Expected folder name: ' + str(folder_name) + ' but got: ' +
            str(partition_folder_name) + self.extra_data.get_all())
Пример #14
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())
Пример #15
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())
Пример #16
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)
Пример #17
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())
Пример #18
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, ''
Пример #19
0
    def setUp(self):
        self.extra_data = ExtraDataManager()
        self.extra_data.add_test_data('user name', self.user_name)
        main_register_and_login_mixin = MainRegisterAndLoginMixin()
        if BoxExternalFileSystemTests.auth is None:
            response = main_register_and_login_mixin.login_or_register(
                user_name=self.user_name,
                password=self.password,
                first_name=self.first_name,
                last_name=self.last_name)
            BoxExternalFileSystemTests.auth = main_register_and_login_mixin.get_auth_from_login_data(
                response)
        self.assertIsInstance(
            BoxExternalFileSystemTests.auth, str, 'Invalid auth: ' +
            str(BoxExternalFileSystemTests.auth) + self.extra_data.get_all())

        if BoxExternalFileSystemTests.host_id is None:
            connect_to_box_response = self.external_storage_client.webdav_connect_to_external_storage(
                auth=self.auth,
                folder_name=self.folder_name,
                service_url=self.service_url,
                user_name=self.box_user_name,
                password=self.box_password)
            status_code = ClientUtils.get_response_status_code(
                connect_to_box_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_connect_to_external_storage_response',
                ClientUtils.get_response_body(connect_to_box_response))

            host_id = ClientUtils.get_value_from_body(
                connect_to_box_response, ExternalStorageClient.KEY_HOST_ID)
            self.assertEquals(
                61043, host_id, 'expected host_id: 61043 but got: ' +
                str(host_id) + self.extra_data.get_all())
            BoxExternalFileSystemTests.host_id = host_id
Пример #20
0
    def setUp(self):
        self.extra_data = ExtraDataManager()
        self.extra_data.add_test_data('user name', self.user_name)
        register_client = RegisterClient()
        if LoginTests.eidm_user_id is None:
            response = 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))

            LoginTests.eidm_user_id = ClientUtils.get_value_from_body(
                response, RegisterClient.KEY_EIDM_USER_ID)
            self.assertIsNotNone(
                LoginTests.eidm_user_id,
                'Expected Eidm user id not None, Register failed in setup' +
                self.extra_data.get_all())
Пример #21
0
    def upload_file_to_s3_and_compress(self, compression_type,
                                       delay_between_polls, file_full_path,
                                       file_name, file_size,
                                       polling_timeout_in_seconds):
        url_to_upload_response = self.files_management_client.get_url_to_upload_v1(
            auth=self.auth,
            folder_id=0,
            file_name=file_name,
            file_size=file_size)
        status_code = ClientUtils.get_response_status_code(
            url_to_upload_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_url_to_upload response',
            ClientUtils.get_response_body(url_to_upload_response))
        version_id = ClientUtils.get_value_from_body(
            url_to_upload_response, FilesManagementClient.KEY_VERSION_ID)
        request_type = ClientUtils.get_value_from_body(
            url_to_upload_response, FilesManagementClient.KEY_REQUEST_TYPE)
        upload_url = ClientUtils.get_value_from_body(
            url_to_upload_response, FilesManagementClient.KEY_URL_TO_UPLOAD)
        header_x_amz_acl = ClientUtils.get_value_from_body(
            url_to_upload_response, json_path='headers.x-amz-acl')
        header_authorization = ClientUtils.get_value_from_body(
            url_to_upload_response, json_path='headers.Authorization')
        header_content_type = ClientUtils.get_value_from_body(
            url_to_upload_response, json_path='headers.Content-Type')
        header_x_amz_date = ClientUtils.get_value_from_body(
            url_to_upload_response, json_path='headers.x-amz-date')
        self.extra_data.add_test_data('version id', version_id)
        self.extra_data.add_test_data('request type', request_type)
        self.extra_data.add_test_data('upload url', upload_url)
        self.extra_data.add_test_data('header x_amz_acl', header_x_amz_acl)
        self.extra_data.add_test_data('header authorization',
                                      header_authorization)
        self.extra_data.add_test_data('header content_type',
                                      header_content_type)
        self.extra_data.add_test_data('header x_amz_date', header_x_amz_date)

        upload_to_s3_response = self.s3_client.upload_to_s3(
            file_full_path=file_full_path,
            url_to_upload=upload_url,
            method=request_type,
            acl=header_x_amz_acl,
            auth=header_authorization,
            date=header_x_amz_date,
            content_type=header_content_type)
        status_code = ClientUtils.get_response_status_code(
            upload_to_s3_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())

        upload_to_compressor_response = self.files_management_client.upload_to_compressor(
            auth=self.auth,
            version_id=version_id,
            compression_type=compression_type)
        status_code = ClientUtils.get_response_status_code(
            upload_to_compressor_response)
        self.assertEqual(
            httplib.NO_CONTENT, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())

        successful_upload, msg = TestUtils.poll_for_upload(
            auth=self.auth,
            version_id=version_id,
            sleep_period=delay_between_polls,
            timeout_in_seconds=polling_timeout_in_seconds,
            extra_data=self.extra_data)
        self.assertIsNotNone(successful_upload,
                             msg + self.extra_data.get_all())

        return version_id
Пример #22
0
    def test_plot_and_send_to_mail(self):  # workflow for web-client plotting
        polling_timeout_in_seconds = 30
        delay_between_polls = 1
        send_to = settings.GMAIL_USER_NAME
        password = settings.GMAIL_PASSWORD

        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 valid 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)

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

        download_id = ClientUtils.get_value_from_body(
            plot_and_send_to_mail_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_plot(
            auth=self.auth,
            version_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())

        sleep(20)  # wait for email to be sent

        gmail_client = GmailClient()
        try:
            gmail_client.connect_to_account(send_to, password)
        except Exception as e:
            self.fail('Could not connect to mail account ' + str(send_to) +
                      ' to verify mail was sent after plot. Exception msg: ' +
                      str(e.message) + '. Exception args: ' + str(e.args) +
                      self.extra_data.get_all())
        self.assertTrue(
            gmail_client.open_label('INBOX'),
            'Failed to open INBOX label in ' + str(send_to) +
            self.extra_data.get_all())
        expected_mail_subject = default_name + ' was sent to you by ' + self.first_name + ' ' + self.last_name
        self.extra_data.add_test_data('expected mail subject',
                                      expected_mail_subject)
        self.assertIsNotNone(
            gmail_client.search_mails_in_label(
                subject_to_search=expected_mail_subject),
            'Could not find sent mail in ' + str(send_to) + ' INBOX' +
            self.extra_data.get_all())
Пример #23
0
    def test_timeline_manual(self):
        file_name = 'test_file_timeline_manual_' + str(int(time())) + '.dwg'
        title = 'test_title_' + str(int(time()))

        self.extra_data.add_test_data('file name', file_name)
        self.extra_data.add_test_data('title', title)

        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())

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

        response_title = ClientUtils.get_value_from_body(
            manual_timeline_response, FilesManagementClient.KEY_TITLE)
        self.assertEqual(
            title, response_title, 'Expected title: ' + str(title) +
            ' but got: ' + str(response_title) + self.extra_data.get_all())

        get_timeline_response = self.files_management_client.get_timeline(
            auth=self.auth, file_id=created_file_id)
        status_code = ClientUtils.get_response_status_code(
            get_timeline_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_timeline response',
            ClientUtils.get_response_body(get_timeline_response))

        response_entries = ClientUtils.get_value_from_body(
            get_timeline_response, FilesManagementClient.KEY_ENTRIES)
        self.assertIsNotNone(
            response_entries,
            'Expected non empty entries' + self.extra_data.get_all())
        self.assertTrue(
            len(response_entries) == 2,
            'Expected exactly 2 entries in response body but got: ' +
            str(response_entries) + self.extra_data.get_all())
        self.extra_data.add_test_data('response entries', response_entries)

        entry = response_entries[0]
        if entry['title'] != title:
            entry = response_entries[1]

        entry_primary_id = entry['primaryVersionId']
        self.assertEqual(
            created_file_id, entry_primary_id,
            'Expected file id: ' + str(created_file_id) + ' but got: ' +
            str(entry_primary_id) + self.extra_data.get_all())
        entry_title = entry['title']
        self.assertEqual(
            title, entry_title, 'Expected title: ' + str(title) +
            ' but got: ' + str(entry_title) + self.extra_data.get_all())

        users_drawing_prefs_in_response_body = ClientUtils.is_key_in_body(
            get_timeline_response, 'usersDrawingPreferences')
        self.assertTrue(
            users_drawing_prefs_in_response_body,
            'Expected usersDrawingPreferences in response body' +
            self.extra_data.get_all())
Пример #24
0
    def test_get_url_to_upload_v1(self):
        file_name = 'LiveView_Clean.dwg'
        file_size = 64128

        url_to_upload_response = self.files_management_client.get_url_to_upload_v1(
            auth=self.auth,
            folder_id=0,
            file_name=file_name,
            file_size=file_size)
        status_code = ClientUtils.get_response_status_code(
            url_to_upload_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_url_to_upload response',
            ClientUtils.get_response_body(url_to_upload_response))

        version_id = ClientUtils.get_value_from_body(
            url_to_upload_response, FilesManagementClient.KEY_VERSION_ID)
        request_type = ClientUtils.get_value_from_body(
            url_to_upload_response, FilesManagementClient.KEY_REQUEST_TYPE)
        upload_url = ClientUtils.get_value_from_body(
            url_to_upload_response, FilesManagementClient.KEY_URL_TO_UPLOAD)
        header_x_amz_date = ClientUtils.get_value_from_body(
            url_to_upload_response, json_path='headers.x-amz-date')
        header_x_amz_acl = ClientUtils.get_value_from_body(
            url_to_upload_response, json_path='headers.x-amz-acl')
        header_authorization = ClientUtils.get_value_from_body(
            url_to_upload_response, json_path='headers.Authorization')
        headers_content_type = ClientUtils.get_value_from_body(
            url_to_upload_response, json_path='headers.Content-Type')

        self.assertTrue(
            version_id > 0, 'Expected valid version id but got: ' +
            str(version_id) + self.extra_data.get_all())
        self.extra_data.add_test_data('version id', version_id)

        self.assertEqual(
            'PUT', request_type, 'Expected request type PUT but got: ' +
            str(request_type) + self.extra_data.get_all())

        self.assertTrue(
            len(upload_url) > 0, 'Expected non empty upload url but got: ' +
            str(upload_url) + self.extra_data.get_all())

        self.assertTrue(
            header_x_amz_date > 0, 'Expected valid date but got: ' +
            str(header_x_amz_date) + self.extra_data.get_all())

        self.assertEqual(
            'authenticated-read', header_x_amz_acl,
            'Expected x-amz-acl header: authenticated-read but got: ' +
            str(header_x_amz_acl) + self.extra_data.get_all())

        self.assertTrue(
            len(header_authorization) > 0,
            'Expected at least one authorization header but got: ' +
            str(header_authorization) + self.extra_data.get_all())

        self.assertEqual(
            'application/octet-stream', headers_content_type,
            'Expected content-type header: ' + str(headers_content_type) +
            ' but got: ' + str(headers_content_type) +
            self.extra_data.get_all())
Пример #25
0
    def test_copy_file_v2_internal(self):
        file_name = 'test_file_copy_file_v2_internal_' + str(int(
            time())) + '.dwg'
        file_new_name = 'test_file_copy_file_v2_internal_copy' + str(
            int(time())) + '.dwg'
        expected_code_and_description = (0, 'SUCCESS')

        self.extra_data.add_test_data('file name', file_name)
        self.extra_data.add_test_data('file new name', file_new_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())

        copy_file_response = self.files_management_client.copy_file_v2_internal(
            auth=self.auth,
            file_id=created_file_id,
            to_folder_id=0,
            rename_to=file_new_name)
        status_code = ClientUtils.get_response_status_code(copy_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(
            'copy_file_internal response',
            ClientUtils.get_response_body(copy_file_response))

        code_desc = ClientUtils.get_code_and_description_from_response(
            copy_file_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())

        copied_file_id = ClientUtils.get_value_from_body(
            copy_file_response, FilesManagementClient.KEY_PRIMARY_WS_ID)
        self.assertTrue(
            copied_file_id > 0, 'Expected valid copied file id but got: ' +
            str(copied_file_id) + self.extra_data.get_all())
        self.extra_data.add_test_data('copied file id', copied_file_id)

        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_src = TestUtils.get_entry_from_internal_file_system_entries(
            entry_id=created_file_id,
            internal_file_system_entries=file_system_entries)
        entry_copy = TestUtils.get_entry_from_internal_file_system_entries(
            entry_id=copied_file_id,
            internal_file_system_entries=file_system_entries)
        self.assertIsNotNone(
            entry_src, 'Source file should still exist in partition' +
            self.extra_data.get_all())
        self.assertIsNotNone(
            entry_copy, 'Copied file should exist in partition' +
            self.extra_data.get_all())

        entry_src_name = TestUtils.get_entry_data_by_keys(
            entry=entry_src, keys=PartitionClient.KEY_ENTRY_NAME)
        entry_copy_name = TestUtils.get_entry_data_by_keys(
            entry=entry_copy, keys=PartitionClient.KEY_ENTRY_NAME)
        self.assertEqual(
            file_name, entry_src_name,
            'Expected source file name: ' + str(file_name) + ' but got: ' +
            str(entry_src_name) + self.extra_data.get_all())
        self.assertEqual(
            file_new_name, entry_copy_name,
            'Expected copy file name: ' + str(file_new_name) + ' but got: ' +
            str(entry_copy_name) + self.extra_data.get_all())
Пример #26
0
    def test_move_file_to_external_folder_rename_and_delete_it_v2(self):
        folder_name = 'test_folder_external_file_flow_' + str(int(time()))
        file_name = 'test_file_external_file_flow_' + str(int(time())) + '.dwg'
        file_new_name = 'test_file_external_file_flow_renamed_' + str(
            int(time())) + '.dwg'
        permanent_folder = 'Permanent_Folder/'

        self.extra_data.add_test_data('folder name', folder_name)
        self.extra_data.add_test_data('file name', file_name)
        self.extra_data.add_test_data('file new name', file_new_name)

        success_code_and_description = (0, 'SUCCESS')
        cont_async_code_and_description = (
            23, 'FILESYSTEM OPERATION CONTINUES ASYNCRONOUSLY')

        polling_timeout_in_seconds = 30
        delay_between_polls = 1

        success, msg = TestUtils.create_external_folder(
            auth=self.auth,
            host_id=self.host_id,
            folder_path=permanent_folder,
            new_folder_name=folder_name,
            extra_data=self.extra_data)
        self.assertIsNotNone(success, msg + self.extra_data.get_all())

        folder_name = permanent_folder + folder_name
        self.extra_data.add_test_data('folder name', folder_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())

        move_to_external_folder_response = self.files_management_client.move_internal_file_to_external(
            auth=self.auth,
            file_id=created_file_id,
            to_host_id=self.host_id,
            to_path=folder_name + '/')
        status_code = ClientUtils.get_response_status_code(
            move_to_external_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(
            'move_internal_file_to_external response',
            ClientUtils.get_response_body(move_to_external_folder_response))

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

        polling_id = ClientUtils.get_value_from_body(
            move_to_external_folder_response,
            FilesManagementClient.KEY_POLLING_ID)
        self.assertTrue(
            polling_id > 0, 'Expected valid polling id, but got: ' +
            str(polling_id) + self.extra_data.get_all())
        self.extra_data.add_test_data('polling id', polling_id)

        successful_move, msg = TestUtils.poll_for_move_to_external(
            auth=self.auth,
            polling_id=polling_id,
            sleep_period=delay_between_polls,
            timeout_in_seconds=polling_timeout_in_seconds,
            extra_data=self.extra_data)
        self.assertIsNotNone(successful_move, msg + self.extra_data.get_all())

        sleep(5)

        file_system_entries, msg = TestUtils.get_external_partition(
            auth=self.auth,
            host_id=self.host_id,
            path=folder_name,
            extra_data=self.extra_data)
        self.assertIsNotNone(file_system_entries,
                             msg + self.extra_data.get_all())

        file_system_entries_names = [
            str(entry[self.partition_client.KEY_ENTRY_NAME])
            for entry in file_system_entries
            if entry['type'] == 'EXTERNAL_DRAWING'
        ]
        if file_name not in file_system_entries_names:
            self.fail('New file should have been moved to external host' +
                      self.extra_data.get_all())

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

        file_system_entries_names = [
            str(entry[self.partition_client.KEY_ENTRY_NAME])
            for entry in internal_file_system_entries
            if entry['type'] == 'DRAWING'
        ]
        if file_new_name in file_system_entries_names:
            self.fail(
                'File should have moved to external folder, and not found in internal partition result'
                + self.extra_data.get_all())

        file_relative_path = folder_name + '/' + file_name
        self.extra_data.add_test_data('file relative path', file_relative_path)
        rename_file_response = self.files_management_client.rename_external_file_v2(
            auth=self.auth,
            host_id=self.host_id,
            name=file_new_name,
            path=file_relative_path)
        status_code = ClientUtils.get_response_status_code(
            rename_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(
            'rename_external_file response',
            ClientUtils.get_response_body(rename_file_response))

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

        file_system_entries, msg = TestUtils.get_external_partition(
            auth=self.auth,
            host_id=self.host_id,
            path=folder_name,
            extra_data=self.extra_data)
        self.assertIsNotNone(file_system_entries,
                             msg + self.extra_data.get_all())

        file_system_entries_names = [
            str(entry[self.partition_client.KEY_ENTRY_NAME])
            for entry in file_system_entries
            if entry['type'] == 'EXTERNAL_DRAWING'
        ]

        if file_new_name not in file_system_entries_names:
            self.fail('File should have been renamed in external host' +
                      self.extra_data.get_all())

        file_relative_path = folder_name + '/' + file_new_name
        self.extra_data.add_test_data('file relative path', file_relative_path)

        delete_file_response = self.files_management_client.delete_external_file_v2(
            auth=self.auth, host_id=self.host_id, path=file_relative_path)
        status_code = ClientUtils.get_response_status_code(
            delete_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(
            'delete_external_file response',
            ClientUtils.get_response_body(delete_file_response))

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

        file_system_entries, msg = TestUtils.get_external_partition(
            auth=self.auth,
            host_id=self.host_id,
            path=folder_name,
            extra_data=self.extra_data)
        self.assertIsNotNone(file_system_entries,
                             msg + self.extra_data.get_all())

        file_system_entries_names = [
            str(entry[self.partition_client.KEY_ENTRY_NAME])
            for entry in file_system_entries
            if entry['type'] == 'EXTERNAL_DRAWING'
        ]

        if file_new_name in file_system_entries_names:
            self.fail(
                'Folder should have been deleted, and not found in partition result'
                + self.extra_data.get_all())

        # Teardown - remove created folder - does not affect test results
        self.folders_management_client.delete_external_folder_v2(
            auth=self.auth, host_id=self.host_id, path=folder_name)
Пример #27
0
    def test_update_post_old_api(self):
        file_name = 'test_file_update_post_' + str(int(time())) + '.dwg'
        comment_body = 'test_comment_body'
        updated_post_status = 'closed'
        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())

        new_post_response = self.drawing_feed_client.new_post_old_api(
            auth=self.auth, file_id=created_file_id, post_body=comment_body)
        status_code = ClientUtils.get_response_status_code(new_post_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'new_post response',
            ClientUtils.get_response_body(new_post_response))

        post_id = ClientUtils.get_value_from_body(new_post_response,
                                                  DrawingFeedClient.KEY_ID)
        self.assertIsInstance(
            post_id, unicode, 'Expected unicode post id but got: ' +
            str(post_id) + self.extra_data.get_all())
        self.extra_data.add_test_data('post id', post_id)

        update_post_response = self.drawing_feed_client.update_post_old_api(
            auth=self.auth,
            file_id=created_file_id,
            post_id=post_id,
            post_status=updated_post_status)
        status_code = ClientUtils.get_response_status_code(
            update_post_response)
        self.assertEqual(
            httplib.OK, status_code,
            'Got status code: ' + str(status_code) + self.extra_data.get_all())
        self.extra_data.add_test_data(
            'update_post response',
            ClientUtils.get_response_body(update_post_response))

        response_post_id = ClientUtils.get_value_from_body(
            update_post_response, DrawingFeedClient.KEY_ID)
        self.assertEqual(
            post_id, response_post_id, 'Expected post_id: ' + str(post_id) +
            ' but got: ' + str(response_post_id) + self.extra_data.get_all())

        self.assertTrue(
            ClientUtils.is_key_in_body(update_post_response, 'updated'),
            'Expected key "updated" to exist in response body' +
            self.extra_data.get_all())

        get_feed_response = self.drawing_feed_client.get_drawing_feed_old_api(
            auth=self.auth, file_id=created_file_id)
        status_code = ClientUtils.get_response_status_code(get_feed_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_feed response',
            ClientUtils.get_response_body(get_feed_response))

        post = TestUtils.get_post_from_drawing_feed_response(
            get_feed_response, post_id)
        self.assertIsNotNone(
            post, 'Expected non empty post' + self.extra_data.get_all())
        self.extra_data.add_test_data('post', post)

        post_status = post['status']
        self.assertEqual(
            updated_post_status, post_status,
            'Expected updated post status: ' + str(updated_post_status) +
            ' but got: ' + str(post_status) + self.extra_data.get_all())
Пример #28
0
    def test_new_post(self):
        file_name = 'test_file_new_post_' + str(int(time())) + '.dwg'
        comment_body = 'test_comment_body'
        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())

        new_post_response = self.drawing_feed_client.new_post(
            auth=self.auth, file_id=created_file_id, post_body=comment_body)

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

        post_status = ClientUtils.get_value_from_body(
            new_post_response, DrawingFeedClient.KEY_STATUS)
        self.assertEqual(
            'open', post_status, 'Expected post status: open but got: ' +
            str(post_status) + self.extra_data.get_all())
        post_body = ClientUtils.get_value_from_body(new_post_response,
                                                    DrawingFeedClient.KEY_BODY)
        self.assertEqual(
            comment_body, post_body,
            'Expected post body: ' + str(comment_body) + ' but got: ' +
            str(post_body) + self.extra_data.get_all())
        post_id = ClientUtils.get_value_from_body(new_post_response,
                                                  DrawingFeedClient.KEY_ID)
        self.assertIsInstance(
            post_id, unicode, 'Expected unicode post id but got: ' +
            str(post_id) + self.extra_data.get_all())
        self.extra_data.add_test_data('post id', post_id)

        get_feed_response = self.drawing_feed_client.get_drawing_feed(
            auth=self.auth, file_id=created_file_id)
        status_code = ClientUtils.get_response_status_code(get_feed_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_feed response',
            ClientUtils.get_response_body(get_feed_response))

        post = TestUtils.get_post_from_drawing_feed_response(
            get_feed_response, post_id)
        self.assertIsNotNone(
            post, 'Expected non-empty post' + self.extra_data.get_all())
        self.extra_data.add_test_data('post', post)

        post_status = post['status']
        self.assertEqual(
            'open', post_status, 'Expected post status: open but got: ' +
            str(post_status) + self.extra_data.get_all())
        post_body = post['body']
        self.assertEqual(
            comment_body, post_body,
            'Expected post body: ' + str(comment_body) + 'but got: ' +
            str(post_body) + self.extra_data.get_all())
        post_actor_name = post['actor']['name']
        user_full_name = self.first_name + ' ' + self.last_name
        self.assertEqual(
            user_full_name, post_actor_name,
            'Expected post actor: ' + str(user_full_name) + 'but got: ' +
            str(post_actor_name) + self.extra_data.get_all())