Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parse_float(self):
answer = mintapi.api.parse_float('10%')
self.assertEqual(answer, float(10))
answer = mintapi.api.parse_float('$10')
self.assertEqual(answer, float(10))
answer = mintapi.api.parse_float('0.00%')
self.assertEqual(answer, float(0))
def test_parse_float(self):
answer = mintapi.api.parse_float('10%')
self.assertEqual(answer, float(10))
answer = mintapi.api.parse_float('$10')
self.assertEqual(answer, float(10))
answer = mintapi.api.parse_float('0.00%')
self.assertEqual(answer, float(0))
def test_parse_float(self):
answer = mintapi.api.parse_float('10%')
self.assertEqual(answer, float(10))
answer = mintapi.api.parse_float('$10')
self.assertEqual(answer, float(10))
answer = mintapi.api.parse_float('0.00%')
self.assertEqual(answer, float(0))
def test_chrome_driver_links(self):
for platform in mintapi.api.CHROME_ZIP_TYPES:
zip_type = mintapi.api.CHROME_ZIP_TYPES.get(platform)
zip_file_url = mintapi.api.CHROME_DRIVER_BASE_URL % (mintapi.api.CHROME_DRIVER_VERSION, zip_type)
request = requests.get(zip_file_url)
self.assertEqual(request.status_code, 200)
@patch.object(mintapi.api, 'get_web_driver')
def test_accounts(self, mock_driver):
token_json = json.dumps({'token': '123'})
mock_driver.return_value.find_element_by_name.return_value.get_attribute.return_value = token_json
accounts_json = json.dumps({'response': {'42': {'response': accounts_example}}})
mock_driver.return_value.request.return_value.text = accounts_json
accounts = mintapi.get_accounts('foo', 'bar')
self.assertFalse('lastUpdatedInDate' in accounts)
self.assertNotEqual(accounts, accounts_example)
accounts_annotated = copy.deepcopy(accounts_example)
for account in accounts_annotated:
account['lastUpdatedInDate'] = (datetime.datetime.fromtimestamp(account['lastUpdated'] / 1000))
self.assertEqual(accounts, accounts_annotated)
def test_chrome_driver_links(self):
for platform in mintapi.api.CHROME_ZIP_TYPES:
zip_type = mintapi.api.CHROME_ZIP_TYPES.get(platform)
zip_file_url = mintapi.api.CHROME_DRIVER_BASE_URL % (mintapi.api.CHROME_DRIVER_VERSION, zip_type)
request = requests.get(zip_file_url)
self.assertEqual(request.status_code, 200)
def test_chrome_driver_links(self):
for platform in mintapi.api.CHROME_ZIP_TYPES:
zip_type = mintapi.api.CHROME_ZIP_TYPES.get(platform)
zip_file_url = mintapi.api.CHROME_DRIVER_BASE_URL % (mintapi.api.CHROME_DRIVER_VERSION, zip_type)
request = requests.get(zip_file_url)
self.assertEqual(request.status_code, 200)
def test_accounts(self, mock_driver):
token_json = json.dumps({'token': '123'})
mock_driver.return_value.find_element_by_name.return_value.get_attribute.return_value = token_json
accounts_json = json.dumps({'response': {'42': {'response': accounts_example}}})
mock_driver.return_value.request.return_value.text = accounts_json
accounts = mintapi.get_accounts('foo', 'bar')
self.assertFalse('lastUpdatedInDate' in accounts)
self.assertNotEqual(accounts, accounts_example)
accounts_annotated = copy.deepcopy(accounts_example)
for account in accounts_annotated:
account['lastUpdatedInDate'] = (datetime.datetime.fromtimestamp(account['lastUpdated'] / 1000))
self.assertEqual(accounts, accounts_annotated)
# ensure everything is json serializable as this is the command-line
# behavior.
mintapi.print_accounts(accounts)
accounts_json = json.dumps({'response': {'42': {'response': accounts_example}}})
mock_driver.return_value.request.return_value.text = accounts_json
accounts = mintapi.get_accounts('foo', 'bar')
self.assertFalse('lastUpdatedInDate' in accounts)
self.assertNotEqual(accounts, accounts_example)
accounts_annotated = copy.deepcopy(accounts_example)
for account in accounts_annotated:
account['lastUpdatedInDate'] = (datetime.datetime.fromtimestamp(account['lastUpdated'] / 1000))
self.assertEqual(accounts, accounts_annotated)
# ensure everything is json serializable as this is the command-line
# behavior.
mintapi.print_accounts(accounts)
keyring.set_password('mintapi', email, password)
if options.accounts_ext:
options.accounts = True
if not any([options.accounts, options.budgets, options.transactions,
options.extended_transactions, options.net_worth, options.credit_score,
options.credit_report]):
options.accounts = True
if options.session_path == 'None':
session_path = None
else:
session_path = options.session_path
mint = Mint.create(email, password,
mfa_method=options.mfa_method,
session_path=session_path,
headless=options.headless,
imap_account=options.imap_account,
imap_password=options.imap_password,
imap_server=options.imap_server,
imap_folder=options.imap_folder,
wait_for_sync=not options.no_wait_for_sync,
wait_for_sync_timeout=options.wait_for_sync_timeout
)
atexit.register(mint.close) # Ensure everything is torn down.
if options.imap_test:
mfa_code = get_email_code(options.imap_account, options.imap_password, options.imap_server, imap_folder=options.imap_folder, debug=1, delete=0)
print("MFA CODE:", mfa_code)
sys.exit()