6.11 Testing the Delivery Processor
With the Python script written and either (or both)
FedEx and UPS customer accounts and web developer API keys
registered, we can now proceed with running the sketch and listener
script through a functional test. Load a valid, recent FedEx or UPS
tracking number into the trackingstatus
table in the packagedelivery
database. To do this, you can
use the same SQLite Manager plug-in for Firefox that was used to
create the database tables. Simply select SQLite Manager from
Firefox’s Tools menu, then open the packagedelivery.sqlite
file. Click the
trackingstatus
table listed in the
left column area, followed by the Browse & Search tab. Lastly,
click the Edit button to add/modify the tracking number
record(s).
Conversely, if you prefer the faster (though less
visually stimulating) sqlite3
command-line interface, add your own tracking number(s) via the
following SQL statement (remembering, of course, to replace the
YOURTRACKINGNUM placeholder with a valid FedEx or UPS tracking
number):
sqlite> INSERT
INTO
tracking("tracking_number","description","delivery_status")\ |
|
VALUES
("YOURTRACKINGNUM", "My Package Being
Tracked","0"); |
Quickly check that the record was indeed correctly
added to the tracking
table with a
simple select statement:
sqlite> select
* from tracking; |
|
1|YOURTRACKINGNUM|My Package Being
Tracked|0| |
Add any other valid FedEx or UPS tracking numbers as well to test the iterative lookup functionality that was coded into the Python script. For the purposes of this test, tracking numbers don’t have to only be those for packages in transit. In fact, it’s best to have a mix of both in-transit and delivered packages to verify that the script correctly updated only those packages with tracking numbers that have a confirmed delivery status.
The moment of truth has arrived. Power up the
Arduino/XBee package delivery hardware. Make sure the receiving
XBee is plugged into your computer via the FTDI cable and execute
the python packagedelivery.py
command. Press firmly on the force sensitive resistor and wait for
the script to process the tracking number queries. If everything
worked successfully, you should have received an email from the
Gmail account you used for the SMTP gateway that listed all
confirmed package deliveries. You can also execute another
select * from tracking;
query from the
sqlite3
command line to verify
that the boolean delivered
field has
been changed from 0 (false) to 1 (true), and that the appropriate
time stamp (indicating when the package was actually delivered) was
recorded in the deliver_time
field.
If the script failed or if the values were not
properly stored, reset the records in the tracking
table and use a variety of debugging
approaches with the script (the easiest being the venerable
print()
function) to determine where
problems are arising in the script’s execution.
Once the tests have successfully and repeatedly passed, we’re ready to install the hardware configuration outdoors in a convenient location close to a power outlet.