From 4c4907ef332b18ae120eb085e04e783d41a60fe8 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Thu, 22 Sep 2016 11:54:29 +0300 Subject: Added notifications, tests --- functions.py | 10 +++++----- tests.py | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) mode change 100644 => 100755 tests.py diff --git a/functions.py b/functions.py index 9fa4b4e..6b76dc4 100644 --- a/functions.py +++ b/functions.py @@ -12,12 +12,16 @@ from system_profiler import SystemProfile SERVICEDIR = '/Library/Services' +def display_notification(msg, title='', subtitle=''): + osascript('display notification "{0}" with title "{1}" subtitle "{2}"'.format(msg, title, subtitle)) + + def ditto(src, dst): subprocess.call(['/usr/bin/ditto', src, dst]) def rsync(src, dst, flags='auE'): - subprocess.call(['rsync', '-' + flags, src, dst]) + subprocess.call(['/usr/bin/rsync', '-' + flags, src, dst]) def dscl(domain='.', *args): @@ -216,7 +220,3 @@ def install_service(src): os.mkdir(SERVICEDIR) ditto(src, SERVICEDIR) - - -if __name__ == '__main__': - delete_user('demouser') diff --git a/tests.py b/tests.py old mode 100644 new mode 100755 index 553b5ed..493fc0f --- a/tests.py +++ b/tests.py @@ -1,9 +1,11 @@ +#!/usr/bin/env python # -*- coding: utf-8 -*- import logging import subprocess from unittest import main, skip, TestCase +import functions as mh import system_profiler @@ -24,7 +26,7 @@ class SystemProfilerTestCase(TestCase): def testOsVersion(self): """ - Check that the OS version we get from SP is contained + Check that the OS version we get from SP is contained in the output of sw_vers """ build = subprocess.check_output(['sw_vers', '-buildVersion']).strip() @@ -53,6 +55,20 @@ class AppsTestCase(TestCase): self.assertTrue(len(results) > 10) +class FunctionsTestCase(TestCase): + def setUp(self): + self.stickes = '/Applications/Stickies.app' + + def test_notification(self): + mh.display_notification('blaaa') + + def test_add_login_item(self): + mh.add_login_item(self.stickes) + + def test_remove_login_item(self): + mh.remove_login_item(path=self.stickes) + + if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) main() -- cgit v1.2.3