From 0a420061424c2665d02e2d46c7f590ad34ff1393 Mon Sep 17 00:00:00 2001 From: hgy59 Date: Mon, 1 Jan 2024 03:52:01 +0100 Subject: [PATCH] adjust tests for beta labels --- spkrepo/tests/test_frontend.py | 75 +++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/spkrepo/tests/test_frontend.py b/spkrepo/tests/test_frontend.py index 4e467ea..4bd76e8 100644 --- a/spkrepo/tests/test_frontend.py +++ b/spkrepo/tests/test_frontend.py @@ -24,7 +24,7 @@ def test_get_logged_user(self): class PackagesTestCase(BaseTestCase): - def test_get_active_stable(self): + def test_get_active(self): build = BuildFactory(version__report_url=None, active=True) db.session.commit() response = self.client.get(url_for("frontend.packages")) @@ -35,8 +35,8 @@ def test_get_active_stable(self): ) self.assertNotIn("beta", response.data.decode()) - def test_get_active_not_stable(self): - build = BuildFactory(active=True) + def test_get_not_active(self): + build = BuildFactory(active=False) db.session.commit() response = self.client.get(url_for("frontend.packages")) self.assert200(response) @@ -44,36 +44,58 @@ def test_get_active_not_stable(self): build.version.displaynames["enu"].displayname, response.data.decode(), ) - self.assertIn("beta", response.data.decode()) - def test_get_not_active_not_stable(self): - build = BuildFactory(active=False) + +class PackageTestCase(BaseTestCase): + def test_get_active_stable(self): + build = BuildFactory( + version__package__author=UserFactory(), + version__report_url=None, + active=True, + ) db.session.commit() - response = self.client.get(url_for("frontend.packages")) + response = self.client.get( + url_for("frontend.package", name=build.version.package.name) + ) self.assert200(response) - self.assertNotIn( + for a in build.architectures: + self.assertIn(a.code, response.data.decode()) + self.assertIn( build.version.displaynames["enu"].displayname, response.data.decode(), ) + self.assertIn( + build.version.descriptions["enu"].description, + response.data.decode(), + ) self.assertNotIn("beta", response.data.decode()) def test_get_not_active_stable(self): - build = BuildFactory(active=False) + build = BuildFactory( + version__package__author=UserFactory(), + version__report_url=None, + active=False, + ) db.session.commit() - response = self.client.get(url_for("frontend.packages")) + response = self.client.get( + url_for("frontend.package", name=build.version.package.name) + ) self.assert200(response) - self.assertNotIn( + for a in build.architectures: + self.assertIn(a.code, response.data.decode()) + self.assertIn( build.version.displaynames["enu"].displayname, response.data.decode(), ) + self.assertIn( + build.version.descriptions["enu"].description, + response.data.decode(), + ) self.assertNotIn("beta", response.data.decode()) - -class PackageTestCase(BaseTestCase): - def test_get(self): + def test_get_active_not_stable(self): build = BuildFactory( version__package__author=UserFactory(), - version__report_url=None, active=True, ) db.session.commit() @@ -91,6 +113,29 @@ def test_get(self): build.version.descriptions["enu"].description, response.data.decode(), ) + self.assertIn("beta", response.data.decode()) + + def test_get_not_active_not_stable(self): + build = BuildFactory( + version__package__author=UserFactory(), + active=False, + ) + db.session.commit() + response = self.client.get( + url_for("frontend.package", name=build.version.package.name) + ) + self.assert200(response) + for a in build.architectures: + self.assertIn(a.code, response.data.decode()) + self.assertIn( + build.version.displaynames["enu"].displayname, + response.data.decode(), + ) + self.assertIn( + build.version.descriptions["enu"].description, + response.data.decode(), + ) + self.assertIn("beta", response.data.decode()) def test_get_no_package(self): response = self.client.get(url_for("frontend.package", name="no-package"))