Skip to content

Commit

Permalink
Make test importable without accessing the internet
Browse files Browse the repository at this point in the history
  • Loading branch information
hugobuddel committed Jan 17, 2024
1 parent 7fac8cc commit a942ef7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions scopesim/tests/tests_server/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def mock_client():
yield client


@pytest.fixture(scope="class")
def all_pkg():
# TODO: This could use some kind of mock to avoid server access
yield db.get_all_package_versions()


@pytest.mark.webtest
def test_package_list_loads():
with pytest.warns(DeprecationWarning):
Expand All @@ -40,22 +46,20 @@ def test_get_all_latest():

@pytest.mark.webtest
class TestGetZipname:
# TODO: This could use some kind of mock to avoid server access
all_pkg = db.get_all_package_versions()

def test_gets_stable(self):
zipname = db._get_zipname("test_package", "stable", self.all_pkg)
def test_gets_stable(self, all_pkg):
zipname = db._get_zipname("test_package", "stable", all_pkg)
assert zipname.startswith("test_package.")
assert zipname.endswith(".zip")

def test_gets_latest(self):
zipname = db._get_zipname("test_package", "latest", self.all_pkg)
def test_gets_latest(self, all_pkg):
zipname = db._get_zipname("test_package", "latest", all_pkg)
assert zipname.startswith("test_package.")
assert zipname.endswith(".dev.zip")

def test_throws_for_nonexisting_release(self):
def test_throws_for_nonexisting_release(self, all_pkg):
with pytest.raises(ValueError):
db._get_zipname("test_package", "bogus", self.all_pkg)
db._get_zipname("test_package", "bogus", all_pkg)


@pytest.mark.webtest
Expand Down

0 comments on commit a942ef7

Please sign in to comment.