Some simple and proposed tests for the ScriptDB object. These pass OK with ./manage.py test, at least after running the server at least once.
This commit is contained in:
parent
12c2402dac
commit
2b2d222e83
1 changed files with 50 additions and 11 deletions
|
|
@ -1,19 +1,58 @@
|
||||||
|
try:
|
||||||
|
# this is an optimized version only available in later Django versions
|
||||||
|
from django.utils.unittest import TestCase
|
||||||
|
except ImportError:
|
||||||
|
# if the first fails, we use the old version
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
from src.scripts.models import ScriptDB, ObjectDoesNotExist
|
||||||
|
from src.utils.create import create_script
|
||||||
|
from src.scripts import DoNothing
|
||||||
import unittest
|
import unittest
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
class TestScriptDB(unittest.TestCase):
|
|
||||||
def test___init__(self):
|
|
||||||
# script_d_b = ScriptDB(*args, **kwargs)
|
|
||||||
assert True # TODO: implement your test here
|
|
||||||
|
|
||||||
def test_at_typeclass_error(self):
|
class TestScriptDB(TestCase):
|
||||||
# script_d_b = ScriptDB(*args, **kwargs)
|
"Check the singleton/static ScriptDB object works correctly"
|
||||||
# self.assertEqual(expected, script_d_b.at_typeclass_error())
|
def setUp(self):
|
||||||
assert True # TODO: implement your test here
|
self.scr = create_script(DoNothing)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.scr.delete()
|
||||||
|
del self.scr
|
||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
# script_d_b = ScriptDB(*args, **kwargs)
|
"Check the script is removed from the database"
|
||||||
# self.assertEqual(expected, script_d_b.delete())
|
self.scr.delete()
|
||||||
assert True # TODO: implement your test here
|
self.assertFalse(self.scr in ScriptDB.objects.get_all_scripts())
|
||||||
|
|
||||||
|
def test_double_delete(self):
|
||||||
|
"What should happen? Isn't it already deleted?"
|
||||||
|
self.scr.delete()
|
||||||
|
self.scr.delete()
|
||||||
|
|
||||||
|
@unittest.skip("not implemented")
|
||||||
|
def test___init__fails(self): # Users should be told not to do this
|
||||||
|
with self.assertRaises(Exception):
|
||||||
|
ScriptDB()
|
||||||
|
|
||||||
|
@unittest.skip("not implemented")
|
||||||
|
def test_deleted_script_fails_start(self):
|
||||||
|
"Would it ever be necessary to start a deleted script?"
|
||||||
|
self.scr.delete()
|
||||||
|
with self.assertRaises(ObjectDoesNotExist): # See issue #509
|
||||||
|
self.scr.start()
|
||||||
|
# Check the script is not recreated as a side-effect
|
||||||
|
self.assertFalse(self.scr in ScriptDB.objects.get_all_scripts())
|
||||||
|
self.scr = create_script(DoNothing) # for tearDown()
|
||||||
|
|
||||||
|
@unittest.skip("not implemented")
|
||||||
|
def test_deleted_script_is_invalid(self):
|
||||||
|
"Can deleted scripts be said to be valid?"
|
||||||
|
self.scr.delete()
|
||||||
|
self.assertFalse(self.scr.is_valid()) # assertRaises? See issue #509
|
||||||
|
self.scr = create_script(DoNothing) # for tearDown()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue