Пример #1
0
def test_list_reports(fyle, mock_data):
  """
  Test Fyle category Object
  :param fyle: fyle sdk instance
  :param mock_data: mock instance
  :return: None
  """
  query_params = {
    'order': 'created_at.desc',
    'limit': 100,
    'offset': 823
  }

  reports_generator = fyle.v1beta.approver.reports.list(query_params=query_params)
  mock_reports = mock_data.reports.get()

  if reports_generator["data"]:
    global report_id
    report_id = reports_generator["data"][0]["id"]
    for reports in reports_generator["data"]:
      if reports["state"] == "APPROVER_PENDING":
        report_id = reports["id"]
        break
    assert dict_compare_keys(reports_generator["data"][0], mock_reports[0]) == [], 'fyle.v1beta.approver.reports.list() has stuff that mock_data doesnt'
    assert dict_compare_keys(mock_reports[0], reports_generator["data"][0]) == [], 'mock_data.reports.get() has stuff that fyle doesnt'
Пример #2
0
def test_get_by_id_tax_groups(fyle, mock_data):
  get_by_id = fyle.v1beta.admin.tax_groups.get_by_id(id_="tgXueCemFa6Q")
  mock_files = mock_data.tax_groups.get()

  if get_by_id["data"]:
    assert dict_compare_keys(get_by_id["data"], mock_files[0]) == [], 'response from fyle.v1beta.admin.tax_groups.post_bulk() has stuff that mock_data doesnt'
    assert dict_compare_keys(mock_files[0], get_by_id["data"]) == [], 'mock_data.tax_groups.get() has stuff that fyle doesnt'
Пример #3
0
def test_approve_report(fyle, mock_data):
  approve_report = {}
  try:
    approve_report = fyle.v1beta.approver.reports.approve(id_=report_id)
    mock_reports = mock_data.reports.get()
  except:
    logger.error("report is not in APPROVER_PENDING state")
  if approve_report:
    assert dict_compare_keys(approve_report["data"], mock_reports[0]) == [], 'fyle.v1beta.approver.reports.list() has stuff that mock_data doesnt'
    assert dict_compare_keys(mock_reports[0], approve_report["data"]) == [], 'mock_data.reports.get() has stuff that fyle doesnt'
Пример #4
0
def test_projects(fyle, mock_fyle):
    """
    Test fyle_db_connector Extract projects
    :param fyle: fyle_extract instance
    :param mock_fyle: mock instance
    :return: None
    """
    data = fyle.Projects.get()['data']
    mock_data = mock_fyle.Projects.get()['data']
    assert dict_compare_keys(data[0], mock_data[0]) == [], 'real fyle has stuff that mock_fyle doesnt'
    assert dict_compare_keys(mock_data[0], data[0]) == [], 'mock_fyle has stuff that real fyle doesnt'
Пример #5
0
def test_corporate_card_expenses(fyle, mock_fyle):
    """
    Test fyle_db_connector Extract corporate_credit_card_expenses
    :param fyle: fyle_extract instance
    :param mock_fyle: mock instance
    :return: None
    """
    data = fyle.CorporateCreditCardExpenses.get_all()
    mock_data = mock_fyle.CorporateCreditCardExpenses.get_all()
    assert dict_compare_keys(data[0], mock_data[0]) == [], 'real fyle has stuff that mock_fyle doesnt'
    assert dict_compare_keys(mock_data[0], data[0]) == [], 'mock_fyle has stuff that real fyle doesnt'
Пример #6
0
def test_get_profile(fyle, mock_data):
    profile = fyle.v1beta.spender.my_profile.get()
    mock_profile = mock_data.profile.get()

    if profile:
        assert dict_compare_keys(
            profile["data"], mock_profile
        ) == [], 'fyle.v1beta.spender.profile.list_all() has stuff that mock_data doesnt'
        assert dict_compare_keys(
            mock_profile, profile["data"]
        ) == [], 'mock_data.profile.get() has stuff that fyle doesnt'
def test_list_currencies(fyle, mock_data):
    list_currencies = fyle.v1beta.common.currencies.list()
    mock_currencies = mock_data.currencies.get()

    if list_currencies["data"]:
        assert dict_compare_keys(
            list_currencies["data"], mock_currencies
        ) == [], 'response from fyle.v1beta.common.currencies.list() has stuff that mock_data doesnt'
        assert dict_compare_keys(
            mock_currencies, list_currencies["data"]
        ) == [], 'mock_data.currencies.get() has stuff that fyle doesnt'
Пример #8
0
def test_advance_requests(fyle, mock_fyle):
    """
    Test fyle_db_connector Extract advance_requests
    :param fyle: fyle_extract instance
    :param mock_fyle: mock instance
    :return: None
    """
    data = fyle.AdvanceRequests.get_all()
    mock_data = mock_fyle.AdvanceRequests.get_all()
    assert dict_compare_keys(data[0], mock_data[0]) == [], 'real fyle has stuff that mock_fyle doesnt'
    assert dict_compare_keys(mock_data[0], data[0]) == [], 'mock_fyle has stuff that real fyle doesnt'
def test_get_exchange_rate(fyle, mock_data):
    exchange_rate = fyle.v1beta.common.currencies_exchange_rate.get(
        from_="INR", to_="USD", date="2021-11-18")
    mock_exchange_rate = mock_data.exchange_rate.get()

    if exchange_rate["data"]:
        assert dict_compare_keys(
            exchange_rate["data"], mock_exchange_rate
        ) == [], 'response from fyle.v1beta.common.currencies_exchange_rate.get() has stuff that mock_data doesnt'
        assert dict_compare_keys(
            mock_exchange_rate, exchange_rate["data"]
        ) == [], 'mock_data.exchange_rate.get() has stuff that fyle doesnt'
def test_list_places_autocomplete(fyle, mock_data):
    places_autocomplete = fyle.v1beta.common.places_autocomplete.list(
        q="bang", types="(cities)", location="26.595889,85.4891037")
    mock_places_autocomplete = mock_data.places_autocomplete.get()

    if places_autocomplete["data"]:
        assert dict_compare_keys(
            places_autocomplete["data"][0], mock_places_autocomplete[0]
        ) == [], 'response from fyle.v1beta.common.places_autocomplete.list() has stuff that mock_data doesnt'
        assert dict_compare_keys(
            mock_places_autocomplete[0], places_autocomplete["data"][0]
        ) == [], 'mock_data.places_autocomplete.get() has stuff that fyle doesnt'
def test_get_by_id_places(fyle, mock_data):
    place_by_id = fyle.v1beta.common.places.get_by_id(
        id_="ChIJbU60yXAWrjsR4E9-UejD3_g")
    mock_places = mock_data.place_by_id.get()

    if place_by_id:
        assert dict_compare_keys(
            place_by_id, mock_places[0]
        ) == [], 'response from fyle.v1beta.common.places.get_by_id() has stuff that mock_data doesnt'
        assert dict_compare_keys(
            mock_places[0], place_by_id
        ) == [], 'mock_data.place_by_id.get() has stuff that fyle doesnt'
Пример #12
0
def test_list_tax_groups(fyle, mock_data):
  query_params = {
    'offset': 1,
    'limit': 1,
    'order': 'created_at.desc'
  }

  tax_groups_generator = fyle.v1beta.admin.tax_groups.list(query_params=query_params)
  mock_tax_groups = mock_data.tax_groups.get()

  if tax_groups_generator["data"]:
    assert dict_compare_keys(tax_groups_generator["data"][0], mock_tax_groups[0]) == [], 'fyle.v1beta.admin.tax_groups.list() has stuff that mock_data doesnt'
    assert dict_compare_keys(mock_tax_groups[0], tax_groups_generator["data"][0]) == [], 'mock_data.tax_groups.get() has stuff that fyle doesnt'
Пример #13
0
def test_create_file(fyle, mock_data):
  create_fyle = fyle.v1beta.admin.files.create_file(payload = {
    "data": {
      "name": "uber_expenses_2.pdf",
      "type": "RECEIPT",
      "user_id": "usqywo0f3nBY"
    }
  })
  mock_files = mock_data.files_create.get()

  if create_fyle["data"]:
    assert dict_compare_keys(create_fyle["data"], mock_files[0]) == [], 'response from fyle.v1beta.admin.files.create_file() has stuff that mock_data doesnt'
    assert dict_compare_keys(mock_files[0], create_fyle["data"]) == [], 'mock_data.files_create.get() has stuff that fyle doesnt'
