from unittest.mock import patch, PropertyMock
import unittest
from pathlib import Path

import jinja2

import portinus

test_dir = Path(__file__).absolute().parent
test_data_dir = Path(test_dir).joinpath("testdata")
portinus_dir = str(test_data_dir.joinpath('portinus_dir'))

class testInit(unittest.TestCase):

    def setUp(self):
        pass

    @patch.object(portinus, 'service_dir')
    @patch('builtins.print')
    def test_list(self, fake_print, fake_service_dir):
        portinus.service_dir = portinus_dir
        portinus.list()
        self.assertEqual(str(fake_print.mock_calls[-2]),"call('bar')")
        self.assertEqual(str(fake_print.mock_calls[-1]),"call('baz')")

    def test_get_instance_dir(self):
        res = portinus.get_instance_dir('foo')

    def test_get_template(self):
        template = portinus.get_template('instance.service')
        self.assertTrue(isinstance(template, jinja2.Template))

class testApplication(unittest.TestCase):

    def setUp(self):
        pass

    @patch('subprocess.check_output')
    @patch.object(portinus.restart, 'Timer')
    @patch.object(portinus.monitor, 'Service')
    def test_init(self, fake_monitor_service, fake_restart_timer, fake_check_output):
        app = portinus.Application('foo')
        self.assertTrue(fake_restart_timer.called)
        self.assertTrue(fake_monitor_service.called)

@@ -111,16 +111,49 @@
 portinus
+%0Afrom portinus import Application
 %0A%0Atest_d
@@ -1036,46 +1036,8 @@
 ss%0A%0A
-    @patch('subprocess.check_output')%0A
     
@@ -1132,226 +1132,1773 @@
     
-def test_init(self, fake_monitor_service, fake_restart_timer, fake_check_output):%0A        app = portinus.Application('foo')%0A        self.assertTrue(fake_restart_timer.called)%0A        self.assertTrue(fake_monitor_servic
+@patch.object(portinus, 'Service')%0A    @patch.object(portinus, 'EnvironmentFile')%0A    def test_init(self, fake_environment_file, fake_service,%0A                  fake_monitor_service, fake_restart_timer):%0A        app = Application('foo')%0A        self.assertTrue(fake_restart_timer.called)%0A        self.assertTrue(fake_monitor_service.called)%0A        self.assertTrue(fake_service.called)%0A        self.assertTrue(fake_environment_file.called)%0A%0A    @patch.object(portinus.restart, 'Timer')%0A    @patch.object(portinus.monitor, 'Service')%0A    @patch.object(portinus, 'Service')%0A    @patch.object(portinus, 'EnvironmentFile')%0A    @patch.object(Application, '_create_service_dir')%0A    def test_ensure(self, fake__create_service_dir, fake_environment_file,%0A                    fake_service, fake_monitor_service, fake_restart_timer):%0A        app = Application('foo')%0A        app.ensure()%0A%0A        self.assertTrue(fake__create_service_dir.called)%0A        self.assertTrue(fake_environment_file().ensure.called)%0A        self.assertTrue(fake_service().ensure.called)%0A        self.assertTrue(fake_monitor_service().ensure.called)%0A        self.assertTrue(fake_restart_timer().ensure.called)%0A%0A    @patch.object(portinus.restart, 'Timer')%0A    @patch.object(portinus.monitor, 'Service')%0A    @patch.object(portinus, 'Service')%0A    @patch.object(portinus, 'EnvironmentFile')%0A    def test_remove(self, fake_environment_file,%0A                    fake_service, fake_monitor_service, fake_restart_timer):%0A        app = Application('foo')%0A        app.remove()%0A%0A        self.assertTrue(fake_environment_file().remove.called)%0A        self.assertTrue(fake_service().remove.called)%0A        self.assertTrue(fake_monitor_service().remove.called)%0A        self.assertTrue(fake_restart_timer().remov
 e.ca

Add tests for most of __init__