コード例 #1
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())
コード例 #2
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())
コード例 #3
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())
コード例 #4
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())