1285 lines
37 KiB
Plaintext
1285 lines
37 KiB
Plaintext
{
|
|
"metadata": {
|
|
"name": "",
|
|
"signature": "sha256:a177051d6f70704c58665f861ab819ee6543ec82b33ce8532d9fd4adeed98fc1"
|
|
},
|
|
"nbformat": 3,
|
|
"nbformat_minor": 0,
|
|
"worksheets": [
|
|
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"To do this testing, I'd ultimately like to automate a workflow. Right now, I'll do a combo of scripted actions and manual clicking."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"!pip show selenium"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stdout",
|
|
"text": [
|
|
"---\r\n",
|
|
"Metadata-Version: 1.1\r\n",
|
|
"Name: selenium\r\n",
|
|
"Version: 2.45.0\r\n",
|
|
"Summary: Python bindings for Selenium\r\n",
|
|
"Home-page: http://code.google.com/p/selenium/\r\n",
|
|
"Author: UNKNOWN\r\n",
|
|
"Author-email: UNKNOWN\r\n",
|
|
"License: UNKNOWN\r\n",
|
|
"Location: /Users/raymondyee/anaconda/envs/regluit478/lib/python2.7/site-packages\r\n",
|
|
"Requires: \r\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 1
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"%%bash\n",
|
|
"\n",
|
|
"../sysadmin/drop_tables.sh | django-admin.py dbshell\n",
|
|
"cat ../test/campaign_starter.sql | django-admin.py dbshell"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stderr",
|
|
"text": [
|
|
"Warning: Using a password on the command line interface can be insecure.\n",
|
|
"Warning: Using a password on the command line interface can be insecure.\n",
|
|
"Warning: Using a password on the command line interface can be insecure.\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 2
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"%%bash\n",
|
|
"django-admin.py migrate default 0001 --fake\n",
|
|
"django-admin.py syncdb --migrate --noinput"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stdout",
|
|
"text": [
|
|
" - Soft matched migration 0001 to 0001_initial.\n",
|
|
"Running migrations for default:\n",
|
|
" - Migrating forwards to 0001_initial.\n",
|
|
" > default:0001_initial\n",
|
|
" (faked)\n",
|
|
"Syncing...\n",
|
|
"Creating tables ...\n",
|
|
"Creating table email_change_emailchangerequest\n",
|
|
"Installing custom SQL ...\n",
|
|
"Installing indexes ...\n",
|
|
"Installed 0 object(s) from 0 fixture(s)\n",
|
|
"Migrating...\n",
|
|
"Running migrations for django_extensions:\n",
|
|
" - Migrating forwards to 0001_empty.\n",
|
|
" > django_extensions:0001_empty\n",
|
|
" - Loading initial data for django_extensions.\n",
|
|
"Installed 0 object(s) from 0 fixture(s)\n",
|
|
"Running migrations for core:\n",
|
|
" - Migrating forwards to 0071_auto__chg_field_userprofile_facebook_id.\n",
|
|
" > core:0037_auto__add_field_edition_cover_image\n",
|
|
" > core:0038_auto__chg_field_campaign_description__chg_field_campaign_details__add_\n",
|
|
" > core:0039_auto__del_field_ebook_unglued__add_field_edition_unglued\n",
|
|
" > core:0040_auto__add_badge\n",
|
|
" > core:0041_auto\n",
|
|
" > core:0042_auto__add_field_userprofile_avatar_source\n",
|
|
" > core:0043_auto__add_publishername__add_publisher__add_field_campaign_email__add_\n",
|
|
" > core:0044_pubname_to_model\n",
|
|
" - Migration 'core:0044_pubname_to_model' is marked for no-dry-run.\n",
|
|
" > core:0045_auto__del_field_edition_publisher\n",
|
|
" > core:0046_auto__add_press\n",
|
|
" > core:0047_auto__add_field_ebook_download_count\n",
|
|
" > core:0048_auto__add_field_userprofile_kindle_email\n",
|
|
" > core:0049_auto__add_libpref__add_marcrecord\n",
|
|
" > core:0050_auto__add_ebookfile__add_offer__add_field_campaign_dollar_per_day__add\n",
|
|
" > core:0051_auto__add_acq\n",
|
|
" > core:0052_auto__add_field_acq_watermarked\n",
|
|
" > core:0053_auto__add_field_acq_nonce\n",
|
|
" > core:0054_auto__del_field_marcrecord_xml_record__del_field_marcrecord_mrc_record\n",
|
|
" > core:0055_auto__add_field_acq_refreshes__add_field_acq_lib_acq\n",
|
|
" > core:0056_auto__add_hold__add_field_acq_refreshed\n",
|
|
" > core:0057_auto__add_field_campaign_do_watermark\n",
|
|
" > core:0058_auto__chg_field_campaign_deadline\n",
|
|
" > core:0059_auto__add_field_work_selected_edition__add_field_work_earliest_publica\n",
|
|
" > core:0060_auto__chg_field_work_language\n",
|
|
" > core:0061_auto__add_field_work_featured\n",
|
|
" > core:0062_auto\n",
|
|
" > core:0063_auto__add_field_campaign_use_add_ask__add_field_ebookfile_asking\n",
|
|
" > core:0064_auto__add_field_ebook_active\n",
|
|
" > core:0065_auto__chg_field_identifier_value\n",
|
|
" > core:0066_auto__del_marcrecord\n",
|
|
" > core:0067_auto__add_field_work_is_free\n",
|
|
" > core:0068_auto__add_gift\n",
|
|
" > core:0069_auto__add_field_subject_is_visible\n",
|
|
" - Migration 'core:0069_auto__add_field_subject_is_visible' is marked for no-dry-run.\n",
|
|
" > core:0070_auto__add_field_ebook_filesize\n",
|
|
" > core:0071_auto__chg_field_userprofile_facebook_id\n",
|
|
" - Loading initial data for core.\n",
|
|
"Installed 12 object(s) from 1 fixture(s)\n",
|
|
"Running migrations for marc:\n",
|
|
" - Migrating forwards to 0002_auto__add_field_marcrecord_user__add_field_marcrecord_created.\n",
|
|
" > marc:0001_initial\n",
|
|
" > marc:0002_auto__add_field_marcrecord_user__add_field_marcrecord_created\n",
|
|
" - Loading initial data for marc.\n",
|
|
"Installed 0 object(s) from 0 fixture(s)\n",
|
|
"Running migrations for payment:\n",
|
|
" - Migrating forwards to 0018_auto.\n",
|
|
" > payment:0007_auto__add_field_transaction_host\n",
|
|
" > payment:0008_auto__add_credit__add_creditlog__del_field_transaction_target__del_fie\n",
|
|
" - Migration 'payment:0008_auto__add_credit__add_creditlog__del_field_transaction_target__del_fie' is marked for no-dry-run.\n",
|
|
" > payment:0009_auto__add_sent__add_field_creditlog_sent\n",
|
|
" > payment:0010_auto__add_account\n",
|
|
" > payment:0011_auto__add_field_account_card_last4__add_field_account_card_type__add_f\n",
|
|
" > payment:0012_auto__chg_field_account_date_created\n",
|
|
" > payment:0013_auto__add_field_account_status\n",
|
|
" > payment:0014_init_account_status\n",
|
|
" - Migration 'payment:0014_init_account_status' is marked for no-dry-run.\n",
|
|
" > payment:0015_auto__chg_field_account_status__add_field_transaction_extra\n",
|
|
" > payment:0016_jsonify\n",
|
|
" - Migration 'payment:0016_jsonify' is marked for no-dry-run.\n",
|
|
" > payment:0017_auto__del_field_transaction_ack_name__del_field_transaction_ack_dedica\n",
|
|
" > payment:0018_auto\n",
|
|
" - Loading initial data for payment.\n",
|
|
"Installed 0 object(s) from 0 fixture(s)\n",
|
|
"Running migrations for default:\n",
|
|
"- Nothing to migrate.\n",
|
|
" - Loading initial data for default.\n",
|
|
"Installed 0 object(s) from 0 fixture(s)\n",
|
|
"Running migrations for tastypie:\n",
|
|
"- Nothing to migrate.\n",
|
|
" - Loading initial data for tastypie.\n",
|
|
"Installed 0 object(s) from 0 fixture(s)\n",
|
|
"Running migrations for djcelery:\n",
|
|
" - Migrating forwards to 0004_v30_changes.\n",
|
|
" > djcelery:0002_v25_changes\n",
|
|
" > djcelery:0003_v26_changes\n",
|
|
" > djcelery:0004_v30_changes\n",
|
|
" - Loading initial data for djcelery.\n",
|
|
"Installed 0 object(s) from 0 fixture(s)\n",
|
|
"Running migrations for booxtream:\n",
|
|
" - Migrating forwards to 0001_initial.\n",
|
|
" > booxtream:0001_initial\n",
|
|
" - Loading initial data for booxtream.\n",
|
|
"Installed 0 object(s) from 0 fixture(s)\n",
|
|
"Running migrations for libraryauth:\n",
|
|
" - Migrating forwards to 0003_auto__add_field_library_name__add_field_library_approved__add_field_li.\n",
|
|
" > libraryauth:0001_initial\n",
|
|
" > libraryauth:0002_auto__add_emailpattern\n",
|
|
" > libraryauth:0003_auto__add_field_library_name__add_field_library_approved__add_field_li\n",
|
|
" - Loading initial data for libraryauth.\n",
|
|
"Installed 0 object(s) from 0 fixture(s)\n",
|
|
"\n",
|
|
"Synced:\n",
|
|
" > django.contrib.auth\n",
|
|
" > django.contrib.contenttypes\n",
|
|
" > django.contrib.sessions\n",
|
|
" > django.contrib.sites\n",
|
|
" > django.contrib.sitemaps\n",
|
|
" > django.contrib.messages\n",
|
|
" > django.contrib.staticfiles\n",
|
|
" > django.contrib.comments\n",
|
|
" > django.contrib.humanize\n",
|
|
" > south\n",
|
|
" > regluit.frontend\n",
|
|
" > regluit.api\n",
|
|
" > registration\n",
|
|
" > endless_pagination\n",
|
|
" > selectable\n",
|
|
" > notification\n",
|
|
" > email_change\n",
|
|
" > ckeditor\n",
|
|
" > storages\n",
|
|
" > django.contrib.admin\n",
|
|
" > djkombu\n",
|
|
"\n",
|
|
"Migrated:\n",
|
|
" - django_extensions\n",
|
|
" - regluit.core\n",
|
|
" - regluit.marc\n",
|
|
" - regluit.payment\n",
|
|
" - social.apps.django_app.default\n",
|
|
" - tastypie\n",
|
|
" - djcelery\n",
|
|
" - regluit.booxtream\n",
|
|
" - regluit.libraryauth\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 3
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"from selenium import selenium, webdriver\n",
|
|
"from selenium.webdriver.support.ui import WebDriverWait\n",
|
|
"from selenium.common.exceptions import NoSuchElementException\n",
|
|
"from regluit.test import campaigntest\n",
|
|
"s = campaigntest.test_relaunch(unglue_it_url = 'http://127.0.0.1:8000', do_local=True, browser='firefox')\n",
|
|
"sel = s.next()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stdout",
|
|
"text": [
|
|
"now opening unglue.it\n",
|
|
"yes: Error in just hitting pledge button as expected"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stdout",
|
|
"text": [
|
|
"\n",
|
|
"making $10 pledge\n",
|
|
"http://127.0.0.1:8000/fund/complete/?tid=1"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stdout",
|
|
"text": [
|
|
" None\n",
|
|
"clicking Modify Pledge button"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stdout",
|
|
"text": [
|
|
"\n",
|
|
"changing pledge to $5 -- should not need to go to Stripe"
|
|
]
|
|
},
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stdout",
|
|
"text": [
|
|
"\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 4
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"from django.contrib.auth.models import User\n",
|
|
"\n",
|
|
"from regluit.core.models import (RightsHolder, Work, Campaign, Claim)\n",
|
|
"\n",
|
|
"from regluit.core.parameters import (\n",
|
|
" REWARDS,\n",
|
|
" BUY2UNGLUE,\n",
|
|
" THANKS,\n",
|
|
" INDIVIDUAL,\n",
|
|
" LIBRARY,\n",
|
|
" BORROWED,\n",
|
|
" TESTING,\n",
|
|
" RESERVE,\n",
|
|
")\n",
|
|
"\n",
|
|
"from regluit.core import bookloader\n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 5
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# create rdhyeetest\n",
|
|
"\n",
|
|
"rdhyeetest = User.objects.filter(username='rdhyeetest')[0]\n",
|
|
"rdhyeetest"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 6,
|
|
"text": [
|
|
"<User: rdhyeetest>"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 6
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# rh\n",
|
|
"\n",
|
|
"rh = RightsHolder(email=\"raymond.yee@dataunbound.com\", \n",
|
|
" rights_holder_name=\"RY Inc\", \n",
|
|
" owner_id=rdhyeetest.id, \n",
|
|
" can_sell=True)\n",
|
|
"\n",
|
|
"rh.save()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 7
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# let's add PW2.0 book\n",
|
|
"\n",
|
|
"e = bookloader.add_by_isbn(isbn='9781430202868')\n",
|
|
"e"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stderr",
|
|
"text": [
|
|
"/Users/raymondyee/anaconda/envs/regluit/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.\n",
|
|
" InsecurePlatformWarning\n"
|
|
]
|
|
},
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 8,
|
|
"text": [
|
|
"<Edition: Pro Web 2.0 Mashups (ISBN 9781430202868) Apress>"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 8
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"w = e.work\n",
|
|
"w.id"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 9,
|
|
"text": [
|
|
"52L"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 9
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Manual interaction as RH\n",
|
|
"\n",
|
|
"I ran up to this point and then I'm going to do manual interactions as RH "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# Programmatic: now get rdhyeetest to lay claim to book\n",
|
|
"\n",
|
|
"claim = Claim(rights_holder_id=rh.id,\n",
|
|
" work_id=w.id,\n",
|
|
" user_id=rdhyeetest.id,\n",
|
|
" status='pending')\n",
|
|
"claim.save()\n",
|
|
"claim\n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 10,
|
|
"text": [
|
|
"<Claim: Pro Web 2.0 Mashups>"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 10
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# explicitly set claim to be active\n",
|
|
"\n",
|
|
"claim.status = 'active'\n",
|
|
"claim.save()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 11
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# reload claim from db\n",
|
|
"\n",
|
|
"claim = Claim.objects.get(id=claim.id)\n",
|
|
"claim.status"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 12,
|
|
"text": [
|
|
"u'active'"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 12
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"I went to http://127.0.0.1:8000/work/52/# and hit the the Claim as RY Inc. I had to agree to terms...and hit \"Confirm Claim\".\n",
|
|
"\n",
|
|
"I then end up at http://127.0.0.1:8000/rightsholders/"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# now create the Campaign\n",
|
|
"\n",
|
|
"campaign = Campaign(name=\"Pro Web 2.0 Mashups\",\n",
|
|
" type=BUY2UNGLUE\n",
|
|
" )\n",
|
|
"\n",
|
|
"# tie work\n",
|
|
"\n",
|
|
"campaign.work = w\n",
|
|
"campaign.save()\n",
|
|
" "
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 13
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"campaign.managers.add(rdhyeetest)\n",
|
|
"campaign.save()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 14
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"#campaign.update_left()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 15
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# go to RH tools\n",
|
|
"sel.get(\"http://127.0.0.1:8000/rightsholders/\")"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 16
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"manage_this_campaign_link = WebDriverWait(sel, 100).until(lambda d : d.find_element_by_css_selector(\"div.work_campaigns:nth-child(1) > div:nth-child(2) > a:nth-child(1)\"))\n",
|
|
"manage_this_campaign_link.click() "
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 17
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"What has to happen next:\n",
|
|
"\n",
|
|
"* select main edition\n",
|
|
"* set revenue target ($1000)\n",
|
|
"* initial unglueing date: Jan 1, 2030\n",
|
|
"* pitch required: \"Buy this book for the sake of humanity!\"\n",
|
|
"* email contact: raymond.yee@dataunbound.com\n",
|
|
"\n",
|
|
"Then load a book\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"By this point, user can go to http://127.0.0.1:8000/work/52/?tab=1# and see link to [Edit this edition/Add ebook](http://127.0.0.1:8000/new_edition/52/52). But there doesn't seem to be a link to add editions."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# pick main edition: id_edition_1\n",
|
|
"sel.current_url\n",
|
|
"id_edition_1_link = WebDriverWait(sel, 100).until(lambda d : d.find_element_by_id(\"id_edition_1\"))\n",
|
|
"id_edition_1_link.click()\n",
|
|
"\n",
|
|
"# #id_target\n",
|
|
"sel.execute_script(\"\"\"document.getElementById(\"id_target\").value=\"1000.00\";\"\"\")\n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 18
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# http://stackoverflow.com/a/6435526/7782\n",
|
|
"# #id_cc_date_initial_month\n",
|
|
"# #id_cc_date_initial_day\n",
|
|
"# #id_cc_date_initial_year\n",
|
|
"\n",
|
|
"## this date selection sometime works....\n",
|
|
"#my_sel = sel.find_element_by_id(\"id_cc_date_initial_month\")\n",
|
|
"#my_sel.click()\n",
|
|
"##month_selector.find_element_by_css_selector(\"option[value='1']\").click()\n",
|
|
"#my_sel.find_element_by_xpath(\"option[contains(text(),'January')]\").click()\n",
|
|
"#\n",
|
|
"#my_sel = sel.find_element_by_id(\"id_cc_date_initial_day\")\n",
|
|
"#my_sel.click()\n",
|
|
"##month_selector.find_element_by_css_selector(\"option[value='1']\").click()\n",
|
|
"#my_sel.find_element_by_xpath(\"option[contains(text(),'1')]\").click()\n",
|
|
"#\n",
|
|
"#my_sel = sel.find_element_by_id(\"id_cc_date_initial_year\")\n",
|
|
"#my_sel.click()\n",
|
|
"##month_selector.find_element_by_css_selector(\"option[value='1']\").click()\n",
|
|
"#my_sel.find_element_by_xpath(\"option[contains(text(),'2030')]\").click()\n",
|
|
"\n",
|
|
"sel.execute_script(\"\"\"\n",
|
|
" document.querySelector(\"#id_cc_date_initial_month option[value='1']\").selected = true;\n",
|
|
"\"\"\");\n",
|
|
"\n",
|
|
"sel.execute_script(\"\"\"\n",
|
|
" document.querySelector(\"#id_cc_date_initial_day option[value='1']\").selected = true;\n",
|
|
"\"\"\");\n",
|
|
"\n",
|
|
"sel.execute_script(\"\"\"\n",
|
|
" document.querySelector(\"#id_cc_date_initial_year option[value='2030']\").selected = true;\n",
|
|
"\"\"\");\n",
|
|
"\n",
|
|
"# http://stackoverflow.com/a/2629130\n",
|
|
"# fill in description\n",
|
|
"sel.execute_script(\"\"\"CKEDITOR.instances['id_description'].setData('\"Buy this book for the sake of humanity!');\"\"\")\n",
|
|
"\n",
|
|
"# contact email\n",
|
|
"sel.execute_script(\"\"\"document.getElementById(\"id_paypal_receiver\").value=\"raymond.yee@dataunbound.com\";\"\"\")\n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 19
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# save campaign info\n",
|
|
"sel.find_element_by_xpath(\"//input[@value='Save Campaign']\").click()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 20
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# http://127.0.0.1:8000/rightsholders/campaign/52/#"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 21
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# hit Description Tab\n",
|
|
"sel.find_element_by_xpath(\"//a[text()='Description']\").click()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 22
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# click on Load a file link\n",
|
|
"\n",
|
|
"sel.find_element_by_xpath(\"//a[contains(text(),'Load a file')]\").click()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 23
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# send the path to the filepicker for uploading\n",
|
|
"# http://stackoverflow.com/a/10472542/7782 \n",
|
|
"# http://127.0.0.1:8000/rightsholders/edition/52/upload/\n",
|
|
"import os\n",
|
|
"test_epub = os.path.join(os.getcwd(), \"../test-data/pg2701.epub\")\n",
|
|
"\n",
|
|
"id_file_link = WebDriverWait(sel, 100).until(lambda d : d.find_element_by_id(\"id_file\"))\n",
|
|
"id_file_link.send_keys(test_epub)\n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 24
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# submit the epub\n",
|
|
"sel.find_element_by_id(\"submit_file\").click()\n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 25
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# when we arrive back\n",
|
|
"# http://127.0.0.1:8000/rightsholders/edition/52/upload/#\n",
|
|
"\n",
|
|
"ebook_file_link = WebDriverWait(sel, 100).until(lambda d : d.find_element_by_css_selector(\".js-main-container-inner > ul:nth-child(3) > li:nth-child(1)\"))\n",
|
|
"\n",
|
|
"#ebook_file = sel.find_element_by_css_selector(\".js-main-container-inner > ul:nth-child(3) > li:nth-child(1) > a:nth-child(1)\")\n",
|
|
"print ebook_file_link.text"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"output_type": "stream",
|
|
"stream": "stdout",
|
|
"text": [
|
|
"ebf/af467b4cfe787cdd4aa2196d872138ff.epub created June 3, 2015, 10:16 a.m.\n"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 26
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# Campaign needs to be launched\n",
|
|
"# hit the Manage this campaign link\n",
|
|
"\n",
|
|
"sel.find_element_by_xpath(\"//a[text()='Manage this campaign']\").click()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 27
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# hit the launch button\n",
|
|
"# sel.find_element_by_xpath(\"//a[text()='Description']\").click()\n",
|
|
"launch_tab = WebDriverWait(sel, 100).until(lambda d:d.find_element_by_xpath(\"//a[text()='Launch']\"))\n",
|
|
"launch_tab.click()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 28
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# hit the launch button\n",
|
|
"\n",
|
|
"launch_button = WebDriverWait(sel, 100).until(lambda d:d.find_element_by_xpath(\"//a[text()='Launch Campaign']\"))\n",
|
|
"launch_button.click()\n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 29
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# time to log out and login as another user to do purchase\n",
|
|
"\n",
|
|
"sel.get(\"http://127.0.0.1:8000/accounts/logout/\")\n",
|
|
"\n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 30
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Stuff to test\n",
|
|
"\n",
|
|
"* as anonymous user, make a payment....see that the total updates properly"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# make a new user for test\n",
|
|
"\n",
|
|
"TEST_USER = 'yee-example'\n",
|
|
"TEST_EMAIL = 'yee@example.org'\n",
|
|
"TEST_PW = 'mayW3allD0Well_'\n",
|
|
"\n",
|
|
"user1 = User.objects.create_user(TEST_USER, TEST_EMAIL, TEST_PW)\n",
|
|
"user1.save()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 31
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# sign in\n",
|
|
"\n",
|
|
"# long wait because sel is slow after PayPal\n",
|
|
"sign_in_link = WebDriverWait(sel, 100).until(lambda d : d.find_element_by_xpath(\"//span[contains(text(),'Sign In')]/..\"))\n",
|
|
"sign_in_link.click()\n",
|
|
"\n",
|
|
"# enter unglue.it login info\n",
|
|
"input_username = WebDriverWait(sel,20).until(lambda d : d.find_element_by_css_selector(\"input#id_username\"))\n",
|
|
"input_username.send_keys(TEST_USER)\n",
|
|
"sel.find_element_by_css_selector(\"input#id_password\").send_keys(TEST_PW)\n",
|
|
"sel.find_element_by_css_selector(\"input[value*='Sign in with Password']\").click() \n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 32
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Then what I did by hand:\n",
|
|
"\n",
|
|
"* did a single purchase and confirmed that generated epub, mobi file ok\n",
|
|
"* ran retotal management command to retotal Campaign.left amounts -- needed because payment webhook not wired on laptop...in a test, will have to look up stripe events and feed to webhook \n",
|
|
"\n",
|
|
"* waiting on Eric to tell me whether there's something automatic after a successful b2u campaign: https://github.com/Gluejar/regluit/pull/292#issuecomment-36406477 --> answer: it seems like we can \n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"MAKE_CAMPAIGN_SUCCEED = False\n",
|
|
"\n",
|
|
"if MAKE_CAMPAIGN_SUCCEED:\n",
|
|
" \n",
|
|
" import datetime\n",
|
|
" \n",
|
|
" campaign = Campaign.objects.get(id=campaign.id)\n",
|
|
" \n",
|
|
" campaign.cc_date_initial = datetime.datetime.today()-datetime.timedelta(days=1)\n",
|
|
" campaign.save()\n",
|
|
" \n",
|
|
" campaign.update_status()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 33
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Also need to look at t4u uploading:\n",
|
|
"\n",
|
|
" T4u upload has improved validation for mobi and ePub. \n",
|
|
" \n",
|
|
"I also have a PDF ready.\n",
|
|
"\n",
|
|
"I simulate by adding the John Eliot Gardiner *Bach: Music in the Castle* ISBN:9780375415296 and then creating a t4u account -> http://127.0.0.1:8000/work/53/"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "heading",
|
|
"level": 1,
|
|
"metadata": {},
|
|
"source": [
|
|
"PR 315 specific functionality"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"oh...we need a b2u campaign."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Let me remind myself:\n",
|
|
"\n",
|
|
"* which account is an admin account? `raymond.yee@gmail.com` (which I can login using 2-step auth -- not friendly to automated testing)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"One specific library in production. \n",
|
|
"\n",
|
|
" * library 4 has owner_id of 34: `abbot`.\n",
|
|
" * User 4351 is `sausalitolibrary` with `email` of `achambers@ci.sausalito.ca.us`"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"sel.current_url"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 34,
|
|
"text": [
|
|
"u'http://127.0.0.1:8000/supporter/yee-example/'"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 34
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# now go to the libraries/create page\n",
|
|
"\n",
|
|
"sel.get(\"http://127.0.0.1:8000/libraryauth/create/\")"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 35
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"library_name_input = WebDriverWait(sel,20).until(lambda d : d.find_element_by_css_selector(\"input#id_name\"))\n",
|
|
"library_name_input.send_keys(\"RY Library\")"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 36
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"sel.find_element_by_id(\"id_username\").send_keys(\"rylibrary\")"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 37
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"sel.execute_script(\"\"\"document.getElementById(\"id_email\").value=\"rylibrary@example.org\";\"\"\")\n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 38
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# configure an email pattern check.\n",
|
|
"\n",
|
|
"sel.execute_script(\"\"\"\n",
|
|
" document.querySelector(\"#id_backend option[value='email']\").selected = true;\n",
|
|
"\"\"\");"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 39
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"sel.find_element_by_id(\"submit\").click()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 40
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# now should be at http://127.0.0.1:8000/libraryauth/{library_id}/admin/\n",
|
|
"\n",
|
|
"save_pattern = WebDriverWait(sel,20).until(lambda d : d.find_element_by_css_selector(\"input#id_new-pattern\"))\n",
|
|
"save_pattern.send_keys(\"@example.org\")"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 41
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"sel.find_element_by_id(\"auth_submit_None\").click()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 42
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# now the library has to be verified\n",
|
|
"\n",
|
|
"from regluit.libraryauth.models import Library\n",
|
|
"\n",
|
|
"lib = Library.objects.get(name=\"RY Library\")\n",
|
|
"lib.approved = True\n",
|
|
"lib.save()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 43
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# let's walk through other stuff quickly\n",
|
|
"\n",
|
|
"* login as rylibrary: "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"sel.find_element_by_xpath(\"//a[contains(text(),'rylibrary')]\").click()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 44
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# go to PW camapaign\n",
|
|
"\n",
|
|
"sel.get(\"http://127.0.0.1:8000/work/52/\")"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 45
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"sel.find_element_by_xpath(\"//input[@value='Purchase']\").click()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 46
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# there are options to pick...for now\n",
|
|
"sel.find_element_by_xpath(\"//input[@id='pledgesubmit']\").click()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 47
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# enter CC\n",
|
|
"\n",
|
|
"sel.execute_script(\"\"\"document.getElementById(\"card_Number\").value=\"4242424242424242\";\"\"\")\n",
|
|
"sel.execute_script(\"\"\"document.getElementById(\"card_CVC\").value=\"321\";\"\"\")\n",
|
|
"sel.execute_script(\"\"\"document.getElementById(\"card_ExpiryMonth\").value=\"01\";\"\"\")\n",
|
|
"sel.execute_script(\"\"\"document.getElementById(\"card_ExpiryYear\").value=\"18\";\"\"\")\n"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 48
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"sel.find_element_by_xpath(\"//input[@id='cc_submit']\").click()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 49
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"....."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "heading",
|
|
"level": 1,
|
|
"metadata": {},
|
|
"source": [
|
|
"Why is there a borrow button?"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"from regluit.core.models import Work\n",
|
|
"from django.contrib.auth.models import User\n",
|
|
"\n",
|
|
"w = Work.objects.get(id=52)\n",
|
|
"user = User.objects.get(username=\"yee-example\")\n",
|
|
"\n",
|
|
"w.borrowable(user)"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 50,
|
|
"text": [
|
|
"False"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 50
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"from regluit.libraryauth.models import (Library, LibraryUser)\n",
|
|
"\n",
|
|
"Library.objects.all()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 51,
|
|
"text": [
|
|
"[<Library: RY Library>]"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 51
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"LibraryUser.objects.all()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"metadata": {},
|
|
"output_type": "pyout",
|
|
"prompt_number": 52,
|
|
"text": [
|
|
"[<LibraryUser: LibraryUser object>, <LibraryUser: LibraryUser object>]"
|
|
]
|
|
}
|
|
],
|
|
"prompt_number": 52
|
|
},
|
|
{
|
|
"cell_type": "heading",
|
|
"level": 1,
|
|
"metadata": {},
|
|
"source": [
|
|
"Testing \\$0 /\\$0 for t4u campaign"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [
|
|
"# create through instantiating directly or\n",
|
|
"# through UI\n",
|
|
"\n",
|
|
"from regluit.core import models\n",
|
|
"t4u_campaign = models.Campaign()"
|
|
],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 53
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 53
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"collapsed": false,
|
|
"input": [],
|
|
"language": "python",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"prompt_number": 53
|
|
}
|
|
],
|
|
"metadata": {}
|
|
}
|
|
]
|
|
} |