-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test the initial version of the app #6
Comments
Let's do the installationhttps://github.com/zoka123/gsheet-to-xml/blob/master/DOCUMENTATION.md#installation
Check my version of PHP
On my MacOS navigate to my projects folder
Done. The
So, that shows our command as:
|
Sort out the G API connectionsGoogle API Setup
Interesting I did not realise you could do that on free Gmail. You can.
Done.
Done. Where is the recommended place to put that highly sensitive file??? I guess I store it in my home directory maybe. The 'Learn more' prompt links through to: Understanding Service Accounts > Managing service account keys. It has lots of recommendations on how to manage the files.
Done. I saved the secret in my home folder:
I took screen grab of the steps as I went along. |
Usage
|
Let's try it. First, I tried with the absolute path to the client_secret. We got a beautiful error to say credentials could not be found. Good to see nice error handling. Then, I tried it with a relative path from the current working directory to a Google Sheet. This worked a beaut! Lovely! $ pwd
/Users/x/Documents/Projects/XmlAuthoring/gsheet-to-xml
$ php bin/console.php forikal:gsheet-to-xml https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522 --credentials=../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Products>
<Product>
<Inventory src-sheet="https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522" src-tab="InventoryTab">
<StockItem>
<KNumberExists>true</KNumberExists>
<KNumber>1111111</KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber></AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>baz</Name>
<Purposes>
<Purpose>11</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
<StockItem>
<KNumberExists>false</KNumberExists>
<KNumber></KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber>foo</AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>bar</Name>
<Purposes>
<Purpose>2</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
</Inventory>
</Product>
</Products>
$
|
I am so pleased. :) |
Let's see it act on a Drive folder. $ pwd
/Users/x/Documents/Projects/XmlAuthoring/gsheet-to-xml
$ php bin/console.php forikal:gsheet-to-xml https://drive.google.com/drive/folders/12UzI416pEoDzIb5-AeuYJZAF6hhKKdbx?usp=sharing --credentials=../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Products>
<Product src-spreadsheet="1ApDJhRGqDS64tVbQygkERJ_CC05KsI_Utq-maeBxklM">
<Inventory src-sheet="https://drive.google.com/drive/folders/12UzI416pEoDzIb5-AeuYJZAF6hhKKdbx?usp=sharing" src-tab="SomeOtherInventoryTab">
<StockItem>
<KNumberExists>true</KNumberExists>
<KNumber>9999999</KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber></AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>baz</Name>
<Purposes>
<Purpose>22</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>11</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
<StockItem>
<KNumberExists>false</KNumberExists>
<KNumber></KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber>bar</AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>bar</Name>
<Purposes>
<Purpose>3</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>11</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
</Inventory>
</Product>
<Product src-spreadsheet="1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM">
<Inventory src-sheet="https://drive.google.com/drive/folders/12UzI416pEoDzIb5-AeuYJZAF6hhKKdbx?usp=sharing" src-tab="InventoryTab">
<StockItem>
<KNumberExists>true</KNumberExists>
<KNumber>1111111</KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber></AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>baz</Name>
<Purposes>
<Purpose>11</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
<StockItem>
<KNumberExists>false</KNumberExists>
<KNumber></KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber>foo</AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>bar</Name>
<Purposes>
<Purpose>2</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
</Inventory>
</Product>
</Products>
$
Yes that works. I note that the |
# to do I would like to set up some Google Files to act as Test Fixtures to test the various Behaviours
Test Fixtures Folder:Let's make one:
|
So that Fixture folder has: $ pwd
/Users/x/Documents/Projects/XmlAuthoring/gsheet-to-xml
$ php bin/console.php forikal:gsheet-to-xml https://drive.google.com/drive/folders/1pgdgRTKQYfMVc1-Kg29FifW-RebwN2Wq?usp=sharing --credentials=../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Products>
<Product src-spreadsheet="1hdKksm6Xj6SiL3r8paCzlW2gBMRnm445ZBflUL-591M">
<Inventory src-sheet="https://drive.google.com/drive/folders/1pgdgRTKQYfMVc1-Kg29FifW-RebwN2Wq?usp=sharing" src-tab="InventoryTab">
<StockItem>
<KNumberExists>true</KNumberExists>
<KNumber>1111111</KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber></AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>baz</Name>
<Purposes>
<Purpose>11</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
<StockItem>
<KNumberExists>false</KNumberExists>
<KNumber></KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber>foo</AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>bar</Name>
<Purposes>
<Purpose>2</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
</Inventory>
</Product>
<Product src-spreadsheet="17BmFwI3yDuHtcGL9uFKkxXHWHD0Mp-TPVp8btG81iQU">
<Inventory src-sheet="https://drive.google.com/drive/folders/1pgdgRTKQYfMVc1-Kg29FifW-RebwN2Wq?usp=sharing" src-tab="InventoryTab">
<StockItem>
<KNumberExists>true</KNumberExists>
<KNumber>1111111</KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber></AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>baz</Name>
<Purposes>
<Purpose>11</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
<StockItem>
<KNumberExists>false</KNumberExists>
<KNumber></KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber>foo</AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>bar</Name>
<Purposes>
<Purpose>2</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
</Inventory>
</Product>
<Product src-spreadsheet="1Y-rtreSasax15UZ5xQwD48Ou8bVhdQfZOGoq4NxXRLE">
<Inventory src-sheet="https://drive.google.com/drive/folders/1pgdgRTKQYfMVc1-Kg29FifW-RebwN2Wq?usp=sharing" src-tab="InventoryTab">
<StockItem>
<KNumberExists>true</KNumberExists>
<KNumber>1111111</KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber></AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>baz</Name>
<Purposes>
<Purpose>11</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
<StockItem>
<KNumberExists>false</KNumberExists>
<KNumber></KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber>foo</AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>bar</Name>
<Purposes>
<Purpose>2</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
</Inventory>
</Product>
</Products>
$
|
OK it is not so easy to work out which file is which. The |
Let's run some unit tests
$ ./vendor/bin/phpunit
PHPUnit 7.2-g4e1f80765 by Sebastian Bergmann and contributors.
..... 5 / 5 (100%)
Time: 163 ms, Memory: 4.00MB
OK (5 tests, 23 assertions)
$ Nice. |
Let's look at the tests: |
FinallyI like how @zoka123 has added a Resource section at the bottom of the docs. Nice touch. |
... to this page. I saved loads of screen grabs during the process and noted location at: xmlsquad/gsheet-to-xml#6 (comment)
Zoka123 has made some fixes, so let's review this again. |
$ php bin/gsheet-to-xml.php --help
Usage:
forikal:gsheet-to-xml [options] [--] <drive-url>
Arguments:
drive-url The URL of the Google Drive entity (Google Sheet or Google Drive folder). is-recursive: if the Google Drive entity is a Google Drive folder, this option specifies whether or not to recurse through sub-directories to find sheets.
Options:
-c, --credentials[=CREDENTIALS] Path to the Google credentials JSON relative to the current working directory [default: "client_secret.json"]
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
Fetch and convert Google Drive Folder / Sheets to XML.
|
I notice that the drive-url description says:
So the I wonder if the |
I did not notice that bug in my spec the first time I tested the software. Doh! |
OK. Let's test those behaviours Do a call to pick up one file first: $ pwd
/Users/x/Documents/Projects/XmlAuthoring/gsheet-to-xml
$ php bin/gsheet-to-xml.php forikal:gsheet-to-xml https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522 --credentials=../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json
Too many arguments, expected arguments "drive-url".
forikal:gsheet-to-xml [-c|--credentials [CREDENTIALS]] [--] <drive-url>
Try with the options before the argument: $ php bin/gsheet-to-xml.php forikal:gsheet-to-xml --credentials=../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522
Too many arguments, expected arguments "drive-url".
forikal:gsheet-to-xml [-c|--credentials [CREDENTIALS]] [--] <drive-url> try with speachmarks $ php bin/gsheet-to-xml.php forikal:gsheet-to-xml --credentials="../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json" https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522
Too many arguments, expected arguments "drive-url".
forikal:gsheet-to-xml [-c|--credentials [CREDENTIALS]] [--] <drive-url> |
## Try without the command name. $ php bin/gsheet-to-xml.php --credentials="../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json" https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Products>
<Product>
<Inventory src-sheet="DocumentationSampleSheet" src-sheet-url="https://docs.google.com/spreadsheets/d/1_SnGKyXjHnsdylZw_YYIQ8HuxYQI-hsvxYQpftGMjpM/edit#gid=311423522" src-tab="InventoryTab">
<StockItem>
<KNumberExists>true</KNumberExists>
<KNumber>1111111</KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber></AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>baz</Name>
<Purposes>
<Purpose>11</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
<StockItem>
<KNumberExists>false</KNumberExists>
<KNumber></KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber>foo</AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>bar</Name>
<Purposes>
<Purpose>2</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
</Inventory>
</Product>
</Products> OK so that worked. So, I guess, the I will need to gain a better understanding of how Symfony commands are designed to be either combined into a suite of commands for a console or 'standalone'. Either way we need to update the example invocation in the docs. |
Check the Xml is written correctlyI have gone through the result of the previous command in the comment above and compared it against the sample source sheet. At the current time of writing the mapping from gsheet to xml in the above command is perfect. So the test passes. |
Let's try the command on a Drive folder.$ php bin/gsheet-to-xml.php --credentials="../../../../APIKeys/gsheet-to-xml-e5eaf708560f.json" https://drive.google.com/drive/u/0/folders/1pgdgRTKQYfMVc1-Kg29FifW-RebwN2Wq
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Products>
<Product>
<Inventory src-sheet="_GoodSheet" src-sheet-url="https://docs.google.com/spreadsheets/d/1hdKksm6Xj6SiL3r8paCzlW2gBMRnm445ZBflUL-591M/" src-tab="InventoryTabA">
<StockItem>
<KNumberExists>true</KNumberExists>
<KNumber>1111111</KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber></AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>baz</Name>
<Purposes>
<Purpose>11</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
<StockItem>
<KNumberExists>false</KNumberExists>
<KNumber></KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber>foo</AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>bar</Name>
<Purposes>
<Purpose>2</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
</Inventory>
</Product>
<Product>
<Inventory src-sheet="_GoodSheet" src-sheet-url="https://docs.google.com/spreadsheets/d/1hdKksm6Xj6SiL3r8paCzlW2gBMRnm445ZBflUL-591M/" src-tab="InventoryTabB">
<StockItem>
<KNumberExists>true</KNumberExists>
<KNumber>5555555</KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber></AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>baz</Name>
<Purposes>
<Purpose>5</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>55</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
<StockItem>
<KNumberExists>false</KNumberExists>
<KNumber></KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber>_GoodSheet > InventoryTabB</AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>bar</Name>
<Purposes>
<Purpose>5</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>55</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
</Inventory>
</Product>
<Product>
<Inventory src-sheet="EmptyRowsSkippedWithoutNotice" src-sheet-url="https://docs.google.com/spreadsheets/d/17BmFwI3yDuHtcGL9uFKkxXHWHD0Mp-TPVp8btG81iQU/" src-tab="InventoryTab">
<StockItem>
<KNumberExists>true</KNumberExists>
<KNumber>1111111</KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber></AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>baz</Name>
<Purposes>
<Purpose>11</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
<StockItem>
<KNumberExists>false</KNumberExists>
<KNumber></KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber>foo</AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>bar</Name>
<Purposes>
<Purpose>2</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
</Inventory>
</Product>
<Product>
<Inventory src-sheet="TabEndingInUnderscore" src-sheet-url="https://docs.google.com/spreadsheets/d/1Y-rtreSasax15UZ5xQwD48Ou8bVhdQfZOGoq4NxXRLE/" src-tab="InventoryTab">
<StockItem>
<KNumberExists>true</KNumberExists>
<KNumber>1111111</KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber></AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>baz</Name>
<Purposes>
<Purpose>11</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
<StockItem>
<KNumberExists>false</KNumberExists>
<KNumber></KNumber>
<AdditionalKNumbers></AdditionalKNumbers>
<AlternativeNumber>foo</AlternativeNumber>
<InventoryContainerID></InventoryContainerID>
<Name>bar</Name>
<Purposes>
<Purpose>2</Purpose>
</Purposes>
<PurposeOther></PurposeOther>
<InventoryQuantity>99</InventoryQuantity>
<HandlingStatus></HandlingStatus>
<SupplierRegistrationNumber></SupplierRegistrationNumber>
</StockItem>
</Inventory>
</Product>
</Products> |
Manual test assertions - passI have used the, above, result to test the Behaviours listed on the Documentation page:
|
I wrote notes as I tested the former version of this commit. See: #6 (comment)
Run tests again$ ./vendor/bin/phpunit
PHPUnit 7.3-g2629ff118 by Sebastian Bergmann and contributors.
..... 5 / 5 (100%)
Time: 136 ms, Memory: 4.00MB
OK (5 tests, 23 assertions) OK Good. |
OK. So, I think we have got it working ok whilst meticulously added Issues for all improvements that I'd like to see. |
Goal
Test the initial version of the app
Why
Zoka123 has done a pull request so let's see it running and iron out any issues.
How
The text was updated successfully, but these errors were encountered: