def test_with_exception(self, register_mock):
     register_mock.side_effect = ValueError
     with tempfile.NamedTemporaryFile() as f:
         f.write(u'{}\n'.encode('utf-8'))
         f.flush()
         sys.argv.append(f.name)
         return_code = register_nodes.main()
     self.assertEqual(1, return_code)
 def test_with_arguments(self, register_mock):
     with tempfile.NamedTemporaryFile() as f:
         f.write(u'{}\n'.encode('utf-8'))
         f.flush()
         sys.argv.append(f.name)
         return_code = register_nodes.main()
     register_mock.has_calls([mock.call("seed", "{}")])
     self.assertEqual(0, return_code)
 def test_with_exception(self, register_mock):
     register_mock.side_effect = ValueError
     with tempfile.NamedTemporaryFile() as f:
         f.write(u'{}\n'.encode('utf-8'))
         f.flush()
         sys.argv.append(f.name)
         return_code = register_nodes.main()
     self.assertEqual(1, return_code)
    def test_with_arguments_ironic(self, register_mock,
                                   using_ironic_mock,
                                   get_keystone_client_mock,
                                   get_ironic_client_mock):
        with tempfile.NamedTemporaryFile() as f:
            f.write(u'{}\n'.encode('utf-8'))
            f.flush()
            sys.argv.append(f.name)
            return_code = register_nodes.main()

        register_mock.assert_called_once_with(
            "seed", {}, client='ironic_client_mock', remove=False)
        using_ironic_mock.assert_called_once_with(
            keystone='keystone_client_mock')
        get_keystone_client_mock.assert_called_once_with()
        get_ironic_client_mock.assert_called_once_with()

        self.assertEqual(0, return_code)
    def test_with_arguments_ironic(self, register_mock, using_ironic_mock,
                                   get_keystone_client_mock,
                                   get_ironic_client_mock):
        with tempfile.NamedTemporaryFile() as f:
            f.write(u'{}\n'.encode('utf-8'))
            f.flush()
            sys.argv.append(f.name)
            return_code = register_nodes.main()

        register_mock.assert_called_once_with("seed", {},
                                              client='ironic_client_mock',
                                              remove=False)
        using_ironic_mock.assert_called_once_with(
            keystone='keystone_client_mock')
        get_keystone_client_mock.assert_called_once_with()
        get_ironic_client_mock.assert_called_once_with()

        self.assertEqual(0, return_code)