From edc7af334005a32514c311a7ce5fe73d4e2f7411 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 13 May 2012 14:25:00 +0100 Subject: [PATCH] More unit-tests for apps --- tests/testdownload.py | 11 +++++++++++ tests/testinstall.py | 26 +++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/testdownload.py b/tests/testdownload.py index 4300f6c..fc9fb13 100755 --- a/tests/testdownload.py +++ b/tests/testdownload.py @@ -475,6 +475,8 @@ class TestDownload(BaseTest): trust.trust_db.trust_key('DE937DD411906ACF7C263B396FCF121BE2390E0B', 'example.com:8000') + global ran_gui + with output_suppressed(): # Select a version of Hello run_server('Hello.xml', '6FCF121BE2390E0B.gpg', 'HelloWorld.tgz') @@ -492,6 +494,7 @@ class TestDownload(BaseTest): selections_path = os.path.join(app.path, 'selections.xml') def reset_timestamps(): + ran_gui = False os.utime(timestamp, (1, 1)) # 1970 os.utime(selections_path, (1, 1)) if os.path.exists(last_check_attempt): @@ -589,6 +592,14 @@ class TestDownload(BaseTest): assert ran_gui kill_server_process() + # Update not triggered because of last-check-attempt + ran_gui = False + os.utime(timestamp, (1, 1)) # 1970 + os.utime(selections_path, (1, 1)) + dl = app.download_selections(sels) + assert dl == None + assert not ran_gui + if __name__ == '__main__': try: unittest.main() diff --git a/tests/testinstall.py b/tests/testinstall.py index e36703b..a765cf2 100755 --- a/tests/testinstall.py +++ b/tests/testinstall.py @@ -358,14 +358,38 @@ class TestInstall(BaseTest): assert not err, err os.rmdir(tmp) - def testAdd(self): + def testApps(self): out, err = self.run_0install(['add', 'local-app']) assert out.lower().startswith("usage:") + out, err = self.run_0install(['destroy', 'local-app', 'uri']) + assert out.lower().startswith("usage:") + local_feed = os.path.join(mydir, 'Local.xml') + + out, err = self.run_0install(['add', 'local:app', local_feed]) + assert not out, out + assert "Invalid application name 'local:app'" in err, err + out, err = self.run_0install(['add', 'local-app', local_feed]) assert not out, out assert not err, err + out, err = self.run_0install(['add', 'local-app', local_feed]) + assert not out, out + assert "Application 'local-app' already exists" in err, err + + out, err = self.run_0install(['update', 'local-app']) + assert "No updates found. Continuing with version 0.1." in out, out + assert not err, err + + out, err = self.run_0install(['destroy', 'local-app']) + assert not out, out + assert not err, err + + out, err = self.run_0install(['destroy', 'local-app']) + assert not out, out + assert "No such application 'local-app'" in err, err + if __name__ == '__main__': unittest.main() -- 2.11.4.GIT