1) updated settings/dev.py to reflect new parameters needed for python-social-auth
2) added an IPython notebook to run Selenium testpull/1/head
parent
4944df8e78
commit
b61a4a0e0c
|
@ -0,0 +1,913 @@
|
||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"name": "",
|
||||||
|
"signature": "sha256:43220ba4174d20ea589ccb449390d432b422f6276af8ab8ef1f5b770b185dcea"
|
||||||
|
},
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"# create rdhyeetest\n",
|
||||||
|
"\n",
|
||||||
|
"rdhyeetest = User.objects.filter(username='rdhyeetest')[0]\n",
|
||||||
|
"rdhyeetest"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"w = e.work\n",
|
||||||
|
"w.id"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"# explicitly set claim to be active\n",
|
||||||
|
"\n",
|
||||||
|
"claim.status = 'active'\n",
|
||||||
|
"claim.save()"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"campaign.managers.add(rdhyeetest)\n",
|
||||||
|
"campaign.save()"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"#campaign.update_left()"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"# go to RH tools\n",
|
||||||
|
"sel.get(\"http://127.0.0.1:8000/rightsholders/\")"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"# save campaign info\n",
|
||||||
|
"sel.find_element_by_xpath(\"//input[@value='Save Campaign']\").click()"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"# http://127.0.0.1:8000/rightsholders/campaign/52/#"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"# hit Description Tab\n",
|
||||||
|
"sel.find_element_by_xpath(\"//a[text()='Description']\").click()"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"# submit the epub\n",
|
||||||
|
"sel.find_element_by_id(\"submit_file\").click()\n"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"sel.find_element_by_id(\"id_username\").send_keys(\"rylibrary\")"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"sel.execute_script(\"\"\"document.getElementById(\"id_email\").value=\"rylibrary@example.org\";\"\"\")\n"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"sel.find_element_by_id(\"submit\").click()"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"sel.find_element_by_id(\"auth_submit_None\").click()"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"sel.find_element_by_xpath(\"//input[@value='Purchase']\").click()"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"sel.find_element_by_xpath(\"//input[@id='cc_submit']\").click()"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"from regluit.libraryauth.models import (Library, LibraryUser)\n",
|
||||||
|
"\n",
|
||||||
|
"Library.objects.all()"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [
|
||||||
|
"LibraryUser.objects.all()"
|
||||||
|
],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"collapsed": false,
|
||||||
|
"input": [],
|
||||||
|
"language": "python",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -45,54 +45,33 @@ DEFAULT_FROM_EMAIL = 'info@gluejar.com'
|
||||||
# you'll need to create a new Twitter application to fill in these blanks
|
# you'll need to create a new Twitter application to fill in these blanks
|
||||||
# https://dev.twitter.com/apps/new
|
# https://dev.twitter.com/apps/new
|
||||||
|
|
||||||
TWITTER_CONSUMER_KEY = ''
|
SOCIAL_AUTH_TWITTER_KEY = ''
|
||||||
TWITTER_CONSUMER_SECRET = ''
|
SOCIAL_AUTH_TWITTER_SECRET = ''
|
||||||
|
|
||||||
# facebook auth
|
# facebook auth
|
||||||
# you'll need to create a new Facebook application to fill in these blanks
|
# you'll need to create a new Facebook application to fill in these blanks
|
||||||
# https://developers.facebook.com/apps/
|
# https://developers.facebook.com/apps/
|
||||||
|
|
||||||
FACEBOOK_APP_ID = ''
|
SOCIAL_AUTH_FACEBOOK_KEY = ''
|
||||||
FACEBOOK_API_SECRET = ''
|
SOCIAL_AUTH_FACEBOOK_SECRET = ''
|
||||||
|
|
||||||
|
# get these (as oauth2 client ID and Secret from
|
||||||
|
# https://console.developers.google.com/project/569579163337/apiui/credential?authuser=1
|
||||||
|
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
|
||||||
|
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
|
||||||
|
|
||||||
# google auth
|
|
||||||
# you'll need to create a new Google application to fill in these blanks
|
|
||||||
# https://code.google.com/apis/console/
|
|
||||||
GOOGLE_OAUTH2_CLIENT_ID = ''
|
|
||||||
GOOGLE_OAUTH2_CLIENT_SECRET = ''
|
|
||||||
GOOGLE_DISPLAY_NAME = 'unglue it!'
|
|
||||||
|
|
||||||
# you'll need to register a GoogleBooks API key
|
# you'll need to register a GoogleBooks API key
|
||||||
# https://code.google.com/apis/console
|
# https://code.google.com/apis/console
|
||||||
GOOGLE_BOOKS_API_KEY = ''
|
GOOGLE_BOOKS_API_KEY = ''
|
||||||
|
|
||||||
# Payment processor switch
|
# Payment processor switch
|
||||||
PAYMENT_PROCESSOR = 'amazon'
|
PAYMENT_PROCESSOR = 'stripelib'
|
||||||
|
|
||||||
# set -- sandbox or production Amazon FPS?
|
# set -- sandbox or production Amazon FPS?
|
||||||
AMAZON_FPS_HOST = "fps.sandbox.amazonaws.com"
|
AMAZON_FPS_HOST = "fps.sandbox.amazonaws.com"
|
||||||
#AMAZON_FPS_HOST = "fps.amazonaws.com"
|
#AMAZON_FPS_HOST = "fps.amazonaws.com"
|
||||||
|
|
||||||
PAYPAL_USERNAME = ''
|
|
||||||
PAYPAL_PASSWORD = ''
|
|
||||||
PAYPAL_SIGNATURE = ''
|
|
||||||
PAYPAL_APPID = ''
|
|
||||||
|
|
||||||
PAYPAL_ENDPOINT = 'svcs.sandbox.paypal.com' # sandbox
|
|
||||||
PAYPAL_PAYMENT_HOST = 'http://www.sandbox.paypal.com' # sandbox
|
|
||||||
|
|
||||||
PAYPAL_SANDBOX_LOGIN = ''
|
|
||||||
PAYPAL_SANDBOX_PASSWORD = ''
|
|
||||||
|
|
||||||
PAYPAL_BUYER_LOGIN =''
|
|
||||||
PAYPAL_BUYER_PASSWORD = ''
|
|
||||||
|
|
||||||
# in live system, replace with the real Gluejar paypal email and that for our non-profit partner
|
|
||||||
PAYPAL_GLUEJAR_EMAIL = "glueja_1317336101_biz@gluejar.com"
|
|
||||||
PAYPAL_NONPROFIT_PARTNER_EMAIL = "nppart_1318957063_per@gluejar.com"
|
|
||||||
|
|
||||||
# for test purposes have a single RH paypal email
|
|
||||||
PAYPAL_TEST_RH_EMAIL = "rh1_1317336251_biz@gluejar.com"
|
|
||||||
|
|
||||||
BASE_URL = 'http://0.0.0.0'
|
BASE_URL = 'http://0.0.0.0'
|
||||||
BASE_URL_SECURE = 'https://0.0.0.0'
|
BASE_URL_SECURE = 'https://0.0.0.0'
|
||||||
|
|
|
@ -199,7 +199,7 @@ def test_relaunch(unglue_it_url = settings.LIVE_SERVER_TEST_URL, do_local=True,
|
||||||
input_username = WebDriverWait(sel,20).until(lambda d : d.find_element_by_css_selector("input#id_username"))
|
input_username = WebDriverWait(sel,20).until(lambda d : d.find_element_by_css_selector("input#id_username"))
|
||||||
input_username.send_keys(USER)
|
input_username.send_keys(USER)
|
||||||
sel.find_element_by_css_selector("input#id_password").send_keys(PASSWORD)
|
sel.find_element_by_css_selector("input#id_password").send_keys(PASSWORD)
|
||||||
sel.find_element_by_css_selector("input[value*='Sign In']").click()
|
sel.find_element_by_css_selector("input[value*='Sign in with Password']").click()
|
||||||
|
|
||||||
# click on biggest campaign list
|
# click on biggest campaign list
|
||||||
# I have no idea why selenium thinks a is not displayed....so that's why I'm going up one element.
|
# I have no idea why selenium thinks a is not displayed....so that's why I'm going up one element.
|
||||||
|
|
Loading…
Reference in New Issue