fakesnow 0.9.14__tar.gz → 0.9.16__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {fakesnow-0.9.14 → fakesnow-0.9.16}/PKG-INFO +1 -1
  2. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow/fakes.py +5 -2
  3. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow.egg-info/PKG-INFO +1 -1
  4. {fakesnow-0.9.14 → fakesnow-0.9.16}/pyproject.toml +1 -1
  5. {fakesnow-0.9.14 → fakesnow-0.9.16}/tests/test_fakes.py +10 -1
  6. {fakesnow-0.9.14 → fakesnow-0.9.16}/LICENSE +0 -0
  7. {fakesnow-0.9.14 → fakesnow-0.9.16}/README.md +0 -0
  8. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow/__init__.py +0 -0
  9. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow/__main__.py +0 -0
  10. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow/checks.py +0 -0
  11. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow/cli.py +0 -0
  12. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow/expr.py +0 -0
  13. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow/fixtures.py +0 -0
  14. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow/global_database.py +0 -0
  15. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow/info_schema.py +0 -0
  16. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow/macros.py +0 -0
  17. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow/py.typed +0 -0
  18. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow/transforms.py +0 -0
  19. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow.egg-info/SOURCES.txt +0 -0
  20. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow.egg-info/dependency_links.txt +0 -0
  21. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow.egg-info/entry_points.txt +0 -0
  22. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow.egg-info/requires.txt +0 -0
  23. {fakesnow-0.9.14 → fakesnow-0.9.16}/fakesnow.egg-info/top_level.txt +0 -0
  24. {fakesnow-0.9.14 → fakesnow-0.9.16}/setup.cfg +0 -0
  25. {fakesnow-0.9.14 → fakesnow-0.9.16}/tests/test_checks.py +0 -0
  26. {fakesnow-0.9.14 → fakesnow-0.9.16}/tests/test_cli.py +0 -0
  27. {fakesnow-0.9.14 → fakesnow-0.9.16}/tests/test_expr.py +0 -0
  28. {fakesnow-0.9.14 → fakesnow-0.9.16}/tests/test_info_schema.py +0 -0
  29. {fakesnow-0.9.14 → fakesnow-0.9.16}/tests/test_patch.py +0 -0
  30. {fakesnow-0.9.14 → fakesnow-0.9.16}/tests/test_sqlalchemy.py +0 -0
  31. {fakesnow-0.9.14 → fakesnow-0.9.16}/tests/test_transforms.py +0 -0
  32. {fakesnow-0.9.14 → fakesnow-0.9.16}/tests/test_users.py +0 -0
  33. {fakesnow-0.9.14 → fakesnow-0.9.16}/tests/test_write_pandas.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fakesnow
3
- Version: 0.9.14
3
+ Version: 0.9.16
4
4
  Summary: Fake Snowflake Connector for Python. Run, mock and test Snowflake DB locally.
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -297,6 +297,9 @@ class FakeSnowflakeCursor:
297
297
  elif cmd == "CREATE TABLE" and ident:
298
298
  result_sql = SQL_CREATED_TABLE.substitute(name=ident)
299
299
 
300
+ elif cmd.startswith("ALTER") and ident:
301
+ result_sql = SQL_SUCCESS
302
+
300
303
  elif cmd == "CREATE VIEW" and ident:
301
304
  result_sql = SQL_CREATED_VIEW.substitute(name=ident)
302
305
 
@@ -517,7 +520,7 @@ class FakeSnowflakeConnection:
517
520
  self.schema = schema and schema.upper()
518
521
  self.database_set = False
519
522
  self.schema_set = False
520
- self.db_path = db_path
523
+ self.db_path = Path(db_path) if db_path else None
521
524
  self.nop_regexes = nop_regexes
522
525
  self._paramstyle = snowflake.connector.paramstyle
523
526
 
@@ -532,7 +535,7 @@ class FakeSnowflakeConnection:
532
535
  where catalog_name = '{self.database}'"""
533
536
  ).fetchone()
534
537
  ):
535
- db_file = f"{Path(db_path)/self.database}.db" if db_path else ":memory:"
538
+ db_file = f"{self.db_path/self.database}.db" if self.db_path else ":memory:"
536
539
  duck_conn.execute(f"ATTACH DATABASE '{db_file}' AS {self.database}")
537
540
  duck_conn.execute(info_schema.creation_sql(self.database))
538
541
  duck_conn.execute(macros.creation_sql(self.database))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fakesnow
3
- Version: 0.9.14
3
+ Version: 0.9.16
4
4
  Summary: Fake Snowflake Connector for Python. Run, mock and test Snowflake DB locally.
5
5
  License: Apache License
6
6
  Version 2.0, January 2004
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "fakesnow"
3
3
  description = "Fake Snowflake Connector for Python. Run, mock and test Snowflake DB locally."
4
- version = "0.9.14"
4
+ version = "0.9.16"
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
7
7
  classifiers = ["License :: OSI Approved :: MIT License"]
@@ -202,6 +202,12 @@ def test_connect_reuse_db():
202
202
  assert cur.execute("select * from example").fetchall() == [(420,)]
203
203
 
204
204
 
205
+ def test_connect_db_path_can_create_database() -> None:
206
+ with tempfile.TemporaryDirectory(prefix="fakesnow-test") as db_path, fakesnow.patch(db_path=db_path):
207
+ cursor = snowflake.connector.connect().cursor()
208
+ cursor.execute("CREATE DATABASE db2")
209
+
210
+
205
211
  def test_connect_without_database(_fakesnow_no_auto_create: None):
206
212
  with snowflake.connector.connect() as conn, conn.cursor() as cur:
207
213
  with pytest.raises(snowflake.connector.errors.ProgrammingError) as excinfo:
@@ -589,10 +595,13 @@ def test_description_create_drop_schema(dcur: snowflake.connector.cursor.DictCur
589
595
  assert dcur.description == [ResultMetadata(name='status', type_code=2, display_size=None, internal_size=16777216, precision=None, scale=None, is_nullable=True)] # fmt: skip
590
596
 
591
597
 
592
- def test_description_create_drop_table(dcur: snowflake.connector.cursor.DictCursor):
598
+ def test_description_create_alter_drop_table(dcur: snowflake.connector.cursor.DictCursor):
593
599
  dcur.execute("create table example (x int)")
594
600
  assert dcur.fetchall() == [{"status": "Table EXAMPLE successfully created."}]
595
601
  assert dcur.description == [ResultMetadata(name='status', type_code=2, display_size=None, internal_size=16777216, precision=None, scale=None, is_nullable=True)] # fmt: skip
602
+ dcur.execute("alter table example add column name varchar(20)")
603
+ assert dcur.fetchall() == [{"status": "Statement executed successfully."}]
604
+ assert dcur.description == [ResultMetadata(name='status', type_code=2, display_size=None, internal_size=16777216, precision=None, scale=None, is_nullable=True)] # fmt: skip
596
605
  dcur.execute("drop table example")
597
606
  assert dcur.fetchall() == [{"status": "EXAMPLE successfully dropped."}]
598
607
  assert dcur.description == [ResultMetadata(name='status', type_code=2, display_size=None, internal_size=16777216, precision=None, scale=None, is_nullable=True)] # fmt: skip
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes