Пример #1
0
 def test_from_environ_override_exists(self, monkeypatch):
     db.drivers.autoregister_class(db_sqlite3.Sqlite3Driver)
     monkeypatch.setenv("ENVIRONMENT", "yacht_club")
     monkeypatch.setenv("YACHT_CLUB_DATABASE_URL", MEM_URL)
     db.from_env()
     assert "sqlite3" in db.drivers._DRIVERS
     assert len(db.drivers._DRIVERS) == 1
Пример #2
0
 def test_from_environ_default_exists(self, monkeypatch):
     db.drivers.autoregister_class(db_sqlite3.Sqlite3Driver)
     monkeypatch.delenv("ENVIRONMENT", raising=False)
     monkeypatch.setenv("DATABASE_URL", MEM_URL)
     db.from_env()
     assert "sqlite3" in db.drivers._DRIVERS
     assert len(db.drivers._DRIVERS) == 1
Пример #3
0
 def test_from_environ_override_not_exists(self, monkeypatch):
     monkeypatch.setenv("ENVIRONMENT", "yacht_club")
     monkeypatch.delenv("YACHT_CLUB_DATABASE_URL", raising=False)
     with pytest.raises(KeyError) as ex:
         db.from_env()
     assert ex.value.message == "YACHT_CLUB_DATABASE_URL"
     assert len(db.drivers._DRIVERS) == 0
Пример #4
0
 def test_from_environ_override_exists(self, monkeypatch):
     db.drivers.autoregister_class(db_sqlite3.Sqlite3Driver)
     monkeypatch.setenv("ENVIRONMENT", "yacht_club")
     monkeypatch.setenv("YACHT_CLUB_DATABASE_URL", MEM_URL)
     db.from_env()
     assert "sqlite3" in db.drivers._DRIVERS
     assert len(db.drivers._DRIVERS) == 1
Пример #5
0
 def test_from_environ_default_not_exists(self, monkeypatch):
     monkeypatch.delenv("ENVIRONMENT", raising=False)
     monkeypatch.delenv("DATABASE_URL", raising=False)
     with pytest.raises(KeyError) as ex:
         db.from_env()
     assert ex.value.message == "DATABASE_URL"
     assert len(db.drivers._DRIVERS) == 0
Пример #6
0
 def test_from_environ_default_exists(self, monkeypatch):
     db.drivers.autoregister_class(db_sqlite3.Sqlite3Driver)
     monkeypatch.delenv("ENVIRONMENT", raising=False)
     monkeypatch.setenv("DATABASE_URL", MEM_URL)
     db.from_env()
     assert "sqlite3" in db.drivers._DRIVERS
     assert len(db.drivers._DRIVERS) == 1
Пример #7
0
 def test_from_environ_override_not_exists(self, monkeypatch):
     monkeypatch.setenv("ENVIRONMENT", "yacht_club")
     monkeypatch.delenv("YACHT_CLUB_DATABASE_URL", raising=False)
     with pytest.raises(KeyError) as ex:
         db.from_env()
     assert ex.value.message == "YACHT_CLUB_DATABASE_URL"
     assert len(db.drivers._DRIVERS) == 0
Пример #8
0
 def test_from_environ_default_not_exists(self, monkeypatch):
     monkeypatch.delenv("ENVIRONMENT", raising=False)
     monkeypatch.delenv("DATABASE_URL", raising=False)
     with pytest.raises(KeyError) as ex:
         db.from_env()
     assert ex.value.message == "DATABASE_URL"
     assert len(db.drivers._DRIVERS) == 0
Пример #9
0
 def test_from_env_bad_url(self, monkeypatch):
     monkeypatch.setenv("DATABASE_URL", "bad bad url")
     with pytest.raises(db.InvalidDatabaseURL) as ex:
         db.from_env()
     assert ex.value.message == "bad bad url"
     assert len(db.drivers._DRIVERS) == 0
Пример #10
0
 def test_from_env_override_exists(self, monkeypatch):
     db.drivers.autoregister_class(db_sqlite3.Sqlite3Driver)
     monkeypatch.setenv("ALT_URL", MEM_URL)
     db.from_env("ALT_URL")
     assert "sqlite3" in db.drivers._DRIVERS
     assert len(db.drivers._DRIVERS) == 1
Пример #11
0
 def test_from_env_override_not_exists(self, monkeypatch):
     monkeypatch.delenv("ALT_URL", raising=False)
     with pytest.raises(KeyError) as ex:
         db.from_env("ALT_URL")
     assert ex.value.message == "ALT_URL"
     assert len(db.drivers._DRIVERS) == 0
Пример #12
0
 def test_from_env_default_exists(self, monkeypatch):
     db.drivers.autoregister_class(db_sqlite3.Sqlite3Driver)
     monkeypatch.setenv("DATABASE_URL", MEM_URL)
     db.from_env()
     assert "sqlite3" in db.drivers._DRIVERS
     assert len(db.drivers._DRIVERS) == 1
Пример #13
0
 def test_from_env_bad_url(self, monkeypatch):
     monkeypatch.setenv("DATABASE_URL", "bad bad url")
     with pytest.raises(db.InvalidDatabaseURL) as ex:
         db.from_env()
     assert ex.value.message == "bad bad url"
     assert len(db.drivers._DRIVERS) == 0
Пример #14
0
 def test_from_env_override_exists(self, monkeypatch):
     db.drivers.autoregister_class(db_sqlite3.Sqlite3Driver)
     monkeypatch.setenv("ALT_URL", MEM_URL)
     db.from_env("ALT_URL")
     assert "sqlite3" in db.drivers._DRIVERS
     assert len(db.drivers._DRIVERS) == 1
Пример #15
0
 def test_from_env_override_not_exists(self, monkeypatch):
     monkeypatch.delenv("ALT_URL", raising=False)
     with pytest.raises(KeyError) as ex:
         db.from_env("ALT_URL")
     assert ex.value.message == "ALT_URL"
     assert len(db.drivers._DRIVERS) == 0
Пример #16
0
 def test_from_env_default_exists(self, monkeypatch):
     db.drivers.autoregister_class(db_sqlite3.Sqlite3Driver)
     monkeypatch.setenv("DATABASE_URL", MEM_URL)
     db.from_env()
     assert "sqlite3" in db.drivers._DRIVERS
     assert len(db.drivers._DRIVERS) == 1