Пример #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"))
Пример #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"))
Пример #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"))
Пример #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"))
Пример #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())
Пример #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_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"
		))
Пример #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()
Пример #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()
Пример #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"
		))
Пример #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"
		))
Пример #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"
		))
Пример #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"
		))
Пример #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"))
Пример #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(), "")
Пример #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(), "")