commit-gnue
[Top][All Lists]
Advanced

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

gnue/geas TODO examples/python/neil_methods_tes...


From: Neil Tiffin
Subject: gnue/geas TODO examples/python/neil_methods_tes...
Date: Sun, 23 Sep 2001 12:57:10 -0400

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Neil Tiffin <address@hidden>    01/09/23 12:57:10

Modified files:
        geas           : TODO 
        geas/examples/python: neil_methods_test.py 

Log message:
        Improve testing to find all kinds of query problems in geas.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/TODO.diff?cvsroot=OldCVS&tr1=1.71&tr2=1.72&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/examples/python/neil_methods_test.py.diff?cvsroot=OldCVS&tr1=1.6&tr2=1.7&r1=text&r2=text

Patches:
Index: gnue/geas/TODO
diff -u gnue/geas/TODO:1.71 gnue/geas/TODO:1.72
--- gnue/geas/TODO:1.71 Fri Sep 21 14:39:45 2001
+++ gnue/geas/TODO      Sun Sep 23 12:57:10 2001
@@ -1,4 +1,4 @@
-$Id: TODO,v 1.71 2001/09/21 18:39:45 ntiffin Exp $
+$Id: TODO,v 1.72 2001/09/23 16:57:10 ntiffin Exp $
 
 Parts of GEAS:
 --------------
@@ -36,7 +36,8 @@
     too slow.
 14. Bug: UNIQUE INDEX() does not work in gcd files.
 15. Bug: Query returns different results between geas and psql for the
-    same logic.
+    same logic.  "startswith" condition is actually returning "endswith"
+    results.
 
 Planned for 0.2.0:
 
Index: gnue/geas/examples/python/neil_methods_test.py
diff -u gnue/geas/examples/python/neil_methods_test.py:1.6 
gnue/geas/examples/python/neil_methods_test.py:1.7
--- gnue/geas/examples/python/neil_methods_test.py:1.6  Sun Sep 23 10:18:11 2001
+++ gnue/geas/examples/python/neil_methods_test.py      Sun Sep 23 12:57:10 2001
@@ -3,7 +3,7 @@
 # a test file: relies on GEAS being run from gnue/geas/src
 # and this from gnue/geas/examples/python
 
-# $Id: neil_methods_test.py,v 1.6 2001/09/23 14:18:11 ntiffin Exp $
+# $Id: neil_methods_test.py,v 1.7 2001/09/23 16:57:10 ntiffin Exp $
 
 import sys
 import md5
@@ -11,6 +11,10 @@
 import whrandom
 from string import * 
 
+print "neil_methods_test.py"
+print time.asctime(time.gmtime()), "UTC"
+print
+
 try:
     import CORBA
     CORBA._load_idl("../../idl/geas.idl")
@@ -88,14 +92,12 @@
       return []   
    return obj_list
 print
-print "This query test requires the zip code database be loaded into GEAS.  
Email"
-print "address@hidden if you do not have a copy of it"
+print "This query test requires the zip code database be loaded into GEAS."
+print "Email address@hidden if you do not have a copy of it"
 print "or you can get it from:"
 print "http://www.gnuenterprise.org/~neilt/insert-en-us-zipcodes.geas";
 print
 num_loops = 50
-print "neil_methods_test.py"
-print time.asctime(time.gmtime()), "UTC"
 print "loop count = %i" % num_loops
 print
 
@@ -124,7 +126,8 @@
         obj.setField("text_fld","joe")
         try:
             a_result = obj.callMethod( "cat_a_b" , [a, b])
-            # print str(x) + ", Call method: " +  str(a_result)
+            if (a_result != a + b):
+                print "Wrong result: %s, should be: %s" % (a_result, a + b)
         except GEAS.NullField,ex:
             print ex.detail
         except GEAS.MethodError,ex:
@@ -139,54 +142,79 @@
 print "time to call a method only = ", "%.3f" % ((create_and_set_method_time - 
create_and_set_time)*1000), " milliseconds."
 print
 