Пример #14
0
def test_departments(qbo, mock_qbo):
    """
    Test Quickbooks departments Object
    :param qbo: qbo sdk instance
    :param mock_qbo: mock instance
    :return: None
    """
    departments = qbo.departments.get()
    mock_departments = mock_qbo.departments.get()

    assert dict_compare_keys(departments[0], mock_departments[0]) == [], \
        'qbo.departments.get() has stuff that mock_qbo doesnt'
    assert dict_compare_keys(mock_departments[0], departments[0]) == [], \
        'mock_qbo.departments.get() has stuff that qbo doesnt'
Пример #15
0
def test_create_accounting_export_lineitems(fyle, mock_data):
  create_accounting_export_lineitems = fyle.v1beta.admin.accounting_exports.create_accounting_export_lineitems(payload={
    "data": {
      "object_id": "sdfd2391",
      "object_type": "REIMBURSEMENT",
      "reference": "string",
      "accounting_export_id": account_export_id
    }
  })
  mock_accounting_exports_lineitems = mock_data.accounting_export_lineitems.get()

  if create_accounting_export_lineitems["data"]:
    assert dict_compare_keys(create_accounting_export_lineitems["data"], mock_accounting_exports_lineitems[0]) == [], 'response from fyle.v1beta.admin.accounting_export.create_accounting_export_lineitems() has stuff that mock_data doesnt'
    assert dict_compare_keys(mock_accounting_exports_lineitems[0], create_accounting_export_lineitems["data"]) == [], 'mock_data.accounting_export_lineitems.get() has stuff that fyle doesnt'
Пример #16
0
def test_exchange_rates(qbo, mock_qbo):
    """
    Test Quickbooks exchange_rates Object
    :param qbo: qbo sdk instance
    :param mock_qbo: mock instance
    :return: None
    """
    exchange_rates = qbo.exchange_rates.get()
    mock_exchange_rates = mock_qbo.exchange_rates.get()

    assert dict_compare_keys(exchange_rates[0], mock_exchange_rates[0]) == [], \
        'qbo.exchange_rates.get() has stuff that mock_qbo doesnt'
    assert dict_compare_keys(mock_exchange_rates[0], exchange_rates[0]) == [], \
        'mock_qbo.exchange_rates.get() has stuff that qbo doesnt'
Пример #17
0
def test_get_accounting_exports(fyle, mock_data):
    query_params = {
      'order': 'created_at.desc',
      'id': 'eq.aeCtoS8IircK'
    }
    accounting_exports = fyle.v1beta.admin.accounting_exports.get_accounting_exports(
        query_params=query_params
    )
    mock_accounting_export = mock_data.accounting_export.get()
    if accounting_exports["data"]:
        global account_export_id
        account_export_id = accounting_exports["data"][0]["id"]
        assert dict_compare_keys(accounting_exports["data"][0], mock_accounting_export[0]) == [], 'response from fyle.v1beta.admin.accounting_export.accounting_exports() has stuff that mock_data doesnt'
        assert dict_compare_keys(mock_accounting_export[0], accounting_exports["data"][0]) == [], 'mock_data.accounting_exports.get() has stuff that fyle doesnt'
Пример #18
0
def test_preferences(qbo, mock_qbo):
    """
    Test Quickbooks preferences Object
    :param qbo: qbo sdk instance
    :param mock_qbo: mock instance
    :return: None
    """
    preferences = qbo.preferences.get()
    mock_preferences = mock_qbo.preferences.get()

    assert dict_compare_keys(preferences, mock_preferences) == [], \
        'qbo.preferences.get() has stuff that mock_qbo doesnt'
    assert dict_compare_keys(mock_preferences, preferences) == [], \
        'mock_qbo.preferences.get() has stuff that qbo doesnt'
Пример #19
0
def test_journal_entries(qbo, mock_qbo):
    """
    Test Quickbooks journal_entries Object
    :param qbo: qbo sdk instance
    :param mock_qbo: mock instance
    :return: None
    """
    journal_entries = qbo.journal_entries.get()
    mock_journal_entries = mock_qbo.journal_entries.get()

    assert dict_compare_keys(journal_entries[0], mock_journal_entries[0]) == [], \
        'qbo.journal_entries.get() has stuff that mock_qbo doesnt'
    assert dict_compare_keys(mock_journal_entries[0], journal_entries[0]) == [], \
        'mock_qbo.journal_entries.get() has stuff that qbo doesnt'
