Skip to content

Instantly share code, notes, and snippets.

View PritishC's full-sized avatar

Pritish Chakraborty PritishC

View GitHub Profile
class TestLNTemplates(TestTemplates):
"""
Runs webshop template tests for LN.
"""
def get_app(self):
"""
Gets the app object.
Sets LN template path.
"""
if address_response.AddressValidationResult.Quality < 0.4:
cls.raise_user_error('The address entered was invalid.')
elif (address_response.AddressValidationResult.Quality >= 0.4)
and (address_response.AddressValidationResult.Quality < 0.6):
pass
else:
values = {
'city': address_response.AddressValidationResult.Address.City,
'zip': self.zip
}
@PritishC
PritishC / AddressValidation
Created October 27, 2014 09:59
Address Validation Response XML
# Details
Zip: '33137'
City: 'Miami, Miami-Dade'
Country: 'US'
Subdivision: 'Florida' or 'US-FL'.
# XML Response
<?xml version="1.0" encoding="UTF-8"?>
@PritishC
PritishC / auth_net
Created October 20, 2014 11:51
Authorize Net Problem
def _create_auth_net_gateway_for_site(self):
"""
A helper function that creates the authorize.net gateway and assigns
it to the websites.
"""
PaymentGateway = POOL.get('payment_gateway.gateway')
NereidWebsite = POOL.get('nereid.website')
Journal = POOL.get('account.journal')
cash_journal, = Journal.search([
#!/bin/env python
""" tryton_shell: A dirty shell for Tryton to quickly interact with it
usage: tryton_shell.py [-h] --config CONFIG --database DATABASE
arguments:
--config CONFIG Tryton config file.
--database DATABASE Tryton database.
@PritishC
PritishC / gist:3e21ecf7107e974db14f
Created September 30, 2014 06:34
assertRaises Correct
for argument in [
{'name': 'None'},
{'value': 'Value'},
{'method_type': 'international'}
]:
self.assertRaises(
UserError, self.endicia_mailclass.write,
[endicia_mailclass], argument
)
@PritishC
PritishC / gist:5770b88608389d594043
Created September 29, 2014 09:25
endicia:carrier.py:get_rates() method None problem
Code:
with Transaction().start(DB_NAME, USER, context=CONTEXT) as tr:
self.setup_defaults()
sale = self.create_sale(self.sale_party)
tr.set_context(sale=sale)
self.carrier.get_rates()
Partial Output:
(u'None Express Mail', Decimal('16.99'), self.currency1, {},
{'endicia_mailclass': 1, 'carrier': 1})
@PritishC
PritishC / gist:09c9b6b502fd0fa25dfa
Created September 29, 2014 07:33
Testing endicia:carrier.py
def test_get_rates(self):
"""
Test the get_rates method of Carrier.
"""
with Transaction().start(DB_NAME, USER, context=CONTEXT) as tr:
tr.set_context(sale=self.sale)
print(self.carrier.get_rates())
Stack Trace:
ERROR: test_get_rates (tests.test_carrier.CarrierTestCase)
@PritishC
PritishC / gist:6a30b2ceda5209a2fb98
Created September 26, 2014 12:49
Testing endicia_mailclass for readonly-ness.
endicia_mailclass, = self.endicia_mailclass.search([])
self.endicia_mailclass.write([endicia_mailclass], {
'name': 'None'
})
@PritishC
PritishC / tatti.html
Last active August 29, 2015 14:06
Movie Rating Exercise Q6
Movie
<table border="1" style="font-size:90%; padding: 1px;border-spacing:
0px; border-collapse: separate">
<tbody><tr border="1"><th style="border-width:
1px; padding: 3px; margin: 4px; border-style: inset; border-color:
gray;">mID</th><th style="border-width: 1px; padding: 3px; margin: 4px;
border-style: inset; border-color: gray;">title</th><th style="border-width: 1px; padding: 3px; margin: 4px; border-style:
inset; border-color: gray;">year</th><th style="border-width: 1px;
padding: 3px; margin: 4px; border-style: inset; border-color:
gray;">director</th></tr>