Exemplo n.º 1
0
 def test_iconutil_fails(self):
     """`iconutil` throws RuntimeError"""
     with InfoPlist():
         with FakePrograms('iconutil'):
             icns_path = os.path.join(self.tempdir, 'icon.icns')
             self.assertRaises(RuntimeError, notify.png_to_icns, PNG_PATH,
                               icns_path)
Exemplo n.º 2
0
 def test_sips_fails(self):
     """`sips` throws RuntimeError"""
     with InfoPlist():
         with FakePrograms('sips'):
             icon_path = os.path.join(self.tempdir, 'icon.png')
             self.assertRaises(RuntimeError, notify.convert_image, PNG_PATH,
                               icon_path, 64)
Exemplo n.º 3
0
 def test_first_run_with_version(self):
     """Workflow: first_run"""
     vstr = '1.9.7'
     with VersionFile(vstr):
         with InfoPlist():
             wf = Workflow()
             self.assertTrue(wf.first_run)
         wf.reset()
Exemplo n.º 4
0
 def test_notifyapp_called(self):
     """Notify.app is called"""
     c = WorkflowMock()
     with InfoPlist():
         notify.install_notifier()
         with c:
             self.assertFalse(notify.notify('Test Title', 'Test Message'))
             self.assertEqual(c.cmd[0], APPLET_PATH)
Exemplo n.º 5
0
 def test_last_version_auto_version(self):
     """Workflow: last_version auto version"""
     vstr = '1.9.7'
     with VersionFile(vstr):
         with InfoPlist():
             wf = Workflow()
             self.assertTrue(wf.set_last_version())
             self.assertEqual(wf.last_version_run, Version(vstr))
             wf.reset()
Exemplo n.º 6
0
 def test_versions_from_version_file(self):
     """Workflow: version from `version`"""
     vstr = '1.9.7'
     with VersionFile(vstr):
         with InfoPlist():
             wf = Workflow()
             self.assertEqual(str(wf.version), vstr)
             self.assertTrue(isinstance(wf.version, Version))
             self.assertEqual(wf.version, Version(vstr))
Exemplo n.º 7
0
 def test_info_plist_missing(self):
     """Info.plist missing"""
     # delete_info_plist()
     self._teardown_env()
     with InfoPlist(present=False):
         wf = Workflow()
         self.assertFalse(os.path.exists(INFO_PLIST_PATH))
         # self.assertRaises(IOError, lambda wf: wf.info, wf)
         self.assertRaises(IOError, lambda: wf.workflowdir)
Exemplo n.º 8
0
 def test_invalid_notifications(self):
     """Invalid notifications"""
     with InfoPlist():
         self.assertRaises(ValueError, notify.notify)
         # Is not installed yet
         self.assertFalse(os.path.exists(APP_PATH))
         self.assertTrue(notify.notify('Test Title', 'Test Message'))
         # A notification should appear now, but there's no way of
         # checking whether it worked
         self.assertTrue(os.path.exists(APP_PATH))
Exemplo n.º 9
0
 def test_first_run_with_previous_run(self):
     """Workflow: first_run with previous run"""
     vstr = '1.9.7'
     last_vstr = '1.9.6'
     with VersionFile(vstr):
         with InfoPlist():
             wf = Workflow()
             wf.set_last_version(last_vstr)
             self.assertTrue(wf.first_run)
             self.assertEqual(wf.last_version_run, Version(last_vstr))
         wf.reset()
Exemplo n.º 10
0
    def test_log_wf(self):
        """Workflow and Logger objects correct"""
        with InfoPlist():
            wf = notify.wf()
            self.assert_(isinstance(wf, Workflow))
            # Always returns the same objects
            wf2 = notify.wf()
            self.assert_(wf is wf2)

            log = notify.log()
            self.assert_(isinstance(log, logging.Logger))
            log2 = notify.log()
            self.assert_(log is log2)
Exemplo n.º 11
0
 def test_install(self):
     """Notify.app is installed correctly"""
     with InfoPlist():
         self.assertFalse(os.path.exists(APP_PATH))
         notify.install_notifier()
         for p in (APP_PATH, APPLET_PATH, ICON_PATH, INFO_PATH):
             self.assertTrue(os.path.exists(p))
         # Ensure applet is executable
         self.assert_(os.stat(APPLET_PATH).st_mode & stat.S_IXUSR)
         # Verify bundle ID was changed
         data = plistlib.readPlist(INFO_PATH)
         bid = data.get('CFBundleIdentifier')
         self.assertNotEqual(bid, BUNDLE_ID)
         self.assertTrue(bid.startswith(BUNDLE_ID))
Exemplo n.º 12
0
 def test_image_conversion(self):
     """PNG to ICNS conversion"""
     with InfoPlist():
         self.assertFalse(os.path.exists(APP_PATH))
         notify.install_notifier()
         self.assertTrue(os.path.exists(APP_PATH))
         icns_path = os.path.join(self.tempdir, 'icon.icns')
         self.assertFalse(os.path.exists(icns_path))
         notify.png_to_icns(PNG_PATH, icns_path)
         self.assertTrue(os.path.exists(icns_path))
         with open(icns_path, 'rb') as fp:
             h1 = hashlib.md5(fp.read())
         with open(ICON_PATH, 'rb') as fp:
             h2 = hashlib.md5(fp.read())
         self.assertEqual(h1.digest(), h2.digest())
Exemplo n.º 13
0
    def test_last_version_on(self):
        """Workflow: last_version_run not empty"""
        vstr = '1.9.7'

        with InfoPlist():
            with VersionFile(vstr):
                wf = Workflow()
                wf.set_last_version(vstr)
                self.assertEqual(Version(vstr), wf.last_version_run)
                wf.reset()
            # Set automatically
            with VersionFile(vstr):
                wf = Workflow()
                wf.set_last_version()
                self.assertEqual(Version(vstr), wf.last_version_run)
                wf.reset()
Exemplo n.º 14
0
    def test_last_version_set_after_run(self):
        """Workflow: last_version set after `run()`"""
        vstr = '1.9.7'

        def cb(wf):
            return

        with VersionFile(vstr):
            with InfoPlist():
                wf = Workflow()
                self.assertTrue(wf.last_version_run is None)
                wf.run(cb)

                wf = Workflow()
                self.assertEqual(wf.last_version_run, Version(vstr))
                wf.reset()
Exemplo n.º 15
0
 def test_paths(self):
     """Module paths are correct"""
     with InfoPlist():
         self.assertEqual(DATADIR, notify.wf().datadir)
         self.assertEqual(APPLET_PATH, notify.notifier_program())
         self.assertEqual(ICON_PATH, notify.notifier_icon_path())
Exemplo n.º 16
0
def wf():
    """Create a :class:`~workflow.Workflow` object."""
    with InfoPlist():
        yield Workflow()
Exemplo n.º 17
0
 def test_first_run_no_version(self):
     """Workflow: first_run fails on no version"""
     with InfoPlist():
         wf = Workflow()
         self.assertRaises(ValueError, lambda wf: wf.first_run, wf)