[conduit: 115/138] Remove the old automatic tests



commit 973d0f781fda370bdaa4564e7810250f580c8a2c
Author: John Carr <john carr unrouted co uk>
Date:   Wed May 6 07:18:41 2009 -0700

    Remove the old automatic tests
---
 scripts/run-tests.sh              |    7 --
 test/python-tests/AutoGenerate.py |   83 ----------------
 test/python-tests/AutoSoup.py     |  175 --------------------------------
 test/python-tests/AutoTemplate.py |  197 -------------------------------------
 4 files changed, 0 insertions(+), 462 deletions(-)

diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh
index 519fc33..6343271 100755
--- a/scripts/run-tests.sh
+++ b/scripts/run-tests.sh
@@ -15,7 +15,6 @@ Usage:\n\
 Options:\n\
     Test Types\n\
     -s NAME Perform only the test called NAME\n\
-    -a      Run the automatically generated (SLOW) tests\n\
     -D      Perform dataprovider tests\n\
     -S      Perform sync tests\n\
     -l      List (do not run) tests\n\
@@ -42,7 +41,6 @@ do_coverage=0
 do_upload=0
 do_single_test=""
 do_online="TRUE"
-do_auto=0
 do_debug=0
 do_dataprovider_tests=0
 do_sync_tests=0
@@ -51,7 +49,6 @@ do_list=0
 while getopts "acus:odDSNl" options
 do
     case $options in
-        a )     do_auto=1;;
         c )     do_coverage=1;;
         u )     do_upload=1;;
         s )     do_single_test=$OPTARG;;
@@ -97,10 +94,6 @@ else
     if [ $do_sync_tests -ne 0 ] ; then
         tests="$tests $PY_TEST_DIR/TestSync*.py"
     fi
-    if [ $do_auto -ne 0 ] ; then
-        python $PY_TEST_DIR/AutoGenerate.py
-        tests="$tests $PY_TEST_DIR/TestAuto*.py"
-    fi    
 fi
 testfiles=`ls $tests`
 