Пример #20
0
def test_attach_receipt(fyle, mock_data):
    attach_receipt = fyle.v1beta.spender.expenses.attach_receipt(
        payload={"data": {
            "id": expense_id,
            "file_id": file_id
        }})
    mock_files = mock_data.attach_receipt.get()

    if attach_receipt["data"]:
        assert dict_compare_keys(
            attach_receipt["data"], mock_files
        ) == [], 'response from fyle.v1beta.spender.expenses.attach_receipt() has stuff that mock_data doesnt'
        assert dict_compare_keys(
            mock_files, attach_receipt["data"]
        ) == [], 'mock_data.attach_receipt.get() has stuff that fyle doesnt'
Пример #21
0
def test_generate_file_urls(fyle, mock_data):
    generate_file_urls = fyle.v1beta.spender.files.generate_file_urls(
        payload={"data": {
            "id": file_id
        }})
    mock_files = mock_data.file_generate_url.get()
    if generate_file_urls["data"]:
        global upload_url
        upload_url = generate_file_urls["data"]["upload_url"]
        assert dict_compare_keys(
            generate_file_urls["data"], mock_files
        ) == [], 'response from fyle.v1beta.spender.files.create_file() has stuff that mock_data doesnt'
        assert dict_compare_keys(
            mock_files, generate_file_urls["data"]
        ) == [], 'mock_data.file_generate_url.get() has stuff that fyle doesnt'
Пример #22
0
def test_list_all_tax_groups(fyle, mock_data):
  tax_groups = []
  query_params = {
    'order': 'created_at.desc'
  }

  tax_groups_generator = fyle.v1beta.admin.tax_groups.list_all(query_params=query_params)
  mock_tax_groups = mock_data.tax_groups.get()

  for response in tax_groups_generator:
    if response.get('data'):
      tax_groups.extend(response['data'])

  if tax_groups:
    assert dict_compare_keys(tax_groups[0], mock_tax_groups[0]) == [], 'fyle.v1beta.admin.tax_groups.list_all() has stuff that mock_data doesnt'
    assert dict_compare_keys(mock_tax_groups[0], tax_groups[0]) == [], 'mock_data.tax_groups.get() has stuff that fyle doesnt'
Пример #23
0
def test_list_employees(fyle, mock_data):
  employees = []
  query_params = {
    'order': 'created_at.desc'
  }

  employees_generator = fyle.v1beta.admin.employees.list_all(query_params=query_params)
  mock_employees = mock_data.employees.get()

  for response in employees_generator:
    if response.get('data'):
      employees.extend(response['data'])

  if employees:
    assert dict_compare_keys(employees[0], mock_employees[0]) == [], 'fyle.v1beta.admin.employees.list_all() has stuff that mock_data doesnt'
    assert dict_compare_keys(mock_employees[0], employees[0]) == [], 'mock_data.employees.get() has stuff that fyle doesnt'
Пример #24
0
def test_accounts(qbo, mock_qbo):
    """
    Test Quickbooks accounts Object
    :param qbo: qbo sdk instance
    :param mock_qbo: mock instance
    :return: None
    """
    accounts = qbo.accounts.get()
    mock_accounts = mock_qbo.accounts.get()

    assert dict_compare_keys(
        accounts[0], mock_accounts[0]
    ) == [], 'qbo.accounts.get() has stuff that mock_qbo doesnt'
    assert dict_compare_keys(
        mock_accounts[0],
        accounts[0]) == [], 'mock_qbo.accounts.get() has stuff that qbo doesnt'
Пример #25
0
def test_home_currency(qbo_ex, mock_qbo):
    """
    Test QBO Extract home_currency
    :param qbo_ex: qbo_ex extract instance
    :param mock_qbo: mock instance
    :return: None
    """
    qbo_ex.extract_home_currency()
    home_currency = dbconn_table_row_dict(dbconn(), 'qbo_extract_home_currency')

    mock_home_currency = mock_qbo.home_currency.get()

    assert dict_compare_keys(home_currency, mock_home_currency[0]) == [], \
        'qbo_extract.extract_home_currency has stuff that mock_qbo.home_currency.get doesnt'
    assert dict_compare_keys(mock_home_currency[0], home_currency) == [], \
        'mock_qbo.home_currency.get() has stuff that qbo_extract.extract_home_currency doesnt'
