Exemplo n.º 1
0
 def test_collect_hosts_called(self, mwrite, mdumps, pCLConf,
                               mrender_template, mcollect_hosts):
     make_dashboard()
     mcollect_hosts.assert_called_once_with(
         pCLConf.return_value[HOSTS_FILE_STR],
         pCLConf.return_value[HOSTS_SECTION_STR],
     )
Exemplo n.º 2
0
 def test_render_dashboard_template_called(self, mwrite, mdumps, pCLConf,
                                           mrender_template,
                                           mcollect_hosts):
     hosts = ["winni", "peg", "glez"]
     mcollect_hosts.return_value = hosts
     make_dashboard()
     mrender_template.assert_has_calls([call(h) for h in hosts],
                                       any_order=True)
Exemplo n.º 3
0
 def test_json_created_from_rendered_template(self, mwrite, mdumps, pCLConf,
                                              mrender_template,
                                              mcollect_hosts):
     hosts = [334, "a"]
     jsons = ["aa", "xx"]
     mcollect_hosts.return_value = hosts
     mrender_template.side_effect = jsons
     make_dashboard()
     mdumps.assert_has_calls([call(j, indent=4) for j in jsons])
Exemplo n.º 4
0
 def test_print_out_result(self, mwrite, mdumps, pCLConf, mrender_template,
                           mcollect_hosts):
     hosts = ["t", None, 0, "-----"]
     jsons = ["a", "v", "z", "D"]
     mcollect_hosts.return_value = hosts
     mdumps.side_effect = jsons
     make_dashboard()
     expected_calls = [call(_, h) for _, h in zip(jsons, hosts)]
     mwrite.assert_has_calls(expected_calls, any_order=True)
Exemplo n.º 5
0
    def test_creates_CLConf_object(self, mwrite, mdumps, pCLConf,
                                   mrender_template, mcollect_hosts):
        expected_args = (
            ("hosts", (("hosts", ), {
                "metavar": HOSTS_FILE_METAVAR,
                "help": MAKE_DASHBOARD_HOSTS_HELP
            })),
            ("section", ((HOSTS_SECTION_SHORT_OPTION,
                          HOSTS_SECTION_LONG_OPTION), {
                              "metavar": HOSTS_SECTION_METAVAR,
                              "help": HOSTS_SECTION_HELP,
                              "default": HOSTS_FILE_STR,
                          })),
        )
        make_dashboard()

        pCLConf.assert_called_once_with(
            description=MAKE_DASHBOARD_DESCRIPTION,
            arguments=expected_args,
        )
Exemplo n.º 6
0
 def test_exceptions_converted_to_SystemExit(self, mwrite, mdumps, pCLConf,
                                             mrender_template,
                                             mcollect_hosts):
     mcollect_hosts.side_effect = Exception("empty message")
     with self.assertRaises(SystemExit):
         make_dashboard()