예제 #1
0
 def test_default_note_only(self):
     view = DefaultView(self.out)
     view.assign("args", ArgsMock())
     view.assign(
         "applications",
         ApplicationsCollection([
             Application({
                 "type": "session",
                 "name": "foo",
                 "helper": "h1"
             }),
             Application({
                 "type": "session",
                 "name": "bar",
                 "helper": "h2"
             }),
             Application({
                 "type": "static",
                 "name": "baz",
                 "helper": "h3"
             }),
         ]))
     view.render()
     self.assertEquals(self.out.getvalue(), (
         "You should restart:\n"
         "There are:\n"
         "  - 2 processes requiring restart of your session (i.e. Logging out & Logging in again)\n"
         "  - 1 processes requiring reboot\n"))
예제 #2
0
 def test_default_without_helpers(self):
     view = DefaultView(self.out)
     view.assign("args", ArgsMock())
     view.assign(
         "applications",
         ApplicationsCollection([
             Application({
                 "type": "application",
                 "name": "foo",
                 "helper": None
             }),
             Application({
                 "type": "application",
                 "name": "bar",
                 "helper": None
             }),
             Application({
                 "type": "application",
                 "name": "baz",
                 "helper": None
             }),
         ]))
     view.render()
     self.assertEquals(self.out.getvalue(),
                       ("You should restart:\n"
                        "  * These applications manually:\n"
                        "      bar\n"
                        "      baz\n"
                        "      foo\n"))
예제 #3
0
 def test_default_with_helpers(self):
     view = DefaultView(self.out)
     view.assign("args", ArgsMock())
     view.assign(
         "applications",
         ApplicationsCollection([
             Application({
                 "type": "application",
                 "helper": "first helper",
                 "name": None
             }),
             Application({
                 "type": "application",
                 "helper": "second helper",
                 "name": None
             }),
             Application({
                 "type": "application",
                 "helper": "third helper",
                 "name": None
             }),
         ]))
     view.render()
     self.assertEquals(self.out.getvalue(),
                       ("You should restart:\n"
                        "  * Some applications using:\n"
                        "      first helper\n"
                        "      second helper\n"
                        "      third helper\n"))
예제 #4
0
 def test_default_all_static(self):
     view = DefaultView(self.out)
     view.assign("args", ArgsMock(all=True))
     view.assign(
         "applications",
         ApplicationsCollection([
             Application({
                 "type": "static",
                 "name": "foo",
                 "helper": "h1"
             }),
             Application({
                 "type": "static",
                 "name": "bar",
                 "helper": "h2"
             }),
             Application({
                 "type": "static",
                 "name": "baz",
                 "helper": "h3"
             }),
         ]))
     view.render()
     self.assertEquals(self.out.getvalue(),
                       ("You should restart:\n"
                        "  * These applications rebooting your computer:\n"
                        "      bar\n"
                        "      baz\n"
                        "      foo\n"))
예제 #5
0
	def test_applications_sorted(self):
		default_type = Applications.DEFAULT_TYPE
		a1 = Application({'name': 'foo', 'helper': 'bar', 'type': default_type})
		a2 = Application({'name': 'baz', 'helper': 'qux', 'type': default_type})
		a3 = Application({'name': 'quux', 'helper': 'corge', 'type': default_type})
		collection = ApplicationsCollection([a1, a2, a3])

		self.assertEqual(collection.sorted('name'), ApplicationsCollection([a2, a1, a3]))
		self.assertEqual(collection.sorted('helper'), ApplicationsCollection([a1, a3, a2]))
		self.assertIsInstance(collection, ApplicationsCollection)
예제 #6
0
 def test_default_not_all(self):
     view = DefaultView(self.out)
     view.assign("args", ArgsMock())
     view.assign(
         "applications",
         ApplicationsCollection([
             Application({
                 "type": "application",
                 "helper": "first helper",
                 "name": None
             }),
             Application({
                 "type": "application",
                 "helper": "second helper",
                 "name": None
             }),
             Application({
                 "type": "application",
                 "name": "foo",
                 "helper": None
             }),
             Application({
                 "type": "application",
                 "name": "bar",
                 "helper": None
             }),
             Application({
                 "type": "session",
                 "name": "baz",
                 "helper": "h1"
             }),
             Application({
                 "type": "session",
                 "name": "qux",
                 "helper": "h2"
             }),
             Application({
                 "type": "static",
                 "name": "aaa",
                 "helper": "h3"
             }),
         ]))
     view.render()
     self.assertEquals(self.out.getvalue(), (
         "You should restart:\n"
         "  * Some applications using:\n"
         "      first helper\n"
         "      second helper\n"
         "\n"
         "  * These applications manually:\n"
         "      bar\n"
         "      foo\n"
         "\n"
         "Additionally to those process above, there are:\n"
         "  - 2 processes requiring restart of your session (i.e. Logging out & Logging in again)\n"
         "  - 1 processes requiring reboot\n"))
예제 #7
0
	def test_contains_formating(self):
		a1 = Application({"name": "foo", "type": "applicaiton", "helper": "some helper"})
		a3 = Application({"name": "foo", "type": "application", "helper": "some helper with {FOO} argument"})
		self.assertFalse(a1.helper_contains_formating)
		self.assertTrue(a3.helper_contains_formating)
예제 #8
0
	def test_contains_name(self):
		a1 = Application({"name": "foo", "type": "applicaiton", "helper": "some helper"})
		a2 = Application({"name": "foo", "type": "application", "helper": "some helper with {NAME} argument"})
		self.assertFalse(a1.helper_contains_name)
		self.assertTrue(a2.helper_contains_name)
예제 #9
0
	def test_representations(self):
		rule = Application({"name": "foo"})
		self.assertEquals(str(rule), "<Application: foo>")
		self.assertEquals(repr(rule), "<Application: foo>")
예제 #10
0
 def test_default_all(self):
     view = DefaultView(self.out)
     view.assign("args", ArgsMock(all=True))
     view.assign(
         "applications",
         ApplicationsCollection([
             Application({
                 "type": "application",
                 "helper": "first helper",
                 "name": None
             }),
             Application({
                 "type": "application",
                 "helper": "second helper",
                 "name": None
             }),
             Application({
                 "type": "application",
                 "name": "foo",
                 "helper": None
             }),
             Application({
                 "type": "application",
                 "name": "bar",
                 "helper": None
             }),
             Application({
                 "type": "session",
                 "name": "baz",
                 "helper": "h1"
             }),
             Application({
                 "type": "session",
                 "name": "qux",
                 "helper": "h2"
             }),
             Application({
                 "type": "static",
                 "name": "aaa",
                 "helper": "h3"
             }),
             Application({
                 "type": "static",
                 "name": "bbb",
                 "helper": "h4"
             }),
         ]))
     view.render()
     self.assertEquals(self.out.getvalue(),
                       ("You should restart:\n"
                        "  * Some applications using:\n"
                        "      first helper\n"
                        "      second helper\n"
                        "\n"
                        "  * These applications manually:\n"
                        "      bar\n"
                        "      foo\n"
                        "\n"
                        "  * These applications restarting your session:\n"
                        "      baz\n"
                        "      qux\n"
                        "\n"
                        "  * These applications rebooting your computer:\n"
                        "      aaa\n"
                        "      bbb\n"))