Пример #26
0
def test_classes(qbo_ex, mock_qbo):
    """
    Test QBO Extract classes
    :param qbo_ex: qbo_ex extract instance
    :param mock_qbo: mock instance
    :return: None
    """
    qbo_ex.extract_classes()
    classes = dbconn_table_row_dict(dbconn(), 'qbo_extract_classes')

    mock_classes = mock_qbo.classes.get()

    assert dict_compare_keys(classes, mock_classes[0]) == [], \
        'qbo_extract.extract_classes has stuff that mock_qbo.classes.get doesnt'
    assert dict_compare_keys(mock_classes[0], classes) == [], \
        'mock_qbo.classes.get() has stuff that qbo_extract.extract_classes doesnt'
Пример #27
0
def test_departments(qbo_ex, mock_qbo):
    """
    Test QBO Extract departments
    :param qbo_ex: qbo_ex extract instance
    :param mock_qbo: mock instance
    :return: None
    """
    qbo_ex.extract_departments()
    departments = dbconn_table_row_dict(dbconn(), 'qbo_extract_departments')

    mock_departments = mock_qbo.departments.get()

    assert dict_compare_keys(departments, mock_departments[0]) == [], \
        'qbo_extract.extract_departments has stuff that mock_qbo.departments.get doesnt'
    assert dict_compare_keys(mock_departments[0], departments) == [], \
        'mock_qbo.departments.get() has stuff that qbo_extract.extract_departments doesnt'
Пример #28
0
def test_load_checks(qbo_lo, mock_qbo):
    """
    Test QBO Load checks
    :param qbo_lo: qbo load instance
    :param mock_qbo: mock instance
    :return: None
    """
    sql = open('./test/common/mock_db_load.sql').read()
    dbconn().executescript(sql)

    check = qbo_lo.load_check(check_id='C1')
    mock_check = mock_qbo.purchases.save()

    assert dict_compare_keys(check, mock_check['Purchase']) == [], \
        'qbo_load.load_check has stuff that mock_qbo.load_check doesnt'
    assert dict_compare_keys(mock_check['Purchase'], check) == [], \
        'mock_qbo.load_check has stuff that qbo_load.load_check doesnt'
Пример #29
0
def test_load_journal_entries(qbo_lo, mock_qbo):
    """
    Test QBO Load journal_entries
    :param qbo_lo: qbo load instance
    :param mock_qbo: mock instance
    :return: None
    """
    sql = open('./test/common/mock_db_load.sql').read()
    dbconn().executescript(sql)

    journal_entry = qbo_lo.load_journal_entry(journal_entry_id='J1')
    mock_journal_entry = mock_qbo.journal_entries.save()

    assert dict_compare_keys(journal_entry, mock_journal_entry['JournalEntry']) == [], \
        'qbo_load.load_journal_entry has stuff that mock_qbo.load_journal_entry doesnt'
    assert dict_compare_keys(mock_journal_entry['JournalEntry'], journal_entry) == [], \
        'mock_qbo.load_journal_entry has stuff that qbo_load.load_journal_entry doesnt'
Пример #30
0
def test_create_accounting_exports(fyle, mock_data):
  create_accounting_exports = fyle.v1beta.admin.accounting_exports.create_accounting_exports(payload={
    "data": {
      "file_ids": [
        "fiFqjxHuSwX5"
      ],
      "exported_at": "2020-06-01T13:14:54.804+00:00",
      "name": "Accounting exports tests",
      "description": "Win the trophy",
    }
  })
  mock_accounting_exports = mock_data.created_accounting_export.get()

  if create_accounting_exports["data"]:
    global account_export_id
    account_export_id = create_accounting_exports["data"]["id"]
    assert dict_compare_keys(create_accounting_exports["data"], mock_accounting_exports[0]) == [], 'response from fyle.v1beta.admin.accounting_export.create_accounting_exports() has stuff that mock_data doesnt'
    assert dict_compare_keys(mock_accounting_exports[0], create_accounting_exports["data"]) == [], 'mock_data.created_accounting_export.get() has stuff that fyle doesnt'