Exemplo n.º 1
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"))
Exemplo n.º 2
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"))
Exemplo n.º 3
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"))
Exemplo n.º 4
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"))
Exemplo n.º 5
0
	def render(self):
		if not self.args.hooks_only:
			view = DefaultView()
			view.assign("applications", self.applications)
			view.assign("args", self.args)
			view.render()
		exit(self.status_code())
Exemplo n.º 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"))
Exemplo n.º 7
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"
		))
Exemplo n.º 8
0
 def render(self):
     # @TODO It is not in the Tracer API yet
     args = self.args if self.args else dnf.util.Bunch(all=False, quiet=False)
     view = DefaultView()
     view.assign("applications", self.apps)
     view.assign("args", args)
     return view.render()
Exemplo n.º 9
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"
		))
 def render(self):
     # @TODO It is not in the Tracer API yet
     args = self.args if self.args else dnf.util.Bunch(all=False, quiet=False)
     view = DefaultView()
     view.assign("applications", self.apps)
     view.assign("args", args)
     return view.render()
Exemplo n.º 11
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(), (
			"There are:\n"
			"  - 2 processes requiring restart of your session (i.e. Logging out & Logging in again)\n"
			"  - 1 processes requiring reboot\n"
		))
Exemplo n.º 12
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"
		))
Exemplo n.º 13
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"
		))
Exemplo n.º 14
0
	def test_default_all_session(self):
		view = DefaultView(self.out)
		view.assign("args", ArgsMock(all=True))
		view.assign("applications", ApplicationsCollection([
			Application({"type": "session", "name": "foo", "helper": "h1"}),
			Application({"type": "session", "name": "bar", "helper": "h2"}),
			Application({"type": "session", "name": "baz", "helper": "h3"}),
		]))
		view.render()
		self.assertEquals(self.out.getvalue(), (
			"You should restart:\n"
			"  * These applications restarting your session:\n"
			"      bar\n"
			"      baz\n"
			"      foo\n"
		))
Exemplo n.º 15
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"))
Exemplo n.º 16
0
	def test_default_none(self):
		view = DefaultView(self.out)
		view.assign("args", ArgsMock())
		view.assign("applications", ApplicationsCollection([]))
		view.render()
		self.assertEquals(self.out.getvalue(), "")
Exemplo n.º 17
0
 def test_default_none(self):
     view = DefaultView(self.out)
     view.assign("args", ArgsMock())
     view.assign("applications", ApplicationsCollection([]))
     view.render()
     self.assertEquals(self.out.getvalue(), "")