diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 031fbbc..b3f08c1 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -1,72 +1,74 @@ include(ECMAddTests) find_package(Qt5Test CONFIG REQUIRED) set(kgapitest_SRCS fakenetworkreply.cpp fakenetworkaccessmanager.cpp fakenetworkaccessmanagerfactory.cpp testutils.cpp ) add_library(kgapitest STATIC ${kgapitest_SRCS}) target_link_libraries(kgapitest Qt5::Core Qt5::Network Qt5::Test KPimGAPICore) macro(add_libkgapi2_test _module _testname) set(testSources ${_module}/${_testname}.cpp) string(SUBSTRING ${_module} 0 1 moduleFirst) string(SUBSTRING ${_module} 1 -1 moduleLast) string(TOUPPER ${moduleFirst} moduleFirst) string(CONCAT moduleName ${moduleFirst} ${moduleLast}) set(extraLibs "KPimGAPI${moduleName}") set(utilsFile ${CMAKE_CURRENT_SOURCE_DIR}/${_module}/${_module}testutils.cpp) if (EXISTS ${utilsFile}) list(APPEND testSources ${utilsFile}) endif() ecm_add_test(${testSources} LINK_LIBRARIES kgapitest KPimGAPICore ${extraLibs} TEST_NAME ${_testname} NAME_PREFIX ${_module}- ) endmacro(add_libkgapi2_test) ecm_add_test(fakenamtest.cpp LINK_LIBRARIES kgapitest KPimGAPICore TEST_NAME fakenamtest NAME_PREFIX fake-) add_libkgapi2_test(core fetchjobtest) add_libkgapi2_test(core createjobtest) add_libkgapi2_test(core accountinfofetchjobtest) add_libkgapi2_test(contacts contactcreatejobtest) add_libkgapi2_test(contacts contactdeletejobtest) add_libkgapi2_test(contacts contactfetchjobtest) add_libkgapi2_test(contacts contactfetchphotojobtest) add_libkgapi2_test(contacts contactmodifyjobtest) add_libkgapi2_test(contacts contactsgroupcreatejobtest) add_libkgapi2_test(contacts contactsgroupdeletejobtest) add_libkgapi2_test(contacts contactsgroupfetchjobtest) add_libkgapi2_test(contacts contactsgroupmodifyjobtest) add_libkgapi2_test(calendar calendarcreatejobtest) add_libkgapi2_test(calendar calendardeletejobtest) add_libkgapi2_test(calendar calendarfetchjobtest) add_libkgapi2_test(calendar calendarmodifyjobtest) add_libkgapi2_test(calendar eventcreatejobtest) add_libkgapi2_test(calendar eventdeletejobtest) add_libkgapi2_test(calendar eventfetchjobtest) add_libkgapi2_test(calendar eventmodifyjobtest) add_libkgapi2_test(calendar freebusyqueryjobtest) add_libkgapi2_test(tasks taskcreatejobtest) add_libkgapi2_test(tasks taskdeletejobtest) add_libkgapi2_test(tasks taskfetchjobtest) add_libkgapi2_test(tasks taskmodifyjobtest) add_libkgapi2_test(tasks taskmovejobtest) add_libkgapi2_test(tasks tasklistcreatejobtest) add_libkgapi2_test(tasks tasklistdeletejobtest) add_libkgapi2_test(tasks tasklistfetchjobtest) add_libkgapi2_test(tasks tasklistmodifyjobtest) add_libkgapi2_test(drive aboutfetchjobtest) add_libkgapi2_test(drive changefetchjobtest) +add_libkgapi2_test(drive filecopyjobtest) +add_libkgapi2_test(drive filecreatejobtest) add_libkgapi2_test(drive filesearchquerytest) diff --git a/autotests/drive/aboutfetchjobtest.cpp b/autotests/drive/aboutfetchjobtest.cpp new file mode 100644 index 0000000..283704b --- /dev/null +++ b/autotests/drive/aboutfetchjobtest.cpp @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2018 Daniel Vrátil + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#include +#include + +#include "fakenetworkaccessmanagerfactory.h" +#include "testutils.h" +#include "drivetestutils.h" + +#include "types.h" +#include "aboutfetchjob.h" +#include "about.h" +#include "account.h" + +using namespace KGAPI2; + +Q_DECLARE_METATYPE(QList) + +class AboutFetchJobTest : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void initTestCase() + { + NetworkAccessManagerFactory::setFactory(new FakeNetworkAccessManagerFactory); + } + + void testFetch() + { + FakeNetworkAccessManagerFactory::get()->setScenarios({ + scenarioFromFile(QFINDTESTDATA("data/about_fetch_request.txt"), + QFINDTESTDATA("data/about_fetch_response.txt")) + + }); + const auto about = aboutFromFile(QFINDTESTDATA("data/about.json")); + + auto account = AccountPtr::create(QStringLiteral("MockAccount"), QStringLiteral("MockToken")); + auto job = new Drive::AboutFetchJob(account, nullptr); + QVERIFY(execJob(job)); + const auto items = job->items(); + QCOMPARE(items.count(), 1); + const auto returnedAbout = items.at(0).dynamicCast(); + QVERIFY(returnedAbout); + QCOMPARE(*returnedAbout, *about); + } +}; + +QTEST_GUILESS_MAIN(AboutFetchJobTest) + +#include "aboutfetchjobtest.moc" + + + diff --git a/autotests/drive/changefetchjobtest.cpp b/autotests/drive/changefetchjobtest.cpp new file mode 100644 index 0000000..1eb15b8 --- /dev/null +++ b/autotests/drive/changefetchjobtest.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2018 Daniel Vrátil + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#include +#include + +#include "fakenetworkaccessmanagerfactory.h" +#include "testutils.h" +#include "drivetestutils.h" + +#include "types.h" +#include "changefetchjob.h" +#include "change.h" +#include "account.h" + +using namespace KGAPI2; + +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(KGAPI2::Drive::ChangesList) + +class ChangeFetchJobTest : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void initTestCase() + { + NetworkAccessManagerFactory::setFactory(new FakeNetworkAccessManagerFactory); + } + + void testFetchAll() + { + FakeNetworkAccessManagerFactory::get()->setScenarios({ + scenarioFromFile(QFINDTESTDATA("data/changes_fetch_page1_request.txt"), + QFINDTESTDATA("data/changes_fetch_page1_response.txt")), + scenarioFromFile(QFINDTESTDATA("data/changes_fetch_page2_request.txt"), + QFINDTESTDATA("data/changes_fetch_page2_response.txt")) + }); + const Drive::ChangesList changes = { + changeFromFile(QFINDTESTDATA("data/change1.json")), + changeFromFile(QFINDTESTDATA("data/change2.json")) + }; + + auto account = AccountPtr::create(QStringLiteral("MockAccount"), QStringLiteral("MockToken")); + auto job = new Drive::ChangeFetchJob(account); + QVERIFY(execJob(job)); + const auto items = job->items(); + QCOMPARE(items.count(), changes.count()); + for (int i = 0; i < changes.count(); ++i) { + const auto returnedChange = items.at(i).dynamicCast(); + const auto expectedChange = changes.at(i); + QVERIFY(returnedChange); + QCOMPARE(*returnedChange, *expectedChange); + } + } + + void testFetchSingle() + { + FakeNetworkAccessManagerFactory::get()->setScenarios({ + scenarioFromFile(QFINDTESTDATA("data/change1_fetch_request.txt"), + QFINDTESTDATA("data/change1_fetch_response.txt")) + + }); + const auto change = changeFromFile(QFINDTESTDATA("data/change1.json")); + + auto account = AccountPtr::create(QStringLiteral("MockAccount"), QStringLiteral("MockToken")); + auto job = new Drive::ChangeFetchJob(QString::number(change->id()), account); + QVERIFY(execJob(job)); + const auto items = job->items(); + QCOMPARE(items.count(), 1); + const auto returnedChange = items.at(0).dynamicCast(); + QVERIFY(returnedChange); + QCOMPARE(*returnedChange, *change); + } +}; + +QTEST_GUILESS_MAIN(ChangeFetchJobTest) + +#include "changefetchjobtest.moc" + + + + + diff --git a/autotests/drive/data/DSC_1287.JPG b/autotests/drive/data/DSC_1287.JPG new file mode 100644 index 0000000..189630c Binary files /dev/null and b/autotests/drive/data/DSC_1287.JPG differ diff --git a/autotests/drive/data/about.json b/autotests/drive/data/about.json new file mode 100644 index 0000000..f4973e1 --- /dev/null +++ b/autotests/drive/data/about.json @@ -0,0 +1,649 @@ +{ + "languageCode": "en", + "quotaBytesByService": [ + { + "serviceName": "DRIVE", + "bytesUsed": "586253350" + }, + { + "serviceName": "PHOTOS", + "bytesUsed": "10417331" + }, + { + "serviceName": "GMAIL", + "bytesUsed": "672922405" + } + ], + "features": [ + { + "featureName": "ocr" + }, + { + "featureName": "translation", + "featureRate": 2.0 + } + ], + "folderColorPalette": [ + "#ac725e", + "#d06b64", + "#f83a22", + "#fa573c", + "#ff7537", + "#ffad46", + "#fad165", + "#fbe983", + "#b3dc6c", + "#7bd148", + "#16a765", + "#42d692", + "#92e1c0", + "#9fe1e7", + "#9fc6e7", + "#4986e7", + "#9a9cff", + "#b99aff", + "#a47ae2", + "#cd74e6", + "#f691b2", + "#cca6ac", + "#cabdbf", + "#8f8f8f" + ], + "quotaBytesUsedAggregate": "1277284486", + "permissionId": "07857126568572968161", + "teamDriveThemes": [ + { + "colorRgb": "#ea6100", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/Z5KeSUwxyWmRT9HGiVoXxqEp-KcWLSAkEgs3EgSHghCRi1_xPNFwdXbll6ivkDDqhtKabFeH1hw5fT3uDEmYDRVH3cNUXklNfZ0M8yuJ5Bwgu4w-vg=w1920-h216-n", + "id": "abacus" + }, + { + "colorRgb": "#4285f4", + "backgroundImageLink": "https://lh3.googleusercontent.com/proxy/UjEpDwYsn-r3TcmSB4k58Z-cKBa_KWgNy5F9sx-O2KGGTJXNXODqmxLJY999NCZG80WDFvs93nF3ISv_qGEiI5slt5eyoFxBCWKuFm873RZEqPy-E6GN4a8=w1920-h216-n", + "id": "blueprints" + }, + { + "colorRgb": "#689f38", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/xVkWcsvjuebP-UnWCIJp6fEqRUHwIJObjK5KawhB-ReWImKOVk5FnbhqnirdhAuZLS3VWAqnks3-3SDjhQMePR15YYfuF7stMy1R14jdcd2WyhSLex00=w1920-h216-n", + "id": "bok_choy" + }, + { + "colorRgb": "#4285f4", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/6Ok-qHt6muyfFg1x3Nd3y9M_iRUH5_aJRXq9JlTE6Z3a67qUFeVTdpLG80OBKpOtMXXffAPXtHMRkAMbzR-Q1e_dCqCntJAkV_q3U4VftNYC3k_V=w1920-h216-n", + "id": "books" + }, + { + "colorRgb": "#ef6c00", + "backgroundImageLink": "https://lh3.googleusercontent.com/proxy/laR76MvgkpxgcFyKbLRlDHThRQ4PLNNwbzuHzSr_uQAOzxCdGhLFBsdMHk_jVWlFBlLSyqODOoLkCaO_lhmu_9zB1_z81r7fPVDjVL007HcvxXHc=w1920-h216-n", + "id": "bread" + }, + { + "colorRgb": "#f06292", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/E3mV_x9XxkOnITzjKrPB0k8U1Cl6I_gqIff5aswwKAAnd7XtXCDQXgu_CMnLI8kbaPqoiqF695_eSyrp5d2Fp-OGeK-_WtpNU3LQAZNCQjYHzd1I1V-uw_Zmkco=w1920-h216-n", + "id": "bubbles_color" + }, + { + "colorRgb": "#039be5", + "backgroundImageLink": "https://lh3.googleusercontent.com/proxy/d_WN5RlW-1zH2gW_Kxj7hHqITZtlM7Zv-WlmBhdq6_43BeEHVxwCIhsqdxdWtCn2FYLH3bdPf0GeR3UCa9B2uXDrfwMOhnOaGwmJxAHLbC9K9Yp0VOg=w1920-h216-n", + "id": "circuit" + }, + { + "colorRgb": "#e91e63", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/LlctuQjxc_XPvwI_INV2KqcfflGjEreBmM2mFXp_5q24UUblES7O1yMNJYYtyMrpcvkziHO8Pyqd0OcvQyRBmNgQE3QI4vD88GMuCHPrd5E1NNl3=w1920-h216-n", + "id": "clams" + }, + { + "colorRgb": "#689f38", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/29RzK7cLA_mP_eh3Z0oAgElcC2DstGo9ujJNHecUyeoUIRbJ1npk_KhoNRtvBb5ZPVuv8dU5C5D0Ei18I_IPu_12ptLNoOioOvTAp_G9p0omV8gfHBg=w1920-h216-n", + "id": "clovers" + }, + { + "colorRgb": "#db4437", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/qVcF-uCcRs4eNsZFZHKDIiN_qdO20ifgGhQpi1t94SFzROGTb-1Kik2dbJ9_gk9G-QMawqhVQ_OVBE_5ZRAiqjhImQyfGSnnND7BEK1SiQYzRi_LpVfZnQ=w1920-h216-n", + "id": "cocktails" + }, + { + "colorRgb": "#ef6c00", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/4rVgd0sxbyBKn2AF41Xn5alyAxc0nOgDAb6y1T3FnX6vntT6QQ0m8QgUlpr2J5rYLfCF9xh2cuGV7QxRSC13Ws2kgaDuf0Iopac-ZCBF6kgg40KXyCQ=w1920-h216-n", + "id": "concert" + }, + { + "colorRgb": "#607d8b", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/UzcLkepaZHw5GeAzjagJdp7-2DGaBMcj-9TU-X3o4PD1x_kQByZO_r-RDmBxS1iLzsq_MDEq4U_3w_qpTY_6VThyMPNk-Tz9lSEBUXXx-2ZclKA=w1920-h216-n", + "id": "desk" + }, + { + "colorRgb": "#f06292", + "backgroundImageLink": "https://lh5.googleusercontent.com/proxy/7Vo64b_mo3aTCFRR5JrnmwVrkeigpQuVpT0mOfsBbK_kdvyNVGY3b9CsrTj0t7E7_iMMg1g3GRltFQuCIuQ7vEUUVuWgxXgycBJhYdgAkUVoQK_Y_BwE2Yh3ng=w1920-h216-n", + "id": "donut_coffee" + }, + { + "colorRgb": "#78909c", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/aTqxoPupRaxlFYZDmlKz-ijfIYlHBPKk4ykKx_QO7P9r2HQzMlbKyPW6ZoslKMs7NMWeoFxi1sCcX_LLBop27LjO3Kd5H9_oa1UymAO_QtFHmHVrcxCNiIW2UA=w1920-h216-n", + "id": "fabric_rolls" + }, + { + "colorRgb": "#009688", + "backgroundImageLink": "https://lh5.googleusercontent.com/proxy/D3i9Q2ZRdKAbGOFcE_zEOgRv2fX07_IDsfUdRBc4Kcwz8yBySLesQtcCM8wfdDxAlX3GqUueFwBdAU2HWuDib0uFsNgikds0N-iLhgdBEHDM3Gt9=w1920-h216-n", + "id": "flags" + }, + { + "colorRgb": "#e06055", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/Gq6BmAzf26j19jOlJSFuQmFUobewCcVkInfjlXCVOCU1Sp-GuieGumKHiaK9oAOpD-NICfQJukjbqNzlCG90O0XKj0VnDR0abL2N7KCy6wIJIoIvOoqgvzCaww=w1920-h216-n", + "id": "flower_field" + }, + { + "colorRgb": "#689f38", + "backgroundImageLink": "https://lh3.googleusercontent.com/proxy/u56F0E7fTV972JarM1Q-rXAOOy-Zg-v5-Cm27-sKiV2hGdA3eeA1T9O1id4BfcuRdq46vXBbZT_tTl0JZNL4Ut0OMyh8op3IxOBGzKJpff9F7rVRCxw=w1920-h216-n", + "id": "flowers" + }, + { + "colorRgb": "#0f9d58", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/VPVLsbZj78Z8xpPMbAWjSF56mJZNw1Kyg7kN9LQ_pH6OA9z2v76rxC_8phHUXRst25qqFBRx14KxHwCDojH9ibzK3didVAx0g-uJqlb5s8-oz3ms=w1920-h216-n", + "id": "glass" + }, + { + "colorRgb": "#4285f4", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/Pwl1rZFnKYnNRcSnIMnc_TsHX0E3OqbDuNT-yy3Ms9uUUjDGgGL21EQEYhoTdCN97pTSFRB086aNass2Kfk0mYOn0lnz-Vk2MrNJ1XrDkvwLmHCnliA-nL4=w1920-h216-n", + "id": "lighthouse" + }, + { + "colorRgb": "#8d6e63", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/L8IbQigKrftSXEMsch8rXdBtZvlUiRZBfxIYiWbpp7S6oze0HZZ_QRcYP_EbEfkgZDU1QxGsVZffBzCRvhpPkgHhG53wVgj7M_nRxVZmOk-Lni0=w1920-h216-n", + "id": "maps" + }, + { + "colorRgb": "#5c6bc0", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/1EIk6eaGyGTBI-Uug-G3KCwS_kE9esUIergJ2ohfcq5fmlMIYCDLtDbJgNSbAzQ6xB8VAKiE5w5jAYk3BofnuOpz5ccrcuuHwsamC2F34WOBg2_U9CJJwg=w1920-h216-n", + "id": "mountains" + }, + { + "colorRgb": "#689f38", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/iUd07dcNVNr6BO13gIGLhyorUezYWoxRf6nSJhT6nRK_NVvP3ABZAWS7vtXSZ6Th25OJ6q-mcYcHVE8pg4WrA9fZE8oVevnyuwLEOzOVHcH4IGac0Vto=w1920-h216-n", + "id": "notebook" + }, + { + "colorRgb": "#9c27b0", + "backgroundImageLink": "https://lh5.googleusercontent.com/proxy/crERnz0f_KJZ7mN9iBmz5_AQiLGyaGNQfmu_kOocXzLChlK84r2aPp6AodqrG42sRv1yk_Og_DEuBIumug6wC6j9EcrZ1tqs6tTtH3SvtqDAkyK4MBbIMNBPAKs=w1920-h216-n", + "id": "paper_colored" + }, + { + "colorRgb": "#0097a7", + "backgroundImageLink": "https://lh5.googleusercontent.com/proxy/joaq8StlNK7Cp-apow03w_sP5HukbIrAHbZQRZJqpBhERCGYrixxXinALZ26nQ8N2o7NrR2reO4cGNJtfFnRQ9CtSnvXEjI3qM7uygrLlG3v573k71k=w1920-h216-n", + "id": "pencils" + }, + { + "colorRgb": "#039be5", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/pP_tp2yMg1wR-SzCbN9_w-mKyNXyquaaYakAvjv9hFGHGFJ6JLCvZYlpVabm-kXAaEUgg2odQ-GTZ4HyAaTOaEfPmxjYTqWyrAnGnSQ1RPMlOT2y3rtmsPF2FF0=w1920-h216-n", + "id": "roofing_metal" + }, + { + "colorRgb": "#0097a7", + "backgroundImageLink": "https://lh5.googleusercontent.com/proxy/UQ3zURt8as-FSzUcbkQQno8Dtk1oHeh38CyecfxIhSZArj6OIQ_ZTFR4sblspJxgHCKJKs4DSZB35UR4ReFEkN2SPo7OWqDRnMaz_MsMaVBXv0lw8kC_PTqfuQ=w1920-h216-n", + "id": "sticky_notes" + }, + { + "colorRgb": "#8d6e63", + "backgroundImageLink": "https://lh5.googleusercontent.com/proxy/0A5qGh2DnHThdgzOJuZymFC7vt5aYKky-QWAuFjVROgK2Bxe47CT1sz72FhocQp0L-Lro5fK5kXKW5-uyVE7f-LhgokET-_Ndhe8BRQaGKzMhgms=w1920-h216-n", + "id": "table" + }, + { + "colorRgb": "#039be5", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/eM-1oz45F6dCfOFQ2Yxr3ONAO7a549babd4jdMsBTqMErAeJ7fsk8EGPkDWi3IWoXxOA-cbftgzIDm0W7UCkepfhrONB_si1f8JfD3I0tt8IDT5hdA=w1920-h216-n", + "id": "travel" + }, + { + "colorRgb": "#ff5722", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/MZfhMLHMVQQCU6ynMhZ_G_Byd4Yk2-zzKFADDpRM33LnFr9nRha-K3Iyk07IUOaQyuOPtMPVHkQ9-q13e2tXQMaDcF6DsTCnSxJBimZAQ5thT3lU=w1920-h216-n", + "id": "waves" + }, + { + "colorRgb": "#5c6bc0", + "backgroundImageLink": "https://lh3.googleusercontent.com/proxy/3culsw3bJyewo0Ql3IiKWm3HNeT54oEzDTVgNasW_V4L0FBZ-hazADPgfmLs06VL2p8b0vSyq9JFbtChXgRBAVX3iSZJeuRF19HYMwrOakDqL3GQMl_lZZ0=w1920-h216-n", + "id": "waves_blue" + }, + { + "colorRgb": "#8d6e63", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/FzzFqxrPJvhI24W_ZIbk7TNz3AYOArCU2m0UG4FNhc_2XPXGgcoF9B8FBIz6PsIctYn8aI5NKnU1NlsjHQEpu0DsMnEG8SDNopZZnwVzcFuQ3X4=w1920-h216-n", + "id": "wood" + } + ], + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/V0zOlFcP0x2a5bbK37FCJu3Its8\"", + "largestChangeId": "82418", + "quotaBytesUsedInTrash": "562239823", + "domainSharingPolicy": "allowed", + "isCurrentAppInstalled": true, + "additionalRoleInfo": [ + { + "roleSets": [ + { + "primaryRole": "reader", + "additionalRoles": [ + "commenter" + ] + } + ], + "type": "application/vnd.google-apps.drawing" + }, + { + "roleSets": [ + { + "primaryRole": "reader", + "additionalRoles": [ + "commenter" + ] + } + ], + "type": "application/vnd.google-apps.document" + }, + { + "roleSets": [ + { + "primaryRole": "reader", + "additionalRoles": [ + "commenter" + ] + } + ], + "type": "application/vnd.google-apps.presentation" + }, + { + "roleSets": [ + { + "primaryRole": "reader", + "additionalRoles": [ + "commenter" + ] + } + ], + "type": "*" + }, + { + "roleSets": [ + { + "primaryRole": "reader", + "additionalRoles": [ + "commenter" + ] + } + ], + "type": "application/vnd.google-apps.spreadsheet" + }, + { + "roleSets": [], + "type": "application/vnd.google-apps.*" + } + ], + "user": { + "picture": { + "url": "https://lh3.googleusercontent.com/MockAccount/AAAAAAAAAAI/AAAAAAAACZk/MockAccount/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "MockAccount", + "permissionId": "07857126568572968161", + "isAuthenticatedUser": true, + "emailAddress": "MockAccount" + }, + "quotaType": "LIMITED", + "maxUploadSizes": [ + { + "type": "application/vnd.google-apps.document", + "size": "10485760" + }, + { + "type": "application/vnd.google-apps.spreadsheet", + "size": "104857600" + }, + { + "type": "application/vnd.google-apps.presentation", + "size": "104857600" + }, + { + "type": "application/vnd.google-apps.drawing", + "size": "2097152" + }, + { + "type": "application/pdf", + "size": "5242880000000" + }, + { + "type": "*", + "size": "5242880000000" + } + ], + "kind": "drive#about", + "name": "MockAccount", + "quotaBytesTotal": "18253611008", + "importFormats": [ + { + "source": "text/tab-separated-values", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/x-vnd.oasis.opendocument.presentation", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "image/jpeg", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "image/bmp", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "image/gif", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.ms-excel.sheet.macroenabled.12", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.wordprocessingml.template", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.ms-powerpoint.presentation.macroenabled.12", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "application/vnd.ms-word.template.macroenabled.12", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "image/pjpeg", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.google-apps.script+text/plain", + "targets": [ + "application/vnd.google-apps.script" + ] + }, + { + "source": "application/vnd.ms-excel", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/vnd.sun.xml.writer", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.ms-word.document.macroenabled.12", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.ms-powerpoint.slideshow.macroenabled.12", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "text/rtf", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "text/plain", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.oasis.opendocument.spreadsheet", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/x-vnd.oasis.opendocument.spreadsheet", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "image/png", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/x-vnd.oasis.opendocument.text", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/msword", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/pdf", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/json", + "targets": [ + "application/vnd.google-apps.script" + ] + }, + { + "source": "application/x-msmetafile", + "targets": [ + "application/vnd.google-apps.drawing" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.spreadsheetml.template", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/vnd.ms-powerpoint", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "application/vnd.ms-excel.template.macroenabled.12", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "image/x-bmp", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/rtf", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.presentationml.template", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "image/x-png", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "text/html", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.oasis.opendocument.text", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.presentationml.presentation", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/vnd.google-apps.script+json", + "targets": [ + "application/vnd.google-apps.script" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.presentationml.slideshow", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "application/vnd.ms-powerpoint.template.macroenabled.12", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "text/csv", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/vnd.oasis.opendocument.presentation", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "image/jpg", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "text/richtext", + "targets": [ + "application/vnd.google-apps.document" + ] + } + ], + "rootFolderId": "0AL9w2vIqdW-OUk9PVA", + "quotaBytesUsed": "593944750", + "exportFormats": [ + { + "source": "application/vnd.google-apps.document", + "targets": [ + "application/rtf", + "application/vnd.oasis.opendocument.text", + "text/html", + "application/pdf", + "application/epub+zip", + "application/zip", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "text/plain" + ] + }, + { + "source": "application/vnd.google-apps.spreadsheet", + "targets": [ + "application/x-vnd.oasis.opendocument.spreadsheet", + "text/tab-separated-values", + "application/pdf", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "text/csv", + "application/zip", + "application/vnd.oasis.opendocument.spreadsheet" + ] + }, + { + "source": "application/vnd.google-apps.jam", + "targets": [ + "application/pdf" + ] + }, + { + "source": "application/vnd.google-apps.script", + "targets": [ + "application/vnd.google-apps.script+json" + ] + }, + { + "source": "application/vnd.google-apps.presentation", + "targets": [ + "application/vnd.oasis.opendocument.presentation", + "application/pdf", + "application/vnd.openxmlformats-officedocument.presentationml.presentation", + "text/plain" + ] + }, + { + "source": "application/vnd.google-apps.form", + "targets": [ + "application/zip" + ] + }, + { + "source": "application/vnd.google-apps.drawing", + "targets": [ + "image/svg+xml", + "image/png", + "application/pdf", + "image/jpeg" + ] + } + ], + "selfLink": "https://www.googleapis.com/drive/v2/about" +} diff --git a/autotests/drive/data/about_fetch_request.txt b/autotests/drive/data/about_fetch_request.txt new file mode 100644 index 0000000..be9ba21 --- /dev/null +++ b/autotests/drive/data/about_fetch_request.txt @@ -0,0 +1 @@ +GET https://www.googleapis.com/drive/v2/about?includeSubscribed=true diff --git a/autotests/drive/data/about_fetch_response.txt b/autotests/drive/data/about_fetch_response.txt new file mode 100644 index 0000000..961e54c --- /dev/null +++ b/autotests/drive/data/about_fetch_response.txt @@ -0,0 +1,652 @@ +HTTP/1.1 200 OK +content-type: application/json; charset=UTF-8 + +{ + "languageCode": "en", + "quotaBytesByService": [ + { + "serviceName": "DRIVE", + "bytesUsed": "586253350" + }, + { + "serviceName": "PHOTOS", + "bytesUsed": "10417331" + }, + { + "serviceName": "GMAIL", + "bytesUsed": "672922405" + } + ], + "features": [ + { + "featureName": "ocr" + }, + { + "featureName": "translation", + "featureRate": 2.0 + } + ], + "folderColorPalette": [ + "#ac725e", + "#d06b64", + "#f83a22", + "#fa573c", + "#ff7537", + "#ffad46", + "#fad165", + "#fbe983", + "#b3dc6c", + "#7bd148", + "#16a765", + "#42d692", + "#92e1c0", + "#9fe1e7", + "#9fc6e7", + "#4986e7", + "#9a9cff", + "#b99aff", + "#a47ae2", + "#cd74e6", + "#f691b2", + "#cca6ac", + "#cabdbf", + "#8f8f8f" + ], + "quotaBytesUsedAggregate": "1277284486", + "permissionId": "07857126568572968161", + "teamDriveThemes": [ + { + "colorRgb": "#ea6100", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/Z5KeSUwxyWmRT9HGiVoXxqEp-KcWLSAkEgs3EgSHghCRi1_xPNFwdXbll6ivkDDqhtKabFeH1hw5fT3uDEmYDRVH3cNUXklNfZ0M8yuJ5Bwgu4w-vg=w1920-h216-n", + "id": "abacus" + }, + { + "colorRgb": "#4285f4", + "backgroundImageLink": "https://lh3.googleusercontent.com/proxy/UjEpDwYsn-r3TcmSB4k58Z-cKBa_KWgNy5F9sx-O2KGGTJXNXODqmxLJY999NCZG80WDFvs93nF3ISv_qGEiI5slt5eyoFxBCWKuFm873RZEqPy-E6GN4a8=w1920-h216-n", + "id": "blueprints" + }, + { + "colorRgb": "#689f38", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/xVkWcsvjuebP-UnWCIJp6fEqRUHwIJObjK5KawhB-ReWImKOVk5FnbhqnirdhAuZLS3VWAqnks3-3SDjhQMePR15YYfuF7stMy1R14jdcd2WyhSLex00=w1920-h216-n", + "id": "bok_choy" + }, + { + "colorRgb": "#4285f4", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/6Ok-qHt6muyfFg1x3Nd3y9M_iRUH5_aJRXq9JlTE6Z3a67qUFeVTdpLG80OBKpOtMXXffAPXtHMRkAMbzR-Q1e_dCqCntJAkV_q3U4VftNYC3k_V=w1920-h216-n", + "id": "books" + }, + { + "colorRgb": "#ef6c00", + "backgroundImageLink": "https://lh3.googleusercontent.com/proxy/laR76MvgkpxgcFyKbLRlDHThRQ4PLNNwbzuHzSr_uQAOzxCdGhLFBsdMHk_jVWlFBlLSyqODOoLkCaO_lhmu_9zB1_z81r7fPVDjVL007HcvxXHc=w1920-h216-n", + "id": "bread" + }, + { + "colorRgb": "#f06292", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/E3mV_x9XxkOnITzjKrPB0k8U1Cl6I_gqIff5aswwKAAnd7XtXCDQXgu_CMnLI8kbaPqoiqF695_eSyrp5d2Fp-OGeK-_WtpNU3LQAZNCQjYHzd1I1V-uw_Zmkco=w1920-h216-n", + "id": "bubbles_color" + }, + { + "colorRgb": "#039be5", + "backgroundImageLink": "https://lh3.googleusercontent.com/proxy/d_WN5RlW-1zH2gW_Kxj7hHqITZtlM7Zv-WlmBhdq6_43BeEHVxwCIhsqdxdWtCn2FYLH3bdPf0GeR3UCa9B2uXDrfwMOhnOaGwmJxAHLbC9K9Yp0VOg=w1920-h216-n", + "id": "circuit" + }, + { + "colorRgb": "#e91e63", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/LlctuQjxc_XPvwI_INV2KqcfflGjEreBmM2mFXp_5q24UUblES7O1yMNJYYtyMrpcvkziHO8Pyqd0OcvQyRBmNgQE3QI4vD88GMuCHPrd5E1NNl3=w1920-h216-n", + "id": "clams" + }, + { + "colorRgb": "#689f38", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/29RzK7cLA_mP_eh3Z0oAgElcC2DstGo9ujJNHecUyeoUIRbJ1npk_KhoNRtvBb5ZPVuv8dU5C5D0Ei18I_IPu_12ptLNoOioOvTAp_G9p0omV8gfHBg=w1920-h216-n", + "id": "clovers" + }, + { + "colorRgb": "#db4437", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/qVcF-uCcRs4eNsZFZHKDIiN_qdO20ifgGhQpi1t94SFzROGTb-1Kik2dbJ9_gk9G-QMawqhVQ_OVBE_5ZRAiqjhImQyfGSnnND7BEK1SiQYzRi_LpVfZnQ=w1920-h216-n", + "id": "cocktails" + }, + { + "colorRgb": "#ef6c00", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/4rVgd0sxbyBKn2AF41Xn5alyAxc0nOgDAb6y1T3FnX6vntT6QQ0m8QgUlpr2J5rYLfCF9xh2cuGV7QxRSC13Ws2kgaDuf0Iopac-ZCBF6kgg40KXyCQ=w1920-h216-n", + "id": "concert" + }, + { + "colorRgb": "#607d8b", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/UzcLkepaZHw5GeAzjagJdp7-2DGaBMcj-9TU-X3o4PD1x_kQByZO_r-RDmBxS1iLzsq_MDEq4U_3w_qpTY_6VThyMPNk-Tz9lSEBUXXx-2ZclKA=w1920-h216-n", + "id": "desk" + }, + { + "colorRgb": "#f06292", + "backgroundImageLink": "https://lh5.googleusercontent.com/proxy/7Vo64b_mo3aTCFRR5JrnmwVrkeigpQuVpT0mOfsBbK_kdvyNVGY3b9CsrTj0t7E7_iMMg1g3GRltFQuCIuQ7vEUUVuWgxXgycBJhYdgAkUVoQK_Y_BwE2Yh3ng=w1920-h216-n", + "id": "donut_coffee" + }, + { + "colorRgb": "#78909c", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/aTqxoPupRaxlFYZDmlKz-ijfIYlHBPKk4ykKx_QO7P9r2HQzMlbKyPW6ZoslKMs7NMWeoFxi1sCcX_LLBop27LjO3Kd5H9_oa1UymAO_QtFHmHVrcxCNiIW2UA=w1920-h216-n", + "id": "fabric_rolls" + }, + { + "colorRgb": "#009688", + "backgroundImageLink": "https://lh5.googleusercontent.com/proxy/D3i9Q2ZRdKAbGOFcE_zEOgRv2fX07_IDsfUdRBc4Kcwz8yBySLesQtcCM8wfdDxAlX3GqUueFwBdAU2HWuDib0uFsNgikds0N-iLhgdBEHDM3Gt9=w1920-h216-n", + "id": "flags" + }, + { + "colorRgb": "#e06055", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/Gq6BmAzf26j19jOlJSFuQmFUobewCcVkInfjlXCVOCU1Sp-GuieGumKHiaK9oAOpD-NICfQJukjbqNzlCG90O0XKj0VnDR0abL2N7KCy6wIJIoIvOoqgvzCaww=w1920-h216-n", + "id": "flower_field" + }, + { + "colorRgb": "#689f38", + "backgroundImageLink": "https://lh3.googleusercontent.com/proxy/u56F0E7fTV972JarM1Q-rXAOOy-Zg-v5-Cm27-sKiV2hGdA3eeA1T9O1id4BfcuRdq46vXBbZT_tTl0JZNL4Ut0OMyh8op3IxOBGzKJpff9F7rVRCxw=w1920-h216-n", + "id": "flowers" + }, + { + "colorRgb": "#0f9d58", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/VPVLsbZj78Z8xpPMbAWjSF56mJZNw1Kyg7kN9LQ_pH6OA9z2v76rxC_8phHUXRst25qqFBRx14KxHwCDojH9ibzK3didVAx0g-uJqlb5s8-oz3ms=w1920-h216-n", + "id": "glass" + }, + { + "colorRgb": "#4285f4", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/Pwl1rZFnKYnNRcSnIMnc_TsHX0E3OqbDuNT-yy3Ms9uUUjDGgGL21EQEYhoTdCN97pTSFRB086aNass2Kfk0mYOn0lnz-Vk2MrNJ1XrDkvwLmHCnliA-nL4=w1920-h216-n", + "id": "lighthouse" + }, + { + "colorRgb": "#8d6e63", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/L8IbQigKrftSXEMsch8rXdBtZvlUiRZBfxIYiWbpp7S6oze0HZZ_QRcYP_EbEfkgZDU1QxGsVZffBzCRvhpPkgHhG53wVgj7M_nRxVZmOk-Lni0=w1920-h216-n", + "id": "maps" + }, + { + "colorRgb": "#5c6bc0", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/1EIk6eaGyGTBI-Uug-G3KCwS_kE9esUIergJ2ohfcq5fmlMIYCDLtDbJgNSbAzQ6xB8VAKiE5w5jAYk3BofnuOpz5ccrcuuHwsamC2F34WOBg2_U9CJJwg=w1920-h216-n", + "id": "mountains" + }, + { + "colorRgb": "#689f38", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/iUd07dcNVNr6BO13gIGLhyorUezYWoxRf6nSJhT6nRK_NVvP3ABZAWS7vtXSZ6Th25OJ6q-mcYcHVE8pg4WrA9fZE8oVevnyuwLEOzOVHcH4IGac0Vto=w1920-h216-n", + "id": "notebook" + }, + { + "colorRgb": "#9c27b0", + "backgroundImageLink": "https://lh5.googleusercontent.com/proxy/crERnz0f_KJZ7mN9iBmz5_AQiLGyaGNQfmu_kOocXzLChlK84r2aPp6AodqrG42sRv1yk_Og_DEuBIumug6wC6j9EcrZ1tqs6tTtH3SvtqDAkyK4MBbIMNBPAKs=w1920-h216-n", + "id": "paper_colored" + }, + { + "colorRgb": "#0097a7", + "backgroundImageLink": "https://lh5.googleusercontent.com/proxy/joaq8StlNK7Cp-apow03w_sP5HukbIrAHbZQRZJqpBhERCGYrixxXinALZ26nQ8N2o7NrR2reO4cGNJtfFnRQ9CtSnvXEjI3qM7uygrLlG3v573k71k=w1920-h216-n", + "id": "pencils" + }, + { + "colorRgb": "#039be5", + "backgroundImageLink": "https://lh6.googleusercontent.com/proxy/pP_tp2yMg1wR-SzCbN9_w-mKyNXyquaaYakAvjv9hFGHGFJ6JLCvZYlpVabm-kXAaEUgg2odQ-GTZ4HyAaTOaEfPmxjYTqWyrAnGnSQ1RPMlOT2y3rtmsPF2FF0=w1920-h216-n", + "id": "roofing_metal" + }, + { + "colorRgb": "#0097a7", + "backgroundImageLink": "https://lh5.googleusercontent.com/proxy/UQ3zURt8as-FSzUcbkQQno8Dtk1oHeh38CyecfxIhSZArj6OIQ_ZTFR4sblspJxgHCKJKs4DSZB35UR4ReFEkN2SPo7OWqDRnMaz_MsMaVBXv0lw8kC_PTqfuQ=w1920-h216-n", + "id": "sticky_notes" + }, + { + "colorRgb": "#8d6e63", + "backgroundImageLink": "https://lh5.googleusercontent.com/proxy/0A5qGh2DnHThdgzOJuZymFC7vt5aYKky-QWAuFjVROgK2Bxe47CT1sz72FhocQp0L-Lro5fK5kXKW5-uyVE7f-LhgokET-_Ndhe8BRQaGKzMhgms=w1920-h216-n", + "id": "table" + }, + { + "colorRgb": "#039be5", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/eM-1oz45F6dCfOFQ2Yxr3ONAO7a549babd4jdMsBTqMErAeJ7fsk8EGPkDWi3IWoXxOA-cbftgzIDm0W7UCkepfhrONB_si1f8JfD3I0tt8IDT5hdA=w1920-h216-n", + "id": "travel" + }, + { + "colorRgb": "#ff5722", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/MZfhMLHMVQQCU6ynMhZ_G_Byd4Yk2-zzKFADDpRM33LnFr9nRha-K3Iyk07IUOaQyuOPtMPVHkQ9-q13e2tXQMaDcF6DsTCnSxJBimZAQ5thT3lU=w1920-h216-n", + "id": "waves" + }, + { + "colorRgb": "#5c6bc0", + "backgroundImageLink": "https://lh3.googleusercontent.com/proxy/3culsw3bJyewo0Ql3IiKWm3HNeT54oEzDTVgNasW_V4L0FBZ-hazADPgfmLs06VL2p8b0vSyq9JFbtChXgRBAVX3iSZJeuRF19HYMwrOakDqL3GQMl_lZZ0=w1920-h216-n", + "id": "waves_blue" + }, + { + "colorRgb": "#8d6e63", + "backgroundImageLink": "https://lh4.googleusercontent.com/proxy/FzzFqxrPJvhI24W_ZIbk7TNz3AYOArCU2m0UG4FNhc_2XPXGgcoF9B8FBIz6PsIctYn8aI5NKnU1NlsjHQEpu0DsMnEG8SDNopZZnwVzcFuQ3X4=w1920-h216-n", + "id": "wood" + } + ], + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/V0zOlFcP0x2a5bbK37FCJu3Its8\"", + "largestChangeId": "82418", + "quotaBytesUsedInTrash": "562239823", + "domainSharingPolicy": "allowed", + "isCurrentAppInstalled": true, + "additionalRoleInfo": [ + { + "roleSets": [ + { + "primaryRole": "reader", + "additionalRoles": [ + "commenter" + ] + } + ], + "type": "application/vnd.google-apps.drawing" + }, + { + "roleSets": [ + { + "primaryRole": "reader", + "additionalRoles": [ + "commenter" + ] + } + ], + "type": "application/vnd.google-apps.document" + }, + { + "roleSets": [ + { + "primaryRole": "reader", + "additionalRoles": [ + "commenter" + ] + } + ], + "type": "application/vnd.google-apps.presentation" + }, + { + "roleSets": [ + { + "primaryRole": "reader", + "additionalRoles": [ + "commenter" + ] + } + ], + "type": "*" + }, + { + "roleSets": [ + { + "primaryRole": "reader", + "additionalRoles": [ + "commenter" + ] + } + ], + "type": "application/vnd.google-apps.spreadsheet" + }, + { + "roleSets": [], + "type": "application/vnd.google-apps.*" + } + ], + "user": { + "picture": { + "url": "https://lh3.googleusercontent.com/MockAccount/AAAAAAAAAAI/AAAAAAAACZk/MockAccount/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "MockAccount", + "permissionId": "07857126568572968161", + "isAuthenticatedUser": true, + "emailAddress": "MockAccount" + }, + "quotaType": "LIMITED", + "maxUploadSizes": [ + { + "type": "application/vnd.google-apps.document", + "size": "10485760" + }, + { + "type": "application/vnd.google-apps.spreadsheet", + "size": "104857600" + }, + { + "type": "application/vnd.google-apps.presentation", + "size": "104857600" + }, + { + "type": "application/vnd.google-apps.drawing", + "size": "2097152" + }, + { + "type": "application/pdf", + "size": "5242880000000" + }, + { + "type": "*", + "size": "5242880000000" + } + ], + "kind": "drive#about", + "name": "MockAccount", + "quotaBytesTotal": "18253611008", + "importFormats": [ + { + "source": "text/tab-separated-values", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/x-vnd.oasis.opendocument.presentation", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "image/jpeg", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "image/bmp", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "image/gif", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.ms-excel.sheet.macroenabled.12", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.wordprocessingml.template", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.ms-powerpoint.presentation.macroenabled.12", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "application/vnd.ms-word.template.macroenabled.12", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "image/pjpeg", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.google-apps.script+text/plain", + "targets": [ + "application/vnd.google-apps.script" + ] + }, + { + "source": "application/vnd.ms-excel", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/vnd.sun.xml.writer", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.ms-word.document.macroenabled.12", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.ms-powerpoint.slideshow.macroenabled.12", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "text/rtf", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "text/plain", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.oasis.opendocument.spreadsheet", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/x-vnd.oasis.opendocument.spreadsheet", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "image/png", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/x-vnd.oasis.opendocument.text", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/msword", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/pdf", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/json", + "targets": [ + "application/vnd.google-apps.script" + ] + }, + { + "source": "application/x-msmetafile", + "targets": [ + "application/vnd.google-apps.drawing" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.spreadsheetml.template", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/vnd.ms-powerpoint", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "application/vnd.ms-excel.template.macroenabled.12", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "image/x-bmp", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/rtf", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.presentationml.template", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "image/x-png", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "text/html", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.oasis.opendocument.text", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.presentationml.presentation", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/vnd.google-apps.script+json", + "targets": [ + "application/vnd.google-apps.script" + ] + }, + { + "source": "application/vnd.openxmlformats-officedocument.presentationml.slideshow", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "application/vnd.ms-powerpoint.template.macroenabled.12", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "text/csv", + "targets": [ + "application/vnd.google-apps.spreadsheet" + ] + }, + { + "source": "application/vnd.oasis.opendocument.presentation", + "targets": [ + "application/vnd.google-apps.presentation" + ] + }, + { + "source": "image/jpg", + "targets": [ + "application/vnd.google-apps.document" + ] + }, + { + "source": "text/richtext", + "targets": [ + "application/vnd.google-apps.document" + ] + } + ], + "rootFolderId": "0AL9w2vIqdW-OUk9PVA", + "quotaBytesUsed": "593944750", + "exportFormats": [ + { + "source": "application/vnd.google-apps.document", + "targets": [ + "application/rtf", + "application/vnd.oasis.opendocument.text", + "text/html", + "application/pdf", + "application/epub+zip", + "application/zip", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document", + "text/plain" + ] + }, + { + "source": "application/vnd.google-apps.spreadsheet", + "targets": [ + "application/x-vnd.oasis.opendocument.spreadsheet", + "text/tab-separated-values", + "application/pdf", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + "text/csv", + "application/zip", + "application/vnd.oasis.opendocument.spreadsheet" + ] + }, + { + "source": "application/vnd.google-apps.jam", + "targets": [ + "application/pdf" + ] + }, + { + "source": "application/vnd.google-apps.script", + "targets": [ + "application/vnd.google-apps.script+json" + ] + }, + { + "source": "application/vnd.google-apps.presentation", + "targets": [ + "application/vnd.oasis.opendocument.presentation", + "application/pdf", + "application/vnd.openxmlformats-officedocument.presentationml.presentation", + "text/plain" + ] + }, + { + "source": "application/vnd.google-apps.form", + "targets": [ + "application/zip" + ] + }, + { + "source": "application/vnd.google-apps.drawing", + "targets": [ + "image/svg+xml", + "image/png", + "application/pdf", + "image/jpeg" + ] + } + ], + "selfLink": "https://www.googleapis.com/drive/v2/about" +} diff --git a/autotests/drive/data/change1.json b/autotests/drive/data/change1.json new file mode 100644 index 0000000..dbcdc2b --- /dev/null +++ b/autotests/drive/data/change1.json @@ -0,0 +1,9 @@ +{ + "kind": "drive#change", + "deleted": true, + "modificationDate": "2011-05-15T08:49:55.721Z", + "type": "file", + "id": "194", + "selfLink": "https://www.googleapis.com/drive/v2/changes/194", + "fileId": "1A2IfVovo1ZWC3F2Um9mUnaBkZEHccTSdsN-KfVT6gPM" +} diff --git a/autotests/drive/data/change1_fetch_request.txt b/autotests/drive/data/change1_fetch_request.txt new file mode 100644 index 0000000..69d7072 --- /dev/null +++ b/autotests/drive/data/change1_fetch_request.txt @@ -0,0 +1 @@ +GET https://www.googleapis.com/drive/v2/changes/194 diff --git a/autotests/drive/data/change1_fetch_response.txt b/autotests/drive/data/change1_fetch_response.txt new file mode 100644 index 0000000..b703b65 --- /dev/null +++ b/autotests/drive/data/change1_fetch_response.txt @@ -0,0 +1,12 @@ +HTTP/1.1 200 OK +Content-type: application/json; charset=UTF-8 + +{ + "kind": "drive#change", + "deleted": true, + "modificationDate": "2011-05-15T08:49:55.721Z", + "type": "file", + "id": "194", + "selfLink": "https://www.googleapis.com/drive/v2/changes/194", + "fileId": "1A2IfVovo1ZWC3F2Um9mUnaBkZEHccTSdsN-KfVT6gPM" +} diff --git a/autotests/drive/data/change2.json b/autotests/drive/data/change2.json new file mode 100644 index 0000000..6128ea1 --- /dev/null +++ b/autotests/drive/data/change2.json @@ -0,0 +1,9 @@ +{ + "kind": "drive#change", + "deleted": true, + "modificationDate": "2011-05-15T08:49:55.721Z", + "type": "file", + "id": "195", + "selfLink": "https://www.googleapis.com/drive/v2/changes/195", + "fileId": "0B79w2vIqdW-OYTYxZDIzM2ItZjFhZi00Mzc0LWI5YTQtNjRkZWRkMzQyNDY0" +} diff --git a/autotests/drive/data/changes_fetch_page1_request.txt b/autotests/drive/data/changes_fetch_page1_request.txt new file mode 100644 index 0000000..3f651ae --- /dev/null +++ b/autotests/drive/data/changes_fetch_page1_request.txt @@ -0,0 +1 @@ +GET https://www.googleapis.com/drive/v2/changes?includeDeleted=true&includeSubscribed=true diff --git a/autotests/drive/data/changes_fetch_page1_response.txt b/autotests/drive/data/changes_fetch_page1_response.txt new file mode 100644 index 0000000..1db75f5 --- /dev/null +++ b/autotests/drive/data/changes_fetch_page1_response.txt @@ -0,0 +1,22 @@ +HTTP/1.1 200 OK +Content-type: application/json; charset=UTF-8 + +{ + "nextPageToken": "195", + "kind": "drive#changeList", + "items": [ + { + "kind": "drive#change", + "deleted": true, + "modificationDate": "2011-05-15T08:49:55.721Z", + "type": "file", + "id": "194", + "selfLink": "https://www.googleapis.com/drive/v2/changes/194", + "fileId": "1A2IfVovo1ZWC3F2Um9mUnaBkZEHccTSdsN-KfVT6gPM" + } + ], + "nextLink": "https://www.googleapis.com/drive/v2/changes?includeDeleted=true&includeSubscribed=true&pageToken=195", + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/8HDhYeVBOHZjZye9LuD6zbiLmmQ\"", + "largestChangeId": "82418", + "selfLink": "https://www.googleapis.com/drive/v2/changes?includeDeleted=true&includeSubscribed=true" +} diff --git a/autotests/drive/data/changes_fetch_page2_request.txt b/autotests/drive/data/changes_fetch_page2_request.txt new file mode 100644 index 0000000..3a08221 --- /dev/null +++ b/autotests/drive/data/changes_fetch_page2_request.txt @@ -0,0 +1 @@ +GET https://www.googleapis.com/drive/v2/changes?includeDeleted=true&includeSubscribed=true&pageToken=195 diff --git a/autotests/drive/data/changes_fetch_page2_response.txt b/autotests/drive/data/changes_fetch_page2_response.txt new file mode 100644 index 0000000..53a9e54 --- /dev/null +++ b/autotests/drive/data/changes_fetch_page2_response.txt @@ -0,0 +1,20 @@ +HTTP/1.1 200 OK +Content-type: application/json; charset=UTF-8 + +{ + "kind": "drive#changeList", + "items": [ + { + "kind": "drive#change", + "deleted": true, + "modificationDate": "2011-05-15T08:49:55.721Z", + "type": "file", + "id": "195", + "selfLink": "https://www.googleapis.com/drive/v2/changes/195", + "fileId": "0B79w2vIqdW-OYTYxZDIzM2ItZjFhZi00Mzc0LWI5YTQtNjRkZWRkMzQyNDY0" + } + ], + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/HEzMs8SWosxvAZXeRW-19oG8bSQ\"", + "largestChangeId": "82418", + "selfLink": "https://www.googleapis.com/drive/v2/changes?includeDeleted=true&includeSubscribed=true&pageToken=195" +} diff --git a/autotests/drive/data/file1.json b/autotests/drive/data/file1.json new file mode 100644 index 0000000..1efcd30 --- /dev/null +++ b/autotests/drive/data/file1.json @@ -0,0 +1,97 @@ +{ + "mimeType": "application/vnd.google-apps.spreadsheet", + "appDataContents": false, + "thumbnailLink": "https://docs.google.com/feeds/vt?gd=true&id=someid&v=480&s=otherid&sz=s220", + "labels": { + "restricted": false, + "starred": false, + "viewed": false, + "hidden": false, + "trashed": false + }, + "explicitlyTrashed": false, + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MTUyMzM1MTc5MDUyNA\"", + "lastModifyingUserName": "John Doe", + "writersCanShare": true, + "owners": [ + { + "picture": { + "url": "https://lh4.googleusercontent.com/myfriend/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "Konqui Dev", + "permissionId": "00104958781700960159", + "isAuthenticatedUser": false, + "emailAddress": "konqui@kde.test" + } + ], + "sharedWithMeDate": "2018-03-14T13:35:25.408Z", + "sharingUser": { + "emailAddress": "john.doe@kde.test", + "kind": "drive#user", + "isAuthenticatedUser": false, + "displayName": "John Doe", + "permissionId": "00615803373363195126" + }, + "lastModifyingUser": { + "emailAddress": "john.doe@kde.test", + "kind": "drive#user", + "isAuthenticatedUser": false, + "displayName": "John Doe", + "permissionId": "0123456789" + }, + "title": "Super mega secret KDE PIM plans for world domination", + "ownerNames": [ + "Konqui Dev" + ], + "capabilities": { + "canCopy": true, + "canEdit": false + }, + "id": "abcdefghijklmnopqrstuvwxyz", + "version": "2902", + "parents": [ + { + "isRoot": false, + "kind": "drive#parentReference", + "id": "zyxwvutsrqponmlkjihgfedcba", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/parents/zyxwvutsrqponmlkjihgfedcba", + "parentLink": "https://www.googleapis.com/drive/v2/files/zyxwvutsrqponmlkjihgfedcba" + } + ], + "exportLinks": { + "application/vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=ods", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=xlsx", + "application/x-vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=ods", + "text/csv": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=csv", + "application/zip": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=zip", + "text/tab-separated-values": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=tsv", + "application/pdf": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=pdf" + }, + "shared": true, + "editable": false, + "kind": "drive#file", + "markedViewedByMeDate": "1970-01-01T00:00:00.000Z", + "modifiedDate": "2018-04-10T09:16:30.524Z", + "createdDate": "2018-01-05T11:35:58.581Z", + "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet", + "embedLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/htmlembed?ouid=116901758143213967333", + "alternateLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/edit?usp=drivesdk", + "copyable": true, + "userPermission": { + "kind": "drive#permission", + "additionalRoles": [ + "commenter" + ], + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/D7YvciIqMvsJrjPC5eirUkb-XoM\"", + "role": "reader", + "type": "user", + "id": "me", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/permissions/me" + }, + "spaces": [ + "drive" + ], + "quotaBytesUsed": "0", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz" +} diff --git a/autotests/drive/data/file1_copy.json b/autotests/drive/data/file1_copy.json new file mode 100644 index 0000000..5ff7cc6 --- /dev/null +++ b/autotests/drive/data/file1_copy.json @@ -0,0 +1,98 @@ +{ + "mimeType": "application/vnd.google-apps.spreadsheet", + "appDataContents": false, + "thumbnailLink": "https://docs.google.com/feeds/vt?gd=true&id=someid&v=480&s=otherid&sz=s220", + "labels": { + "restricted": false, + "starred": false, + "viewed": false, + "hidden": false, + "trashed": false + }, + "explicitlyTrashed": false, + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MTUyMzM1MTc5MDUyNA\"", + "lastModifyingUserName": "John Doe", + "writersCanShare": true, + "owners": [ + { + "picture": { + "url": "https://lh4.googleusercontent.com/myfriend/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "Konqui Dev", + "permissionId": "00104958781700960159", + "isAuthenticatedUser": false, + "emailAddress": "konqui@kde.test" + } + ], + "sharedWithMeDate": "2018-03-14T13:35:25.408Z", + "sharingUser": { + "emailAddress": "john.doe@kde.test", + "kind": "drive#user", + "isAuthenticatedUser": false, + "displayName": "John Doe", + "permissionId": "00615803373363195126" + }, + "lastModifyingUser": { + "emailAddress": "john.doe@kde.test", + "kind": "drive#user", + "isAuthenticatedUser": false, + "displayName": "John Doe", + "permissionId": "0123456789" + }, + "title": "Super mega secret KDE PIM plans for world domination", + "ownerNames": [ + "Konqui Dev" + ], + "capabilities": { + "canCopy": true, + "canEdit": false + }, + "id": "abcdefghijklmnopqrstuvwxyz", + "version": "2902", + "parents": [ + { + "isRoot": false, + "kind": "drive#parentReference", + "id": "completelynewparentreference", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/parents/completelynewparentreference", + "parentLink": "https://www.googleapis.com/drive/v2/files/completelynewparentreference" + } + ], + "exportLinks": { + "application/vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=ods", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=xlsx", + "application/x-vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=ods", + "text/csv": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=csv", + "application/zip": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=zip", + "text/tab-separated-values": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=tsv", + "application/pdf": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=pdf" + }, + "shared": true, + "editable": false, + "kind": "drive#file", + "markedViewedByMeDate": "1970-01-01T00:00:00.000Z", + "modifiedDate": "2018-04-10T09:16:30.524Z", + "createdDate": "2018-01-05T11:35:58.581Z", + "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet", + "embedLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/htmlembed?ouid=116901758143213967333", + "alternateLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/edit?usp=drivesdk", + "copyable": true, + "userPermission": { + "kind": "drive#permission", + "additionalRoles": [ + "commenter" + ], + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/D7YvciIqMvsJrjPC5eirUkb-XoM\"", + "role": "reader", + "type": "user", + "id": "me", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/permissions/me" + }, + "spaces": [ + "drive" + ], + "quotaBytesUsed": "0", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz" +} + diff --git a/autotests/drive/data/file1_copy_request.txt b/autotests/drive/data/file1_copy_request.txt new file mode 100644 index 0000000..e60fe06 --- /dev/null +++ b/autotests/drive/data/file1_copy_request.txt @@ -0,0 +1,40 @@ +POST https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/copy?convert=false&ocr=false&pinned=false +Content-Type: application/json + +{ + "mimeType": "application/vnd.google-apps.spreadsheet", + "thumbnailLink": "https://docs.google.com/feeds/vt?gd=true&id=someid&v=480&s=otherid&sz=s220", + "labels": { + "restricted": false, + "starred": false, + "viewed": false, + "hidden": false, + "trashed": false + }, + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MTUyMzM1MTc5MDUyNA\"", + "lastModifyingUserName": "John Doe", + "writersCanShare": true, + "sharedWithMeDate": "2018-03-14T13:35:25Z", + "title": "Super mega secret KDE PIM plans for world domination", + "ownerNames": [ + "Konqui Dev" + ], + + "id": "abcdefghijklmnopqrstuvwxyz", + "parents": [ + { + "id": "completelynewparentreference", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/parents/completelynewparentreference", + "parentLink": "https://www.googleapis.com/drive/v2/files/completelynewparentreference" + } + ], + "shared": true, + "editable": false, + "kind": "drive#file", + "modifiedDate": "2018-04-10T09:16:30Z", + "createdDate": "2018-01-05T11:35:58Z", + "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet", + "embedLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/htmlembed?ouid=116901758143213967333", + "alternateLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/edit?usp=drivesdk", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz" +} diff --git a/autotests/drive/data/file1_copy_response.txt b/autotests/drive/data/file1_copy_response.txt new file mode 100644 index 0000000..2cb54df --- /dev/null +++ b/autotests/drive/data/file1_copy_response.txt @@ -0,0 +1,102 @@ +HTTP/1.1 200 OK +content-type: application/json; charset=UTF-8 + +{ + "mimeType": "application/vnd.google-apps.spreadsheet", + "appDataContents": false, + "thumbnailLink": "https://docs.google.com/feeds/vt?gd=true&id=someid&v=480&s=otherid&sz=s220", + "labels": { + "restricted": false, + "starred": false, + "viewed": false, + "hidden": false, + "trashed": false + }, + "explicitlyTrashed": false, + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MTUyMzM1MTc5MDUyNA\"", + "lastModifyingUserName": "John Doe", + "writersCanShare": true, + "owners": [ + { + "picture": { + "url": "https://lh4.googleusercontent.com/myfriend/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "Konqui Dev", + "permissionId": "00104958781700960159", + "isAuthenticatedUser": false, + "emailAddress": "konqui@kde.test" + } + ], + "sharedWithMeDate": "2018-03-14T13:35:25.408Z", + "sharingUser": { + "emailAddress": "john.doe@kde.test", + "kind": "drive#user", + "isAuthenticatedUser": false, + "displayName": "John Doe", + "permissionId": "00615803373363195126" + }, + "lastModifyingUser": { + "emailAddress": "john.doe@kde.test", + "kind": "drive#user", + "isAuthenticatedUser": false, + "displayName": "John Doe", + "permissionId": "0123456789" + }, + "title": "Super mega secret KDE PIM plans for world domination", + "ownerNames": [ + "Konqui Dev" + ], + "capabilities": { + "canCopy": true, + "canEdit": false + }, + "id": "abcdefghijklmnopqrstuvwxyz", + "version": "2902", + "parents": [ + { + "isRoot": false, + "kind": "drive#parentReference", + "id": "completelynewparentreference", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/parents/completelynewparentreference", + "parentLink": "https://www.googleapis.com/drive/v2/files/completelynewparentreference" + } + ], + "exportLinks": { + "application/vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=ods", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=xlsx", + "application/x-vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=ods", + "text/csv": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=csv", + "application/zip": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=zip", + "text/tab-separated-values": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=tsv", + "application/pdf": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=pdf" + }, + "shared": true, + "editable": false, + "kind": "drive#file", + "markedViewedByMeDate": "1970-01-01T00:00:00.000Z", + "modifiedDate": "2018-04-10T09:16:30.524Z", + "createdDate": "2018-01-05T11:35:58.581Z", + "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet", + "embedLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/htmlembed?ouid=116901758143213967333", + "alternateLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/edit?usp=drivesdk", + "copyable": true, + "userPermission": { + "kind": "drive#permission", + "additionalRoles": [ + "commenter" + ], + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/D7YvciIqMvsJrjPC5eirUkb-XoM\"", + "role": "reader", + "type": "user", + "id": "me", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/permissions/me" + }, + "spaces": [ + "drive" + ], + "quotaBytesUsed": "0", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz" +} + + diff --git a/autotests/drive/data/file1_create_request.txt b/autotests/drive/data/file1_create_request.txt new file mode 100644 index 0000000..03d8712 --- /dev/null +++ b/autotests/drive/data/file1_create_request.txt @@ -0,0 +1,40 @@ +POST https://www.googleapis.com/drive/v2/files?convert=false&ocr=false&pinned=false&useContentAsIndexableText=false +Content-Type: application/json + +{ + "mimeType": "application/vnd.google-apps.spreadsheet", + "thumbnailLink": "https://docs.google.com/feeds/vt?gd=true&id=someid&v=480&s=otherid&sz=s220", + "labels": { + "restricted": false, + "starred": false, + "viewed": false, + "hidden": false, + "trashed": false + }, + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MTUyMzM1MTc5MDUyNA\"", + "lastModifyingUserName": "John Doe", + "writersCanShare": true, + "sharedWithMeDate": "2018-03-14T13:35:25Z", + "title": "Super mega secret KDE PIM plans for world domination", + "ownerNames": [ + "Konqui Dev" + ], + "id": "abcdefghijklmnopqrstuvwxyz", + "parents": [ + { + "id": "zyxwvutsrqponmlkjihgfedcba", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/parents/zyxwvutsrqponmlkjihgfedcba", + "parentLink": "https://www.googleapis.com/drive/v2/files/zyxwvutsrqponmlkjihgfedcba" + } + ], + "shared": true, + "editable": false, + "kind": "drive#file", + "modifiedDate": "2018-04-10T09:16:30Z", + "createdDate": "2018-01-05T11:35:58Z", + "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet", + "embedLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/htmlembed?ouid=116901758143213967333", + "alternateLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/edit?usp=drivesdk", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz" +} + diff --git a/autotests/drive/data/file1_create_response.txt b/autotests/drive/data/file1_create_response.txt new file mode 100644 index 0000000..93ff0fc --- /dev/null +++ b/autotests/drive/data/file1_create_response.txt @@ -0,0 +1,100 @@ +HTTP/1.1 200 OK +Content-Type: application/json; charset=UTF-8 + +{ + "mimeType": "application/vnd.google-apps.spreadsheet", + "appDataContents": false, + "thumbnailLink": "https://docs.google.com/feeds/vt?gd=true&id=someid&v=480&s=otherid&sz=s220", + "labels": { + "restricted": false, + "starred": false, + "viewed": false, + "hidden": false, + "trashed": false + }, + "explicitlyTrashed": false, + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MTUyMzM1MTc5MDUyNA\"", + "lastModifyingUserName": "John Doe", + "writersCanShare": true, + "owners": [ + { + "picture": { + "url": "https://lh4.googleusercontent.com/myfriend/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "Konqui Dev", + "permissionId": "00104958781700960159", + "isAuthenticatedUser": false, + "emailAddress": "konqui@kde.test" + } + ], + "sharedWithMeDate": "2018-03-14T13:35:25.408Z", + "sharingUser": { + "emailAddress": "john.doe@kde.test", + "kind": "drive#user", + "isAuthenticatedUser": false, + "displayName": "John Doe", + "permissionId": "00615803373363195126" + }, + "lastModifyingUser": { + "emailAddress": "john.doe@kde.test", + "kind": "drive#user", + "isAuthenticatedUser": false, + "displayName": "John Doe", + "permissionId": "0123456789" + }, + "title": "Super mega secret KDE PIM plans for world domination", + "ownerNames": [ + "Konqui Dev" + ], + "capabilities": { + "canCopy": true, + "canEdit": false + }, + "id": "abcdefghijklmnopqrstuvwxyz", + "version": "2902", + "parents": [ + { + "isRoot": false, + "kind": "drive#parentReference", + "id": "zyxwvutsrqponmlkjihgfedcba", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/parents/zyxwvutsrqponmlkjihgfedcba", + "parentLink": "https://www.googleapis.com/drive/v2/files/zyxwvutsrqponmlkjihgfedcba" + } + ], + "exportLinks": { + "application/vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=ods", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=xlsx", + "application/x-vnd.oasis.opendocument.spreadsheet": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=ods", + "text/csv": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=csv", + "application/zip": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=zip", + "text/tab-separated-values": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=tsv", + "application/pdf": "https://docs.google.com/spreadsheets/export?id=abcdefghijklmnopqrstuvwxyz&exportFormat=pdf" + }, + "shared": true, + "editable": false, + "kind": "drive#file", + "markedViewedByMeDate": "1970-01-01T00:00:00.000Z", + "modifiedDate": "2018-04-10T09:16:30.524Z", + "createdDate": "2018-01-05T11:35:58.581Z", + "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/application/vnd.google-apps.spreadsheet", + "embedLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/htmlembed?ouid=116901758143213967333", + "alternateLink": "https://docs.google.com/spreadsheets/d/abcdefghijklmnopqrstuvwxyz/edit?usp=drivesdk", + "copyable": true, + "userPermission": { + "kind": "drive#permission", + "additionalRoles": [ + "commenter" + ], + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/D7YvciIqMvsJrjPC5eirUkb-XoM\"", + "role": "reader", + "type": "user", + "id": "me", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz/permissions/me" + }, + "spaces": [ + "drive" + ], + "quotaBytesUsed": "0", + "selfLink": "https://www.googleapis.com/drive/v2/files/abcdefghijklmnopqrstuvwxyz" +} diff --git a/autotests/drive/data/file2.json b/autotests/drive/data/file2.json new file mode 100644 index 0000000..53a615a --- /dev/null +++ b/autotests/drive/data/file2.json @@ -0,0 +1,109 @@ +{ + "mimeType": "image/jpeg", + "appDataContents": false, + "thumbnailLink": "https://lh3.googleusercontent.com/abc123def456ghi789=s220", + "labels": { + "restricted": false, + "starred": false, + "viewed": false, + "hidden": false, + "trashed": false + }, + "explicitlyTrashed": false, + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MTUxODk3NjU5MzAyMA\"", + "lastModifyingUserName": "Konqui Dev", + "writersCanShare": true, + "owners": [ + { + "picture": { + "url": "https://lh4.googleusercontent.com/konqui/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "Konqui Dev", + "permissionId": "0987654321", + "isAuthenticatedUser": false, + "emailAddress": "konqui@kde.test" + } + ], + "id": "abc123def456ghi789", + "lastModifyingUser": { + "picture": { + "url": "https://lh4.googleusercontent.com/konqui/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "Konqui Dev", + "permissionId": "1234567890", + "isAuthenticatedUser": false, + "emailAddress": "konqui@kde.test" + }, + "title": "DSC_1287.JPG", + "ownerNames": [ + "Konqui Dev" + ], + "capabilities": { + "canCopy": true, + "canEdit": true + }, + "version": "5", + "parents": [ + { + "isRoot": false, + "kind": "drive#parentReference", + "id": "someparentfolderid", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789/parents/someparentfolderid", + "parentLink": "https://www.googleapis.com/drive/v2/files/someparentfolderid" + } + ], + "shared": true, + "originalFilename": "DSC_1287.JPG", + "webContentLink": "https://drive.google.com/uc?id=abc123def456ghi789&export=download", + "editable": true, + "embedLink": "https://drive.google.com/file/d/abc123def456ghi789/preview?usp=drivesdk", + "markedViewedByMeDate": "1970-01-01T00:00:00.000Z", + "quotaBytesUsed": "0", + "modifiedDate": "2018-02-18T17:56:33.020Z", + "createdDate": "2018-02-18T17:56:33.020Z", + "md5Checksum": "dc74e95b97efce962ac3f31a0cdecccb", + "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/image/jpeg", + "imageMediaMetadata": { + "exposureTime": 0.01, + "flashUsed": false, + "lens": "AF-S DX VR Nikkor 55-300mm 4.5-5.6G ED", + "cameraMake": "NIKON CORPORATION", + "maxApertureValue": 4.2999999999999998, + "isoSpeed": 1600, + "focalLength": 55.0, + "exposureMode": "Auto", + "colorSpace": "sRGB", + "subjectDistance": 0, + "height": 4928, + "aperture": 4.5, + "width": 3264, + "meteringMode": "Pattern", + "exposureBias": 0.0, + "date": "2018:02:18 18:05:08", + "rotation": 0, + "sensor": "One-chip color area", + "whiteBalance": "Auto", + "cameraModel": "NIKON D5100" + }, + "kind": "drive#file", + "alternateLink": "https://drive.google.com/file/d/abc123def456ghi789/view?usp=drivesdk", + "copyable": true, + "downloadUrl": "https://doc-0o-5g-docs.googleusercontent.com/docs/securesc/abc123def456ghi789?e=download&gd=true", + "userPermission": { + "kind": "drive#permission", + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MCNk4LqJxD5LuAEq7zawaLJjbNg\"", + "role": "writer", + "type": "user", + "id": "me", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789/permissions/me" + }, + "spaces": [ + "drive" + ], + "fileExtension": "JPG", + "headRevisionId": "abc123def456ghi789revisionid", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789", + "fileSize": "5106501" +} diff --git a/autotests/drive/data/file2_copy.json b/autotests/drive/data/file2_copy.json new file mode 100644 index 0000000..32054c9 --- /dev/null +++ b/autotests/drive/data/file2_copy.json @@ -0,0 +1,110 @@ +{ + "mimeType": "image/jpeg", + "appDataContents": false, + "thumbnailLink": "https://lh3.googleusercontent.com/abc123def456ghi789=s220", + "labels": { + "restricted": false, + "starred": false, + "viewed": false, + "hidden": false, + "trashed": false + }, + "explicitlyTrashed": false, + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MTUxODk3NjU5MzAyMA\"", + "lastModifyingUserName": "Konqui Dev", + "writersCanShare": true, + "owners": [ + { + "picture": { + "url": "https://lh4.googleusercontent.com/konqui/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "Konqui Dev", + "permissionId": "0987654321", + "isAuthenticatedUser": false, + "emailAddress": "konqui@kde.test" + } + ], + "id": "abc123def456ghi789", + "lastModifyingUser": { + "picture": { + "url": "https://lh4.googleusercontent.com/konqui/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "Konqui Dev", + "permissionId": "1234567890", + "isAuthenticatedUser": false, + "emailAddress": "konqui@kde.test" + }, + "title": "DSC_1287.JPG", + "ownerNames": [ + "Konqui Dev" + ], + "capabilities": { + "canCopy": true, + "canEdit": true + }, + "version": "5", + "parents": [ + { + "isRoot": false, + "kind": "drive#parentReference", + "id": "someparentfolderid", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789/parents/someparentfolderid", + "parentLink": "https://www.googleapis.com/drive/v2/files/someparentfolderid" + } + ], + "shared": true, + "originalFilename": "DSC_1287.JPG", + "webContentLink": "https://drive.google.com/uc?id=abc123def456ghi789&export=download", + "editable": true, + "embedLink": "https://drive.google.com/file/d/abc123def456ghi789/preview?usp=drivesdk", + "markedViewedByMeDate": "1970-01-01T00:00:00.000Z", + "quotaBytesUsed": "0", + "modifiedDate": "2018-02-18T17:56:33.020Z", + "createdDate": "2018-02-18T17:56:33.020Z", + "md5Checksum": "dc74e95b97efce962ac3f31a0cdecccb", + "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/image/jpeg", + "imageMediaMetadata": { + "exposureTime": 0.01, + "flashUsed": false, + "lens": "AF-S DX VR Nikkor 55-300mm 4.5-5.6G ED", + "cameraMake": "NIKON CORPORATION", + "maxApertureValue": 4.2999999999999998, + "isoSpeed": 1600, + "focalLength": 55.0, + "exposureMode": "Auto", + "colorSpace": "sRGB", + "subjectDistance": 0, + "height": 4928, + "aperture": 4.5, + "width": 3264, + "meteringMode": "Pattern", + "exposureBias": 0.0, + "date": "2018:02:18 18:05:08", + "rotation": 0, + "sensor": "One-chip color area", + "whiteBalance": "Auto", + "cameraModel": "NIKON D5100" + }, + "kind": "drive#file", + "alternateLink": "https://drive.google.com/file/d/abc123def456ghi789/view?usp=drivesdk", + "copyable": true, + "downloadUrl": "https://doc-0o-5g-docs.googleusercontent.com/docs/securesc/abc123def456ghi789?e=download&gd=true", + "userPermission": { + "kind": "drive#permission", + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MCNk4LqJxD5LuAEq7zawaLJjbNg\"", + "role": "writer", + "type": "user", + "id": "me", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789/permissions/me" + }, + "spaces": [ + "drive" + ], + "fileExtension": "JPG", + "headRevisionId": "abc123def456ghi789revisionid", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789", + "fileSize": "5106501" +} + diff --git a/autotests/drive/data/file2_copy_request.txt b/autotests/drive/data/file2_copy_request.txt new file mode 100644 index 0000000..9419708 --- /dev/null +++ b/autotests/drive/data/file2_copy_request.txt @@ -0,0 +1,43 @@ +POST https://www.googleapis.com/drive/v2/files/abc123def456ghi789/copy?convert=false&ocr=false&pinned=false +Content-Type: application/json + +{ + "mimeType": "image/jpeg", + "thumbnailLink": "https://docs.google.com/feeds/vt?gd=true&id=someid&v=480&s=otherid&sz=s220", + "labels": { + "restricted": false, + "starred": false, + "viewed": false, + "hidden": false, + "trashed": false + }, + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MTUxODk3NjU5MzAyMA\"", + "lastModifyingUserName": "Konqui Dev", + "md5Checksum": "dc74e95b97efce962ac3f31a0cdecccb", + "writersCanShare": true, + "fileExtension": "JPG", + "title": "DSC_1287.JPG", + "ownerNames": [ + "Konqui Dev" + ], + "fileSize": 5106501, + "id": "abc123def456ghi789", + "parents": [ + { + "id": "someparentfolderid", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789/parents/someparentfolderid", + "parentLink": "https://www.googleapis.com/drive/v2/files/someparentfolderid" + } + ], + "shared": true, + "kind": "drive#file", + "modifiedDate": "2018-02-18T17:56:33Z", + "createdDate": "2018-02-18T17:56:33Z", + "thumbnailLink": "https://lh3.googleusercontent.com/abc123def456ghi789=s220", + "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/image/jpeg", + "embedLink": "https://drive.google.com/file/d/abc123def456ghi789/preview?usp=drivesdk", + "alternateLink": "https://drive.google.com/file/d/abc123def456ghi789/view?usp=drivesdk", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789", + "downloadUrl": "https://doc-0o-5g-docs.googleusercontent.com/docs/securesc/abc123def456ghi789?e=download&gd=true", + "webContentLink": "https://drive.google.com/uc?id=abc123def456ghi789&export=download" +} diff --git a/autotests/drive/data/file2_copy_response.txt b/autotests/drive/data/file2_copy_response.txt new file mode 100644 index 0000000..aa5a1a6 --- /dev/null +++ b/autotests/drive/data/file2_copy_response.txt @@ -0,0 +1,113 @@ +HTTP/1.1 200 OK +content-type: application/json; charset=UTF-8 + +{ + "mimeType": "image/jpeg", + "appDataContents": false, + "thumbnailLink": "https://lh3.googleusercontent.com/abc123def456ghi789=s220", + "labels": { + "restricted": false, + "starred": false, + "viewed": false, + "hidden": false, + "trashed": false + }, + "explicitlyTrashed": false, + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MTUxODk3NjU5MzAyMA\"", + "lastModifyingUserName": "Konqui Dev", + "writersCanShare": true, + "owners": [ + { + "picture": { + "url": "https://lh4.googleusercontent.com/konqui/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "Konqui Dev", + "permissionId": "0987654321", + "isAuthenticatedUser": false, + "emailAddress": "konqui@kde.test" + } + ], + "id": "abc123def456ghi789", + "lastModifyingUser": { + "picture": { + "url": "https://lh4.googleusercontent.com/konqui/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "Konqui Dev", + "permissionId": "1234567890", + "isAuthenticatedUser": false, + "emailAddress": "konqui@kde.test" + }, + "title": "DSC_1287.JPG", + "ownerNames": [ + "Konqui Dev" + ], + "capabilities": { + "canCopy": true, + "canEdit": true + }, + "version": "5", + "parents": [ + { + "isRoot": false, + "kind": "drive#parentReference", + "id": "someparentfolderid", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789/parents/someparentfolderid", + "parentLink": "https://www.googleapis.com/drive/v2/files/someparentfolderid" + } + ], + "shared": true, + "originalFilename": "DSC_1287.JPG", + "webContentLink": "https://drive.google.com/uc?id=abc123def456ghi789&export=download", + "editable": true, + "embedLink": "https://drive.google.com/file/d/abc123def456ghi789/preview?usp=drivesdk", + "markedViewedByMeDate": "1970-01-01T00:00:00.000Z", + "quotaBytesUsed": "0", + "modifiedDate": "2018-02-18T17:56:33.020Z", + "createdDate": "2018-02-18T17:56:33.020Z", + "md5Checksum": "dc74e95b97efce962ac3f31a0cdecccb", + "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/image/jpeg", + "imageMediaMetadata": { + "exposureTime": 0.01, + "flashUsed": false, + "lens": "AF-S DX VR Nikkor 55-300mm 4.5-5.6G ED", + "cameraMake": "NIKON CORPORATION", + "maxApertureValue": 4.2999999999999998, + "isoSpeed": 1600, + "focalLength": 55.0, + "exposureMode": "Auto", + "colorSpace": "sRGB", + "subjectDistance": 0, + "height": 4928, + "aperture": 4.5, + "width": 3264, + "meteringMode": "Pattern", + "exposureBias": 0.0, + "date": "2018:02:18 18:05:08", + "rotation": 0, + "sensor": "One-chip color area", + "whiteBalance": "Auto", + "cameraModel": "NIKON D5100" + }, + "kind": "drive#file", + "alternateLink": "https://drive.google.com/file/d/abc123def456ghi789/view?usp=drivesdk", + "copyable": true, + "downloadUrl": "https://doc-0o-5g-docs.googleusercontent.com/docs/securesc/abc123def456ghi789?e=download&gd=true", + "userPermission": { + "kind": "drive#permission", + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MCNk4LqJxD5LuAEq7zawaLJjbNg\"", + "role": "writer", + "type": "user", + "id": "me", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789/permissions/me" + }, + "spaces": [ + "drive" + ], + "fileExtension": "JPG", + "headRevisionId": "abc123def456ghi789revisionid", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789", + "fileSize": "5106501" +} + diff --git a/autotests/drive/data/file2_create_request.txt b/autotests/drive/data/file2_create_request.txt new file mode 100644 index 0000000..f099130 Binary files /dev/null and b/autotests/drive/data/file2_create_request.txt differ diff --git a/autotests/drive/data/file2_create_response.txt b/autotests/drive/data/file2_create_response.txt new file mode 100644 index 0000000..d5f61fa --- /dev/null +++ b/autotests/drive/data/file2_create_response.txt @@ -0,0 +1,112 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{ + "mimeType": "image/jpeg", + "appDataContents": false, + "thumbnailLink": "https://lh3.googleusercontent.com/abc123def456ghi789=s220", + "labels": { + "restricted": false, + "starred": false, + "viewed": false, + "hidden": false, + "trashed": false + }, + "explicitlyTrashed": false, + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MTUxODk3NjU5MzAyMA\"", + "lastModifyingUserName": "Konqui Dev", + "writersCanShare": true, + "owners": [ + { + "picture": { + "url": "https://lh4.googleusercontent.com/konqui/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "Konqui Dev", + "permissionId": "0987654321", + "isAuthenticatedUser": false, + "emailAddress": "konqui@kde.test" + } + ], + "id": "abc123def456ghi789", + "lastModifyingUser": { + "picture": { + "url": "https://lh4.googleusercontent.com/konqui/s64/photo.jpg" + }, + "kind": "drive#user", + "displayName": "Konqui Dev", + "permissionId": "1234567890", + "isAuthenticatedUser": false, + "emailAddress": "konqui@kde.test" + }, + "title": "DSC_1287.JPG", + "ownerNames": [ + "Konqui Dev" + ], + "capabilities": { + "canCopy": true, + "canEdit": true + }, + "version": "5", + "parents": [ + { + "isRoot": false, + "kind": "drive#parentReference", + "id": "someparentfolderid", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789/parents/someparentfolderid", + "parentLink": "https://www.googleapis.com/drive/v2/files/someparentfolderid" + } + ], + "shared": true, + "originalFilename": "DSC_1287.JPG", + "webContentLink": "https://drive.google.com/uc?id=abc123def456ghi789&export=download", + "editable": true, + "embedLink": "https://drive.google.com/file/d/abc123def456ghi789/preview?usp=drivesdk", + "markedViewedByMeDate": "1970-01-01T00:00:00.000Z", + "quotaBytesUsed": "0", + "modifiedDate": "2018-02-18T17:56:33.020Z", + "createdDate": "2018-02-18T17:56:33.020Z", + "md5Checksum": "dc74e95b97efce962ac3f31a0cdecccb", + "iconLink": "https://drive-thirdparty.googleusercontent.com/16/type/image/jpeg", + "imageMediaMetadata": { + "exposureTime": 0.01, + "flashUsed": false, + "lens": "AF-S DX VR Nikkor 55-300mm 4.5-5.6G ED", + "cameraMake": "NIKON CORPORATION", + "maxApertureValue": 4.2999999999999998, + "isoSpeed": 1600, + "focalLength": 55.0, + "exposureMode": "Auto", + "colorSpace": "sRGB", + "subjectDistance": 0, + "height": 4928, + "aperture": 4.5, + "width": 3264, + "meteringMode": "Pattern", + "exposureBias": 0.0, + "date": "2018:02:18 18:05:08", + "rotation": 0, + "sensor": "One-chip color area", + "whiteBalance": "Auto", + "cameraModel": "NIKON D5100" + }, + "kind": "drive#file", + "alternateLink": "https://drive.google.com/file/d/abc123def456ghi789/view?usp=drivesdk", + "copyable": true, + "downloadUrl": "https://doc-0o-5g-docs.googleusercontent.com/docs/securesc/abc123def456ghi789?e=download&gd=true", + "userPermission": { + "kind": "drive#permission", + "etag": "\"bX7M5zOlGcEthti1qPHKQWp6SJA/MCNk4LqJxD5LuAEq7zawaLJjbNg\"", + "role": "writer", + "type": "user", + "id": "me", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789/permissions/me" + }, + "spaces": [ + "drive" + ], + "fileExtension": "JPG", + "headRevisionId": "abc123def456ghi789revisionid", + "selfLink": "https://www.googleapis.com/drive/v2/files/abc123def456ghi789", + "fileSize": "5106501" +} diff --git a/autotests/drive/drivetestutils.cpp b/autotests/drive/drivetestutils.cpp new file mode 100644 index 0000000..5775d8a --- /dev/null +++ b/autotests/drive/drivetestutils.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2018 Daniel Vrátil + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#include "driveservice.h" +#include "about.h" +#include "change.h" +#include "file.h" +#include "testutils.h" + +#include + +KGAPI2::Drive::AboutPtr aboutFromFile(const QString &path) +{ + QFile f(path); + VERIFY_RET(f.open(QIODevice::ReadOnly), {}); + + auto about = KGAPI2::Drive::About::fromJSON(f.readAll()); + VERIFY_RET(about, {}); + return about; +} + +KGAPI2::Drive::ChangePtr changeFromFile(const QString &path) +{ + QFile f(path); + VERIFY_RET(f.open(QIODevice::ReadOnly), {}); + + auto change = KGAPI2::Drive::Change::fromJSON(f.readAll()); + VERIFY_RET(change, {}); + return change; +} + +KGAPI2::Drive::FilePtr fileFromFile(const QString &path) +{ + QFile f(path); + VERIFY_RET(f.open(QIODevice::ReadOnly), {}); + + auto file = KGAPI2::Drive::File::fromJSON(f.readAll()); + VERIFY_RET(file, {}); + return file; +} diff --git a/autotests/drive/drivetestutils.h b/autotests/drive/drivetestutils.h new file mode 100644 index 0000000..b8ff8c9 --- /dev/null +++ b/autotests/drive/drivetestutils.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2018 Daniel Vrátil + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#ifndef DRIVETESTUTILS_H_ +#define DRIVETESTUTILS_H_ + +#include "types.h" + +KGAPI2::Drive::AboutPtr aboutFromFile(const QString &path); +KGAPI2::Drive::ChangePtr changeFromFile(const QString &path); +KGAPI2::Drive::FilePtr fileFromFile(const QString &path); + +#endif + + diff --git a/autotests/drive/filecopyjobtest.cpp b/autotests/drive/filecopyjobtest.cpp new file mode 100644 index 0000000..8bcd76b --- /dev/null +++ b/autotests/drive/filecopyjobtest.cpp @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2018 Daniel Vrátil + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#include +#include + +#include "fakenetworkaccessmanagerfactory.h" +#include "testutils.h" +#include "drivetestutils.h" + +#include "types.h" +#include "filecopyjob.h" +#include "file.h" +#include "account.h" + +using namespace KGAPI2; + +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(KGAPI2::Drive::FilesList) + +class FileCopyJobTest : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void initTestCase() + { + NetworkAccessManagerFactory::setFactory(new FakeNetworkAccessManagerFactory); + } + + void testCopy_data() + { + QTest::addColumn>("scenarios"); + QTest::addColumn("sourceFiles"); + QTest::addColumn("destinationFiles"); + QTest::addColumn("expectedCopies"); + + QTest::newRow("simple file") + << QList{ + scenarioFromFile(QFINDTESTDATA("data/file1_copy_request.txt"), + QFINDTESTDATA("data/file1_copy_response.txt")) + } + << Drive::FilesList{ fileFromFile(QFINDTESTDATA("data/file1.json")) } + << Drive::FilesList{ fileFromFile(QFINDTESTDATA("data/file1_copy.json")) } + << Drive::FilesList{ fileFromFile(QFINDTESTDATA("data/file1_copy.json")) }; + + // NOTE: The scenarios are reversed due use of QMap, which orders the files + // by ID + QTest::newRow("batch copy") + << QList{ + scenarioFromFile(QFINDTESTDATA("data/file2_copy_request.txt"), + QFINDTESTDATA("data/file2_copy_response.txt")), + scenarioFromFile(QFINDTESTDATA("data/file1_copy_request.txt"), + QFINDTESTDATA("data/file1_copy_response.txt")) + } + << Drive::FilesList{ fileFromFile(QFINDTESTDATA("data/file1.json")), + fileFromFile(QFINDTESTDATA("data/file2.json")) } + << Drive::FilesList{ fileFromFile(QFINDTESTDATA("data/file1_copy.json")), + fileFromFile(QFINDTESTDATA("data/file2_copy.json")) } + << Drive::FilesList{ fileFromFile(QFINDTESTDATA("data/file2_copy.json")), + fileFromFile(QFINDTESTDATA("data/file1_copy.json")) }; + } + + void testCopy() + { + QFETCH(QList, scenarios); + QFETCH(Drive::FilesList, sourceFiles); + QFETCH(Drive::FilesList, destinationFiles); + QFETCH(Drive::FilesList, expectedCopies); + + FakeNetworkAccessManagerFactory::get()->setScenarios(scenarios); + + auto account = AccountPtr::create(QStringLiteral("MockAccount"), QStringLiteral("MockToken")); + Drive::FileCopyJob *job = nullptr; + if (sourceFiles.count() == 1) { + job = new Drive::FileCopyJob(sourceFiles.at(0), destinationFiles.at(0), account); + } else { + QMap map; + for (auto it1 = sourceFiles.cbegin(), it2 = destinationFiles.cbegin(), end = sourceFiles.cend(); it1 != end; ++it1, ++it2) { + map.insert(*it1, *it2); + } + job = new Drive::FileCopyJob(map, account); + } + QVERIFY(execJob(job)); + const auto items = job->files(); + QCOMPARE(items.count(), expectedCopies.count()); + for (int i = 0; i < expectedCopies.count(); ++i) { + QVERIFY(items.at(i)); + QCOMPARE(*items.at(i), *expectedCopies.at(i)); + } + } +}; + +QTEST_GUILESS_MAIN(FileCopyJobTest) + +#include "filecopyjobtest.moc" + + + + diff --git a/autotests/drive/filecreatejobtest.cpp b/autotests/drive/filecreatejobtest.cpp new file mode 100644 index 0000000..27e3b6b --- /dev/null +++ b/autotests/drive/filecreatejobtest.cpp @@ -0,0 +1,107 @@ +/* + * Createright (C) 2018 Daniel Vrátil + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a create of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#include +#include + +#include "fakenetworkaccessmanagerfactory.h" +#include "testutils.h" +#include "drivetestutils.h" + +#include "types.h" +#include "filecreatejob.h" +#include "file.h" +#include "account.h" + +using namespace KGAPI2; + +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(KGAPI2::Drive::FilePtr) + +class FileCreateJobTest : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void initTestCase() + { + NetworkAccessManagerFactory::setFactory(new FakeNetworkAccessManagerFactory); + } + + void testCreate_data() + { + QTest::addColumn>("scenarios"); + QTest::addColumn("sourceFile"); + QTest::addColumn("uploadFilePath"); + QTest::addColumn("expectedResult"); + + QTest::newRow("metadata only") + << QList{ + scenarioFromFile(QFINDTESTDATA("data/file1_create_request.txt"), + QFINDTESTDATA("data/file1_create_response.txt")) + } + << fileFromFile(QFINDTESTDATA("data/file1.json")) + << QString() + << fileFromFile(QFINDTESTDATA("data/file1.json")); + + // NOTE: The scenarios are reversed due use of QMap, which orders the files + // by ID + QTest::newRow("upload") + << QList{ + scenarioFromFile(QFINDTESTDATA("data/file2_create_request.txt"), + QFINDTESTDATA("data/file2_create_response.txt")) + } + << fileFromFile(QFINDTESTDATA("data/file2.json")) + << QFINDTESTDATA("data/DSC_1287.JPG") + << fileFromFile(QFINDTESTDATA("data/file2.json")); + } + + void testCreate() + { + QFETCH(QList, scenarios); + QFETCH(Drive::FilePtr, sourceFile); + QFETCH(QString, uploadFilePath); + QFETCH(Drive::FilePtr, expectedResult); + + FakeNetworkAccessManagerFactory::get()->setScenarios(scenarios); + + auto account = AccountPtr::create(QStringLiteral("MockAccount"), QStringLiteral("MockToken")); + Drive::FileCreateJob *job = nullptr; + if (uploadFilePath.isNull()) { + job = new Drive::FileCreateJob(sourceFile, account); + } else { + job = new Drive::FileCreateJob(uploadFilePath, sourceFile, account); + } + + QVERIFY(execJob(job)); + const auto items = job->files(); + QCOMPARE(items.count(), 1); + QVERIFY(*items.cbegin()); + QCOMPARE(**items.cbegin(), *expectedResult); + } +}; + +QTEST_GUILESS_MAIN(FileCreateJobTest) + +#include "filecreatejobtest.moc" + + + + +