This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
logging.info("INCOMING XCOM MESSAGE: %s"%message) | |
logging.info("INCOMING XCOM HEADERS: %s"%str(request.META)) | |
logging.info("INCOMING XCOM REQUEST: %s"%request.POST.copy().__dict__) | |
logging.info("INCOMING XCOM REQUEST params: %s"%request.POST.copy()) | |
authorization = request.META.get('HTTP_AUTHORIZATION') | |
if authorization != settings.XCOM_RECEIVER_FABRIC_CREDENTIALS: | |
return HttpResponse("Incorrect authorization!",status=403) | |
params = dict(request.POST.copy()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2012-04-19 09:10:24,588 - django.request - ERROR - Internal Server Error: /xcom/listener/marketplace/profile/create | |
Traceback (most recent call last): | |
File "/home/deploy/.virtualenvs/sandbox.koaladeal.com/lib/python2.6/site-packages/django/core/handlers/base.py", line 111, in get_response | |
response = callback(request, *callback_args, **callback_kwargs) | |
File "/home/deploy/.virtualenvs/sandbox.koaladeal.com/lib/python2.6/site-packages/django/views/decorators/csrf.py", line 39, in wrapped_view | |
resp = view_func(*args, **kwargs) | |
File "/home/deploy/.virtualenvs/sandbox.koaladeal.com/lib/python2.6/site-packages/django/views/decorators/csrf.py", line 52, in wrapped_view | |
return view_func(*args, **kwargs) | |
File "/var/www/apps/sandbox.koaladeal.com/koaladeal_django/xcom/views.py", line 50, in listener | |
result = reader.read(decoder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a test listener for a new xcom capability | |
@csrf_exempt | |
def listener(request,message): | |
logging.info("INCOMING XCOM MESSAGE: %s"%message) | |
logging.info("INCOMING XCOM HEADERS: %s"%str(request.META)) | |
logging.info("INCOMING XCOM REQUEST: %s"%request.POST.copy().__dict__) | |
logging.info("INCOMING XCOM REQUEST params: %s"%request.POST.copy()) | |
logging.info("INCOMING RAW DATA: %s"%request.raw_post_data) | |
authorization = request.META.get('HTTP_AUTHORIZATION') | |
if authorization != settings.XCOM_RECEIVER_FABRIC_CREDENTIALS: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2012-04-19 14:37:17,890 - requests.packages.urllib3.connectionpool - INFO - Starting new HTTPS connection (1): api.x.com | |
2012-04-19 14:37:18,135 - root - INFO - schema resp is {"type":"record","name":"Ping", "version":"1.0.0", "topic":"/message/ping","namespace":"com.x.system","fields":[{"name":"payload","type":["null","string"],"default":null}]} | |
2012-04-19 14:37:18,136 - root - INFO - binary data: test | |
2012-04-19 14:37:18,136 - root - INFO - headers are {'X-XC-SCHEMA-VERSION': '1.0.0', 'Content-Type': 'avro/binary', 'X-XC-DESTINATION-ID': 'GL15hWzfFvbraOlHj/r4AJa0Jzs+Fin7wWhs1xNGUDjcvd+sToB9iBgaR8MaHEmT17tz25i8', 'Authorization': 'Bearer q9XW03JED6izYfWIORS1gFSqwiDNXLWWdZXACqLBBbbzsysr1AsLAJSf/fpHmU5W9qpMMF9k'} | |
2012-04-19 14:37:18,136 - root - INFO - posting to fabric url https://api.sandbox.x.com/message/ping | |
2012-04-19 14:37:18,137 - requests.packages.urllib3.connectionpool - INFO - Starting new HTTPS connection (1): api.sandbox.x.com | |
2012-04-19 14:37:18,366 - root - INFO - sender response is <fault> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def auth1(): | |
headers = {'X-PAYPAL-SECURITY-USERID':PAYPAL_API_USERNAME,'X-PAYPAL-SECURITY-PASSWORD':PAYPAL_API_PASSWORD,'X-PAYPAL-SECURITY-SIGNATURE':PAYPAL_API_SIGNATURE,'X-PAYPAL-APPLICATION-ID':'APP-80W284485P519543T','X-PAYPAL-REQUEST-DATA-FORMAT':'NV','X-PAYPAL-RESPONSE-DATA-FORMAT':'JSON'} | |
url = 'https://svcs.sandbox.paypal.com/Permissions/RequestPermissions' | |
payload="requestEnvelope.errorLanguage=en_US&scope=EXPRESS_CHECKOUT&callback=http://simplerelevance.com" | |
resp = requests.post(url,headers=headers,data=payload,config=m) | |
print resp.content | |
print resp.status_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_card(): | |
test_email='eli_1335983746_per@simplerelevance.com' | |
headers = {"X-PAYPAL-SECURITY-USERID":PAYPAL_API_USERNAME,"X-PAYPAL-SECURITY-PASSWORD":PAYPAL_API_PASSWORD,"X-PAYPAL-SECURITY-SIGNATURE":PAYPAL_API_SIGNATURE,"X-PAYPAL-APPLICATION-ID":"APP-80W284485P519543T","X-PAYPAL-REQUEST-DATA-FORMAT":"NV","X-PAYPAL-RESPONSE-DATA-FORMAT":"JSON"} | |
payload = { | |
'requestEnvelope.errorLanguage':'en_US', | |
'emailAddress':test_email, | |
'cardNumber':'5178054152614319', | |
'cardType':'MasterCard', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_email='eli_1335983746_per@simplerelevance.com' | |
headers = {"X-PAYPAL-SECURITY-USERID":PAYPAL_API_USERNAME,"X-PAYPAL-SECURITY-PASSWORD":PAYPAL_API_PASSWORD,"X-PAYPAL-SECURITY-SIGNATURE":PAYPAL_API_SIGNATURE,"X-PAYPAL-APPLICATION-ID":"APP-80W284485P519543T","X-PAYPAL-REQUEST-DATA-FORMAT":"NV","X-PAYPAL-RESPONSE-DATA-FORMAT":"JSON"} | |
payload = { | |
'requestEnvelope.errorLanguage':'en_US', | |
'emailAddress':test_email, | |
'cardNumber':'5178059152624418', | |
'cardType':'MasterCard', | |
'confirmationType':'WEB', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Exercise: Knows why we "Don't trust the developer" | |
- Developers are a tricksey bunch. Name some reasons why you shouldn't just trust the person who wrote the code. | |
I understand the thinking here. It's easy to write code and be really proud of it, which means you wouldn't necessarily notice issues with the code. Easy to be blinded by pride, or arrogance kind of thing. | |
- Name some mental pitfalls that you should watch out for when testing code. | |
I think all developers should try to stay in the testing mindset. It's always broken. It's never perfect. Strive for excellence, expect bugs. So the pitfall is the "it's done" mindset. | |
- So then, why shouldn't we be satisfied with testing our own code? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shopping Cart | |
You need some exercise in writing test plans. I've got the cure for what ails you. Write a test plan for a basic shopping cart. Make sure to include Happy Path, Sad Path and Bad Path in your tests. | |
It can be helpful to use something like the Cucumber syntax for this, but you don't need to write the entire implementation this time. You're welcome. | |
Requirements | |
The shopping cart behaves a lot like every other cart you've seen on the internet. We're not shooting for the stars on this one. | |
I should be able to add, remove, and change quantities on items in my cart. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The idea behind writing the code you want to see is to plan both your code and your tests as if you were a stakeholder / business owner, rather than a machine. Generally programmers who don't do this think of the task from a highlevel, then jump straight into the heart of the domain and start coding what they think it should be like. Then they jump out a level or two and write tests. But those tests are now only indirectly related to the high level view. | |
Outside in means writing the tests first, with the high level business requirements fresh in your mind, and then jumping in to write various pieces of the application incrementally, such that each peice of code is written in direct response with a failing test to make it pass. | |
The advantage here is that the final logic of the code itself will be more directly informed by the business logic, and will adhere more closely with the business requirements. There is a high chance that the code design will be better thought out and more clearly related to the busine |