diff --git a/test/python-tests/AutoGenerate.py b/test/python-tests/AutoGenerate.py
deleted file mode 100644
index 271f0dc..0000000
--- a/test/python-tests/AutoGenerate.py
+++ /dev/null
@@ -1,83 +0,0 @@
-import sys, inspect
-import AutoSoup
-
-#common sets up the conduit environment
-from common import *
-
-# This is the python code 
-SimpleTest = """\
-#
-# DO NOT EDIT, AUTOMATICALLY GENERATED
-# 
-
-import sys, thread
-
-from AutoTemplate import *
-from AutoSoup import *
-
-try:
-    # The dataproviders we are testing
-    source = %s().instance(host)
-    sink = %s().instance(host)
-
-    # The data sample we are using
-    data = %s()
-    dataset = data.get()
-    datatype = str(data._datatype_)
-
-    # Test local <--> local
-    test_full_set(host, source, sink, datatype, dataset)
-
-    # Test networked <--> local
-    newsource = host.networked_dataprovider(source)
-    test_full_set(host, newsource, sink, datatype, dataset)
-        
-    # Test local <--> networked
-    newsink = host.networked_dataprovider(sink)
-    test_full_set(host, source, newsink, datatype, dataset)
-
-    # Test networked <--> networked
-    test_full_set(host, newsource, newsink, datatype, dataset)
-except:
-    sys.excepthook(*sys.exc_info())
-    ok("Unhandled borkage", False)
-    thread.interrupt_main()
-
-finished()"""
-
-# It's hard to pick sane combinations of dps, so heres a little rules table to help out
-# col 1 = weight. in sync folder <--> contact we need to use contact objects over file objects.
-# col 2 = a function to call to get some data.
-# As a bonus, reject combinations where col 1 is same (e.g. contact <--> event)
-rules = {}
-for name in dir(AutoSoup):
-    cls = getattr(AutoSoup, name)
-    if name[:7] == "objset_" and inspect.isclass(cls):
-        rules[cls._datatype_] = (cls._weight_, cls._name_)
-
-targets = []
-combinations = []
-
-# Cludge to gather all the dataprovider initialisers
-for name in dir(AutoSoup):
-    cls = getattr(AutoSoup, name)
-    if name[:5] == "prep_" and inspect.isclass(cls):    
-        targets.append( cls() )
-
-for source in targets:
-    for sink in targets:
-        if source != sink:
-            in_type1 = source._datatype_
-            in_type2 = sink._datatype_
-
-            if in_type1 == in_type2:
-                combinations.append( (source, sink, in_type1, rules[in_type1][1]) )
-            elif rules[in_type1][0] > rules[in_type2][0]:
-                combinations.append( (source, sink, in_type1, rules[in_type1][1]) )
-            elif rules[in_type2][0] > rules[in_type1][0]:
-                combinations.append( (source, sink, in_type2, rules[in_type2][1]) )
-
-for source, sink, datatype, dataset in combinations:
-    f = open('test/python-tests/TestAuto_%s_%s.py' % (source, sink), 'w')
-    f.write(SimpleTest % (source, sink, dataset))
-
diff --git a/test/python-tests/AutoSoup.py b/test/python-tests/AutoSoup.py
deleted file mode 100644
index b12949e..0000000
--- a/test/python-tests/AutoSoup.py
+++ /dev/null
@@ -1,175 +0,0 @@
-"""
-  This is part of the automatic test case generator
-
-  This file contains the basic building blocks of our tests - dataproviders and data.
-"""
-
-#common sets up the conduit environment
-from common import *
-
-# import any datatypes that are needed
-import conduit.datatypes.File as File
-import conduit.datatypes.Contact as Contact
-import conduit.datatypes.Event as Event
-import conduit.datatypes.Note as Note
-
-# import any dp's that we'll need to wrap
-from conduit.modules import iPodModule
-
-def dataprovider(datatype, **kwargs):
-    """ Encapsulate a prep_... function in a class """
-    def _(func):
-        class Souplet(object):
-            _datatype_ = datatype
-            _name_ = func.__name__
-            def instance(self, host):
-                return func(host)
-            def __str__(self):
-                return self._name_
-        return Souplet
-    return _
-
-def data(datatype, weight, **kwargs):
-    def _(func):
-        class Datalet(object):
-            _datatype_ = datatype
-            _weight_ = weight
-            _name_ = func.__name__
-            def get(self):
-                return func()
-            def __str__(self):
-                return self._name_
-        return Datalet
-    return _
-
- data("contact", 5)
-def objset_contacts():
-    """
-    Return a sample of contact objects
-    """
-    objs = []
-    vcards = get_files_from_data_dir("*.vcard")
-    for i in range(0, len(vcards)):
-        c = Contact.Contact()
-        c.set_from_vcard_string( read_data_file(vcards[i]) )
-        objs.append(c)
-    ok("Got %d sample contacts" % len(objs), len(objs) > 0)
-    return objs
-
- data("event", 5)
-def objset_events():
-    """
-    Return a sample of event objects
-    """
-    objs = []
-    icals = get_files_from_data_dir("*.ical")
-    for i in range(0, len(icals)):
-        c = Event.Event()
-        c.set_from_ical_string( read_data_file(icals[i]) )
-        objs.append(c)
-    ok("Got %d sample events" % len(objs), len(objs) > 0)
-    return objs
-
- data("note", 5)
-def objset_notes():
-    """
-    Return a sample of note objects
-    """
-    objs = []
-    notes = get_files_from_data_dir("*.tomboy")
-    for i in range(0, len(notes)):
-        n = Note.Note(title="Note-" + Utils.random_string())
-        n.content = read_data_file(notes[i])
-        n.raw = read_data_file(notes[i])
-        objs.append(n)
-    ok("Got %d sample notes" % len(objs), len(objs) > 0)
-    return objs
-
- data("file", 1)
-def objset_files():
-    """
-    Return a sample of file objects
-    """
-    objs = [File.File(f) for f in get_files_from_data_dir("*")]
-    ok("Got %d sample contacts" % len(objs), len(objs) > 0)
-    return objs
-
- dataprovider("event")
-def prep_ipod_calendar(host):
-    source_folder = os.path.join(os.environ['TEST_DIRECTORY'], "ipod calendar " + Utils.random_string())
-    if not os.path.exists(source_folder):
-        os.mkdir(source_folder)
-    return host.wrap_dataprovider( iPodModule.IPodCalendarTwoWay(source_folder, "") )
-
- dataprovider("contact")
-def prep_ipod_contacts(host):
-    source_folder = os.path.join(os.environ['TEST_DIRECTORY'], "ipod contacts " + Utils.random_string())
-    if not os.path.exists(source_folder):
-        os.mkdir(source_folder)
-    return host.wrap_dataprovider( iPodModule.IPodContactsTwoWay(source_folder, "") )
-
- dataprovider("note")
-def prep_ipod_notes(host):
-    source_folder = os.path.join(os.environ['TEST_DIRECTORY'], "ipod notes " + Utils.random_string())
-    if not os.path.exists(source_folder):
-        os.mkdir(source_folder)
-    return host.wrap_dataprovider( iPodModule.IPodNoteTwoWay(source_folder, "") )
-
- dataprovider("event")
-def prep_folder_calendar(host):
-    sink_folder = os.path.join(os.environ['TEST_DIRECTORY'], "folder calendar " + Utils.random_string())
-    if not os.path.exists(sink_folder):
-        os.mkdir(sink_folder)
-
-    dp = host.get_dataprovider("FolderTwoWay")
-    dp.module.set_configuration( { "folderGroupName": "calendar", "folder": "file://"+sink_folder } )
-    return dp
-
- dataprovider("contact")
-def prep_folder_contacts(host):
-    sink_folder = os.path.join(os.environ['TEST_DIRECTORY'], "folder contacts " + Utils.random_string())
-    if not os.path.exists(sink_folder):
-        os.mkdir(sink_folder)
-
-    dp = host.get_dataprovider("FolderTwoWay")
-    dp.module.set_configuration( { "folderGroupName": "contacts", "folder": "file://"+sink_folder } )
-    return dp
-
-# dataprovider("note")
-#def prep_tomboy(host):
-#    dp = host.get_dataprovider("TomboyTwoWay")
-#    return dp
-
-# dataprovider("contact")
-#def prep_evo_contacts(host):
-#    dp = host.get_dataprovider("EvoContactTwoWay")
-#    opts = dict(dp.module._addressBooks)
-#    dp.module.set_configuration( { "sourceURI": opts["conduit-test"], } )
-#    return dp
-
-# dataprovider("event")
-#def prep_evo_calendar(host):
-#    dp = host.get_dataprovider("EvoCalendarTwoWay")
-#    opts = dict(dp.module._calendarURIs)
-#    dp.module.set_configuration( { "sourceURI": opts["conduit-test"], } )
-#    return dp
-
-# dataprovider("note")
-#def prep_evo_memo(host):
-#    dp = host.get_dataprovider("EvoMemoTwoWay")
-#    opts = dict(dp.module._memoSources)
-#    dp.module.set_configuration( { "sourceURI": opts["conduit-test"], } )
-#    return dp
-
-# dataprovider("contact")
-#def prep_opensync_evo_contact(host):
-#    dp = host.get_dataprovider("OS_Evolution_Contact")
-#    dp.module.set_configuration({"source": "Test"})
-#    return dp
-
-# dataprovider("event")
-#def prep_opensync_evo_event(host):
-#    dp = host.get_dataprovider("OS_Evolution_Event")
-#    dp.module.set_configuration({"source": "Test"})
-#    return dp
-
diff --git a/test/python-tests/AutoTemplate.py b/test/python-tests/AutoTemplate.py
deleted file mode 100644
index da2f9b1..0000000
--- a/test/python-tests/AutoTemplate.py
+++ /dev/null
@@ -1,197 +0,0 @@
-import sys, threading, thread, inspect, datetime
-
-#common sets up the conduit environment
-from common import *
-
-# we are going to wrap some debugging code around our internals..
-import conduit.Synchronization as Sync
-import conduit.Exceptions as Exceptions
-
-def convert(host, fromType, toType, data):
-    return host.type_converter.convert(fromType, toType, data)
-
-def test_delete_all(dp):
-    """
-    Delete any and all objects store on a dataprovider
-    """
-    ok("Can delete from this dp", dp.module_type == "twoway" or dp.module_type == "sink")
-
-    uids = []
-
-    dp.module.refresh()
-    for uid in dp.module.get_all():
-        dp.module.delete(uid)
-
-    dp.module.refresh()
-    ok("All objects deleted", dp.module.get_num_items() == 0)
-
-def test_sync(host, should_change=True):
-    """
-    Wrapper around the sync method. It calls sync twice and checks for changes, which would
-    indicate that the mappings db has become corrupted
-    """
-    # get the counts before we start
-    a1 = host.get_source_count()
-    b1 = host.get_sink_count()
-
-    # after the first sync the counts should be the same on both sides
-    a2, b2 = host.sync()
-    ok("Sync worked (source had %s, source has %s, sink had %s, sink has %s)" % (a1, a2, b1, b2), a2==b2)
-
-    # after the third sync nothing should have changed
-    a3, b3 = host.sync()
-    ok("Sync worked (source had %s, source has %s, sink had %s, sink has %s)" % (a2, a3, b2, b3), a3==b3)
-
-    if should_change:
-        ok("Count didn't change between last 2 syncs", a2==a3 and b2==b3)
-
-    return (a2-a1, b2-b1)
-
-def test_add_data(host, dp, datatype, dataset):
-    """
-    Add some data to a dataprovider
-    """
-    for i in range(0, len(dataset)):
-        obj = convert(host, datatype, dp.in_type, dataset[i])
-        dp.module.put(obj, False)
-
-    dp.module.refresh()
-    ok("Dataset loaded into source", dp.module.get_num_items() == len(dataset)) 
-
-    test_sync(host)
-
-def test_modify_data(host, dp):
-    ok("Testing MODIFY Case (Prepare)", True)
-    dp.module.refresh()
-    uids = dp.module.get_all()
-    for uid in uids:
-        obj = dp.module.get(uid)
-        obj.set_mtime(datetime.datetime.now())
-        dp.module.put(obj, True, uid)
-    ok("Testing MODIFY Case (Sync Runs)", True)
-    test_sync(host, False)
-    ok("Testing MODIFY Case (Complete)", True)
-
-def test_delete_data(host, dp):
-    a = host.get_source_count()
-    b = host.get_sink_count()
-    ok("Testing DELETE Case (Prepare)", a==b)
-
-    dp.module.refresh()
-    uids = dp.module.get_all()
-    for uid in uids:
-        obj = dp.module.get(uid)
-        obj.set_mtime(datetime.datetime.now())
-        dp.module.delete(uid)
-
-    dp.module.refresh()
-    ok("Testing DELETE Case (Prepared)", len(dp.module.get_all()) == 0)
-
-    test_sync(host)
-    # ok("Testing DELETE Case (Complete)", a == 0 and b == 0)
-
-def test_clear(host, source, sink):
-    """
-    Ensure that both dps are blank
-    Run a combination of two way/one way and slow sync
-    """
-    test_delete_all(source)
-    test_delete_all(sink)
-
-    a, b = host.sync()
-    ok("Sync worked (%s, %s)" % (a, b), a == 0 and b == 0)
-
-def test_full(host, source, sink, datatype, dataset, twoway=True, slow=False):
-    """
-    Run all tests
-    """
-    ok("Beginning test run. Source: %s, Sink: %s, Datatype: %s, twoway: %s, Slow: %s" % (source, sink, datatype, twoway, slow), True)
- 
-    host.prepare(source, sink)
-    host.set_two_way_sync(twoway)
-    host.set_slow_sync(slow)
-
-    # Fresh data (source end), and try modifying data on both sides
-    test_clear(host, source, sink)
-    test_add_data(host, source, datatype, dataset)
-    test_modify_data(host, source)
-    test_modify_data(host, sink)
-
-    # Fresh data (source end), delete on source + sync
-    test_clear(host, source, sink)
-    test_add_data(host, source, datatype, dataset)
-    test_delete_data(host, source)
-
-    if twoway:
-        # Fresh data (source end), delete on sink + sync
-        test_clear(host, source, sink)
-        test_add_data(host, source, datatype, dataset)
-        test_delete_data(host, sink)
-
-    # Same tests again, but inject at the sink.
-    # Only makes sense in the twoway case
-    if twoway:
-        # Fresh data (source end), and try modifying data on both sides
-        test_clear(host, source, sink)
-        test_add_data(host, sink, datatype, dataset)
-        test_modify_data(host, source)
-        test_modify_data(host, sink)
-
-        # Fresh data (source end), delete on source + sync
-        test_clear(host, source, sink)
-        test_add_data(host, sink, datatype, dataset)
-        test_delete_data(host, host.source)
-
-        # Fresh data (source end), delete on sink + sync
-        test_clear(host, source, sink)
-        test_add_data(host, sink, datatype, dataset)
-        test_delete_data(host, sink)
-
-    test_clear(host, source, sink)
-
-def test_full_set(host, source, sink, datatype, dataset):
-    """
-    Call test_full 4 times to test 1way + 2way (w and w/out slow-sync)
-    """
-    try:
-        test_full(host, source, sink, datatype, dataset, True, False)
-        # test_full(host, source, sink, datatype, dataset, True, True)
-        test_full(host, source, sink, datatype, dataset, False, False)
-        # test_full(host, source, sink, datatype, dataset, False, True)
-
-    except (KeyboardInterrupt, SystemExit):
-        pass
-
-    except:
-        sys.excepthook(*sys.exc_info())
-
-    try:
-        host.model.quit()
-    except:
-        pass
-
-# Catch exceptions better
-def catch(old_func):
-    def func(*args, **kwargs):
-        try:
-            return old_func(*args, **kwargs)
-        except (KeyboardInterrupt, SystemExit):
-            raise
-        except:
-            sys.excepthook(*sys.exc_info())
-            ok("Unhandled borkage in thread or sync logic", False)
-            thread.interrupt_main()
-
-    func.__doc__ = old_func.__doc__
-    return func
-
-threading.Thread.run = catch(threading.Thread.run)
-Sync.SyncWorker.run = catch(Sync.SyncWorker.run)
-
-# Intialise sync management framework
-host = SimpleSyncTest()
-host.set_two_way_policy({
-                "conflict"  :   "replace",
-                "deleted"   :   "replace"}
-                )
-



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]