-# this test should be the same as executing the following query
-# SELECT * FROM location__post_code WHERE city LIKE 'M%' AND zip_code LIKE 
'6%';
+print "Testing startswith query"
+# this test should be the same as executing the following queries
+# SELECT count(*) FROM location__post_code WHERE city LIKE 'M%' AND zip_code 
LIKE '68%';
+# SELECT count(*) FROM location__post_code WHERE city LIKE 'M%' AND zip_code 
LIKE '4%';
+# SELECT count(*) FROM location__post_code WHERE city LIKE 'M%' AND zip_code 
LIKE '5%';
+# SELECT city, zip_code FROM location__post_code WHERE city LIKE 'M%' AND 
zip_code LIKE '68%';
+# SELECT city, zip_code FROM location__post_code WHERE city LIKE 'M%' AND 
zip_code LIKE '4%';
+# SELECT city, zip_code FROM location__post_code WHERE city LIKE 'M%' AND 
zip_code LIKE '5%';
 x = 0
 num_records = 0
 total_time_start = time.time()
-citystart = 'M'
-for zip2 in ('6', '4', '5'):
+city_test = ['M', 'M', 'M']
+zip2_test = ['68', '4', '5']
+cor_result = [26, 269, 342]
+while x < len(city_test):
     start_time = time.time()
-    result = zip_query2( citystart, zip2)
-    x = x+1
+    result = zip_query2( city_test[x], zip2_test[x])
     end_time = time.time()
     query_time = end_time - start_time
-    print "query found %i results between city starts with %s and zip starts 
with %s," % (result.length, citystart, zip2),
+    print "query found %i results between city starts with %s and zip starts 
with %s," % (result.length, city_test[x], zip2_test[x]),
     if query_time > 60.0:
         print "in %.3f minutes." % (query_time/60.0)
     else:
         print "in %.3f seconds." % (query_time)
+    if (result.length != cor_result[x]):
+        print "**** Error Incorrect result from query, expecting %i, received 
%i" % (cor_result[x], result.length)
+        if result == None:
+            print "None returned."
+        else:
+            for o in result.objects:
+                print "        ", o.getField("sys_id") , o.getField("city"), 
o.getField("zip_code")
     num_records = num_records + result.length
+    x = x+1
 total_time_end = time.time()
 query1_time = (total_time_end - total_time_start) / num_records
 print "time to query zip file = ", "%.3f" % (query1_time), " seconds per 
object returned."
 print "number of objects returned = %i." % num_records
 print
 
-num_loops = 3
+print "Testing lessthan and greaterthan query"
+# SELECT count(*) from location__post_code WHERE zip_code > 20000 and zip_code 
< 20199;
 x = 0
 num_records = 0
+min_test = [20000]
+max_test = [20199]
+cor_result = [22]
 total_time_start = time.time()
-while (x < num_loops):
+while (x < len(min_test) ):
+    # zip1 = whrandom.randint(10000, 99999)
+    # zip2 = whrandom.randint(10000, 99999)
+    # if (zip1 <= zip2):
     start_time = time.time()
-    zip1 = whrandom.randint(10000, 99999)
-    zip2 = whrandom.randint(10000, 99999)
-    if (zip1 <= zip2):
-        result = zip_query( zip1, zip2)
-    else:
-        result = zip_query( zip2, zip1)
-    result = zip_query( zip1, zip2)
-    x = x+1
+    result = zip_query( min_test[x], max_test[x])
     end_time = time.time()
     query_time = end_time - start_time
+    print "query found %i results between zip codes %i - %i," % 
(result.length, min_test[x], max_test[x]),
     if query_time > 60.0:
-        print "query found %i results between zip codes %s - %s, in %.3f 
minutes." % (result.length, zip1, zip2, query_time/60.0)
+         print "in %.3f minutes." % (query_time/60.0)
     else:
-        print "query found %i results between zip codes %s - %s, in %.3f 
seconds." % (result.length, zip1, zip2, query_time)
+        print "in %.3f seconds." % (query_time)
+    if (result.length != cor_result[x]):
+        print "**** Error Incorrect result from query, expecting %i, received 
%i" % (cor_result[x], result.length)
+        if result == None:
+            print "None returned."
+        else:
+            for o in result.objects:
+                print "        ", o.getField("sys_id") , o.getField("city"), 
o.getField("zip_code")
+
     num_records = num_records + result.length
+    x = x+1
 total_time_end = time.time()
 query1_time = (total_time_end - total_time_start) / num_records
-print "time to query zip file = ", "%.3f" % (query1_time), " seconds per 
object returned."
+print "time to query post_code table = ", "%.3f" % (query1_time), " seconds 
per object returned."
 print "number of items returned = %i" % num_records
-
-print time.asctime(time.gmtime()), "UTC"
+print
+print "Done", time.asctime(time.gmtime()), "UTC"
\ No newline at end of file



reply via email to

[Prev in Thread] Current Thread [Next in Thread]