I hereby claim:
- I am andy47 on github.
- I am andy47 (https://keybase.io/andy47) on keybase.
- I have a public key ASAr8XqLaXRk2O6C-l37nEJckWiUyI3rI9yMsmjPCxkxDgo
To claim this, I am signing this object:
def parse_connection(connection_string): | |
"""Work out the user name and password in connection_string | |
Connection string should be of the form 'database://username@password' | |
""" | |
if '@' in connection_string: | |
# Username is characters between '://' and '@' | |
slash_position = connection_string.find('://') | |
at_position = connection_string.find('@') | |
user_name = connection_string[slash_position+3:at_position] |
from parse_conn import parse_connection | |
import unittest | |
class InvalidInputs(unittest.TestCase): | |
def testNoAt(self): | |
"""parse_connection should raise an exception | |
for an invalid connection string""" | |
self.assertRaises(ValueError, parse_connection, 'invalid uri') | |
if __name__ == "__main__": |
from parse_conn import parse_connection | |
import py.test | |
def test_not_at(): | |
py.test.raises(ValueError, parse_connection, 'invalid uri') |
class Portfolio(object): | |
... | |
def get_portfolio(self, portfolio_code): | |
... | |
stmt = """SELECT id FROM portfolios WHERE code=?""" | |
cursor.execute(stmt, (portfolio_code,)) | |
portfolio_id = cursor.fetchone()[0] | |
... | |
def add_value(self, portfolio_code, ...): | |
... |
I hereby claim:
To claim this, I am signing this object: