Commit c9c4f19e authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Split GanetiUnitTest into testutils.py

Reviewed-by: iustinp
parent bcfbed6b
......@@ -12,5 +12,5 @@ check-am: do-pre-check
do-pre-check:
$(MAKE) -C $(top_builddir) pre-check
EXTRA_DIST = $(TESTS) mocks.py $(wildcard data/*.txt)
EXTRA_DIST = $(TESTS) testutils.py mocks.py $(wildcard data/*.txt)
CLEANFILES = *.py[co]
......@@ -33,6 +33,7 @@ import shutil
import re
import ganeti
import testutils
from ganeti import constants
from ganeti import utils
from ganeti.utils import IsProcessAlive, Lock, Unlock, RunCmd, \
......@@ -43,18 +44,6 @@ from ganeti.utils import IsProcessAlive, Lock, Unlock, RunCmd, \
from ganeti.errors import LockError, UnitParseError
class GanetiTestCase(unittest.TestCase):
def assertFileContent(self, file_name, content):
"""Checks the content of a file.
"""
handle = open(file_name, 'r')
try:
self.assertEqual(handle.read(), content)
finally:
handle.close()
class TestIsProcessAlive(unittest.TestCase):
"""Testing case for IsProcessAlive"""
def setUp(self):
......@@ -362,7 +351,7 @@ class TestParseUnit(unittest.TestCase):
self.assertRaises(UnitParseError, ParseUnit, '1,3' + suffix)
class TestSshKeys(GanetiTestCase):
class TestSshKeys(testutils.GanetiTestCase):
"""Test case for the AddAuthorizedKey function"""
KEY_A = 'ssh-dss AAAAB3NzaC1w5256closdj32mZaQU root@key-a'
......@@ -432,7 +421,7 @@ class TestSshKeys(GanetiTestCase):
" ssh-dss AAAAB3NzaC1w520smc01ms0jfJs22 root@key-b\n")
class TestEtcHosts(GanetiTestCase):
class TestEtcHosts(testutils.GanetiTestCase):
"""Test functions modifying /etc/hosts"""
def setUp(self):
......
#
#
# Copyright (C) 2006, 2007, 2008 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Utilities for unit testing"""
import unittest
class GanetiTestCase(unittest.TestCase):
def assertFileContent(self, file_name, content):
"""Checks the content of a file.
"""
handle = open(file_name, 'r')
try:
self.assertEqual(handle.read(), content)
finally:
handle.close()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment