You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.1 KiB

  1. from .dbtest import (
  2. DbTest,
  3. dbconnect
  4. )
  5. import os
  6. from psycopg2.extras import RealDictCursor
  7. PATH_TO_SQL_DIR = os.path.abspath(
  8. os.path.join(
  9. os.path.dirname(__file__),
  10. "..",
  11. "sql"
  12. )
  13. )
  14. class TestExample(DbTest):
  15. @dbconnect
  16. def test_select_organizations(self, conn):
  17. self.load_fixtures(
  18. conn,
  19. os.path.join(PATH_TO_SQL_DIR, "organizations.sql")
  20. )
  21. sql = """
  22. SELECT * FROM organizations;
  23. """
  24. with conn.cursor(cursor_factory=RealDictCursor) as cur:
  25. cur.execute(sql)
  26. organizations = cur.fetchall()
  27. assert len(organizations) == 7
  28. @dbconnect
  29. def test_select_addresses(self, conn):
  30. self.load_fixtures(
  31. conn,
  32. os.path.join(PATH_TO_SQL_DIR, "organizations.sql")
  33. )
  34. sql = """
  35. SELECT * FROM addresses;
  36. """
  37. with conn.cursor(cursor_factory=RealDictCursor) as cur:
  38. cur.execute(sql)
  39. addresses = cur.fetchall()
  40. assert len(addresses) == 7