Ticket #2542: dojox.data.CsvStore_20070501.patch

File dojox.data.CsvStore_20070501.patch, 43.0 kB (added by guest, 19 months ago)

Second revision of dojox.data.CsvStore? implementation.

  • dojox/tests/module.js

     
    22 
    33try{ 
    44        dojo.require("dojox.tests.date.posix"); 
     5        dojo.require("dojox.tests.data.CsvStore"); 
    56        dojo.requireIf(dojo.isBrowser, "dojox.tests.data.XmlStore"); 
    67        dojo.requireIf(dojo.isBrowser, "dojox.tests.data.dom"); 
    78}catch(e){ 
  • dojox/tests/data/CsvStore.js

     
     1dojo.provide("dojox.tests.data.CsvStore"); 
     2dojo.require("dojox.data.CsvStore"); 
     3 
     4dojox.tests.data.CsvStore.getDatasource = function(filepath){ 
     5        //  summary: 
     6        //              A simple helper function for getting the sample data used in each of the tests. 
     7        //  description: 
     8        //              A simple helper function for getting the sample data used in each of the tests. 
     9         
     10        var dataSource = {}; 
     11        if(dojo.isBrowser){ 
     12                dataSource.url = dojo.moduleUrl("dojox.tests", filepath).toString();             
     13        }else{ 
     14                // When running tests in Rhino, xhrGet is not available, 
     15                // so we have the file data in the code below. 
     16                switch(filepath){ 
     17                        case "data/movies.csv": 
     18                                var csvData = ""; 
     19                                csvData += "Title, Year, Producer\n"; 
     20                                csvData += "City of God, 2002, Katia Lund\n"; 
     21                                csvData += "Rain,, Christine Jeffs\n"; 
     22                                csvData += "2001: A Space Odyssey, 1968, Stanley Kubrick\n"; 
     23                                csvData += '"This is a ""fake"" movie title", 1957, Sidney Lumet\n'; 
     24                                csvData += "Alien, 1979   , Ridley Scott\n"; 
     25                                csvData += '"The Sequel to ""Dances With Wolves.""", 1982, Ridley Scott\n'; 
     26                                csvData += '"Caine Mutiny, The", 1954, "Dymtryk ""the King"", Edward"\n'; 
     27                                break; 
     28                        case "data/books.csv": 
     29                                var csvData = ""; 
     30                                csvData += "Title, Author\n"; 
     31                                csvData += "The Transparent Society, David Brin\n"; 
     32                                csvData += "The First Measured Century, Theodore Caplow\n"; 
     33                                csvData += "Maps in a Mirror, Orson Scott Card\n"; 
     34                                csvData += "Princess Smartypants, Babette Cole\n"; 
     35                                csvData += "Carfree Cities, Crawford J.H.\n"; 
     36                                csvData += "Down and Out in the Magic Kingdom, Cory Doctorow\n"; 
     37                                csvData += "Tax Shift, Alan Thein Durning\n"; 
     38                                csvData += "The Sneetches and other stories, Dr. Seuss\n"; 
     39                                csvData += "News from Tartary, Peter Fleming\n"; 
     40                                break; 
     41                        case "data/patterns.csv": 
     42                                var csvData = ""; 
     43                                csvData += "uniqueId, value\n"; 
     44                                csvData += "9, jfq4@#!$!@Rf14r14i5u\n"; 
     45                                csvData += "6, BaBaMaSaRa***Foo\n"; 
     46                                csvData += "2, bar*foo\n"; 
     47                                csvData += "8, 123abc\n"; 
     48                                csvData += "4, bit$Bite\n"; 
     49                                csvData += "3, 123abc\n"; 
     50                                csvData += "10, 123abcdefg\n"; 
     51                                csvData += "1, foo*bar\n"; 
     52                                csvData += "7, \n"; 
     53                                csvData += "5, 123abc\n" 
     54                                break; 
     55                } 
     56                dataSource.data = csvData; 
     57        } 
     58        return dataSource; //Object 
     59} 
     60 
     61dojox.tests.data.CsvStore.verifyItems = function(csvStore, items, attribute, compareArray){ 
     62        //  summary: 
     63        //              A helper function for validating that the items array is ordered 
     64        //              the same as the compareArray 
     65        if(items.length != compareArray.length){ return false; } 
     66        for(var i = 0; i < items.length; i++){ 
     67                if(!(csvStore.getValue(items[i], attribute) === compareArray[i])){ 
     68                        return false; //Boolean 
     69                } 
     70        } 
     71        return true; //Boolean 
     72} 
     73 
     74dojox.tests.data.CsvStore.error = function(t, d, errData){ 
     75        //  summary: 
     76        //              The error callback function to be used for all of the tests. 
     77        d.errback(errData);      
     78} 
     79 
     80tests.register("dojox.tests.data.CsvStore",  
     81        [ 
     82                function testReadAPI_fetch_all(t){ 
     83                        //      summary:  
     84                        //              Simple test of a basic fetch on CsvStore. 
     85                        //      description: 
     86                        //              Simple test of a basic fetch on CsvStore. 
     87                         
     88                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     89                        var csvStore = new dojox.data.CsvStore(args); 
     90                         
     91                        var d = new tests.Deferred(); 
     92            function completedAll(items){ 
     93                                t.assertTrue((items.length === 7)); 
     94                                d.callback(true); 
     95                        } 
     96 
     97                        //Get everything... 
     98                        csvStore.fetch({ onComplete: completedAll, onError: dojo.partial(dojox.tests.data.CsvStore.error, t, d)}); 
     99                        return d; //Object 
     100                }, 
     101                function testReadAPI_fetch_one(t){ 
     102                        //      summary:  
     103                        //              Simple test of a basic fetch on CsvStore of a single item. 
     104                        //      description: 
     105                        //              Simple test of a basic fetch on CsvStore of a single item. 
     106 
     107                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     108                        var csvStore = new dojox.data.CsvStore(args); 
     109                         
     110                        var d = new tests.Deferred(); 
     111                        function onComplete(items, request){ 
     112                                t.is(1, items.length); 
     113                                d.callback(true); 
     114                        } 
     115                        csvStore.fetch({        query: {Title: "*Sequel*"},  
     116                                                                onComplete: onComplete,  
     117                                                                onError: dojo.partial(dojox.tests.data.CsvStore.error, t, d) 
     118                                                        }); 
     119                        return d; //Object 
     120                }, 
     121                function testReadAPI_fetch_all_streaming(t){ 
     122                        //      summary:  
     123                        //              Simple test of a basic fetch on CsvStore. 
     124                        //      description: 
     125                        //              Simple test of a basic fetch on CsvStore. 
     126 
     127                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     128                        var csvStore = new dojox.data.CsvStore(args); 
     129 
     130                        var d = new tests.Deferred(); 
     131                        count = 0; 
     132 
     133                        function onBegin(size, requestObj){ 
     134                                t.assertTrue(size === 7); 
     135                        } 
     136                        function onItem(item, requestObj){ 
     137                                t.assertTrue(csvStore.isItem(item)); 
     138                                count++; 
     139                        } 
     140                        function onComplete(items, request){ 
     141                                t.is(7, count); 
     142                                t.is(null, items); 
     143                            d.callback(true); 
     144                        } 
     145 
     146                        //Get everything... 
     147                        csvStore.fetch({        onBegin: onBegin, 
     148                                                                onItem: onItem,  
     149                                                                onComplete: onComplete, 
     150                                                                onError: dojo.partial(dojox.tests.data.CsvStore.error, t, d) 
     151                                                        }); 
     152                        return d; //Object 
     153                }, 
     154                function testReadAPI_fetch_paging(t){ 
     155                         //     summary:  
     156                         //             Test of multiple fetches on a single result.  Paging, if you will. 
     157                         //     description: 
     158                         //             Test of multiple fetches on a single result.  Paging, if you will. 
     159 
     160                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     161                        var csvStore = new dojox.data.CsvStore(args); 
     162                         
     163                        var d = new tests.Deferred(); 
     164                        function dumpFirstFetch(items, request){ 
     165                                t.is(5, items.length); 
     166                                request.start = 3; 
     167                                request.count = 1; 
     168                                request.onComplete = dumpSecondFetch; 
     169                                csvStore.fetch(request); 
     170                        } 
     171 
     172                        function dumpSecondFetch(items, request){ 
     173                                t.is(1, items.length); 
     174                                request.start = 0; 
     175                                request.count = 5; 
     176                                request.onComplete = dumpThirdFetch; 
     177                                csvStore.fetch(request); 
     178                        } 
     179 
     180                        function dumpThirdFetch(items, request){ 
     181                                t.is(5, items.length); 
     182                                request.start = 2; 
     183                                request.count = 20; 
     184                                request.onComplete = dumpFourthFetch; 
     185                                csvStore.fetch(request); 
     186                        } 
     187 
     188                        function dumpFourthFetch(items, request){ 
     189                                t.is(5, items.length); 
     190                request.start = 9; 
     191                                request.count = 100; 
     192                                request.onComplete = dumpFifthFetch; 
     193                                csvStore.fetch(request); 
     194                        } 
     195 
     196                        function dumpFifthFetch(items, request){ 
     197                                t.is(0, items.length); 
     198                                request.start = 2; 
     199                                request.count = 20; 
     200                                request.onComplete = dumpSixthFetch; 
     201                                csvStore.fetch(request); 
     202                        } 
     203 
     204                        function dumpSixthFetch(items, request){ 
     205                                t.is(5, items.length); 
     206                            d.callback(true); 
     207                        } 
     208 
     209                        function completed(items, request){ 
     210                                t.is(7, items.length); 
     211                                request.start = 1; 
     212                                request.count = 5; 
     213                                request.onComplete = dumpFirstFetch; 
     214                                csvStore.fetch(request); 
     215                        } 
     216 
     217                        csvStore.fetch({onComplete: completed, onError: dojo.partial(dojox.tests.data.CsvStore.error, t, d)}); 
     218                        return d; //Object 
     219 
     220                }, 
     221                function testReadAPI_getValue(t){ 
     222                        //      summary:  
     223                        //              Simple test of the getValue function of the store. 
     224                        //      description: 
     225                        //              Simple test of the getValue function of the store. 
     226 
     227                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     228                        var csvStore = new dojox.data.CsvStore(args); 
     229                                  
     230                        t.is("City of God",                                             csvStore.getValue(csvStore.getItemByIdentity("0"),"Title")); 
     231                        t.is("Rain",                                                            csvStore.getValue(csvStore.getItemByIdentity("1"),"Title")); 
     232                        t.is("2001: A Space Odyssey",                           csvStore.getValue(csvStore.getItemByIdentity("2"),"Title")); 
     233                        t.is('This is a "fake" movie title',            csvStore.getValue(csvStore.getItemByIdentity("3"),"Title")); 
     234                        t.is("Alien",                                                           csvStore.getValue(csvStore.getItemByIdentity("4"),"Title")); 
     235                        t.is('The Sequel to "Dances With Wolves."', csvStore.getValue(csvStore.getItemByIdentity("5"),"Title")); 
     236                        t.is('Caine Mutiny, The',                                       csvStore.getValue(csvStore.getItemByIdentity("6"),"Title")); 
     237 
     238                        t.is("2002",                                                            csvStore.getValue(csvStore.getItemByIdentity("0"),"Year")); 
     239                        t.is("1979",                                                            csvStore.getValue(csvStore.getItemByIdentity("4"),"Year")); 
     240 
     241                        t.is("Stanley Kubrick",                                         csvStore.getValue(csvStore.getItemByIdentity("2"),"Producer")); 
     242                        t.is('Dymtryk "the King", Edward',                      csvStore.getValue(csvStore.getItemByIdentity("6"),"Producer")); 
     243                },       
     244                 
     245                function testReadAPI_getValues(t){ 
     246                        //      summary:  
     247                        //              Simple test of the getValues function of the store. 
     248                        //      description: 
     249                        //              Simple test of the getValues function of the store. 
     250 
     251                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     252                        var csvStore = new dojox.data.CsvStore(args); 
     253 
     254                        var item = csvStore.getItemByIdentity("1"); 
     255                        t.assertTrue(item !== null); 
     256                        var names = csvStore.getValues(item,"Title"); 
     257            t.assertTrue(dojo.isArray(names)); 
     258                        t.is(1, names.length); 
     259                        t.is("Rain", names[0]); 
     260                }, 
     261                 
     262                function testIdentityAPI_getItemByIdentity(t){ 
     263                        //      summary:  
     264                        //              Simple test of the getItemByIdentity function of the store. 
     265                        //      description: 
     266                        //              Simple test of the getItemByIdentity function of the store. 
     267                         
     268                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     269                        var csvStore = new dojox.data.CsvStore(args); 
     270                         
     271                        for(var i=0; i<7; i++){ 
     272                                t.assertTrue(csvStore.getItemByIdentity(i) !== null); 
     273                        } 
     274                        t.is(null, csvStore.getItemByIdentity("7")); 
     275                        t.is(null, csvStore.getItemByIdentity("-1")); 
     276                        t.is(null, csvStore.getItemByIdentity("999999")); 
     277                }, 
     278                function testIdentityAPI_getIdentity(t){ 
     279                        //      summary:  
     280                        //              Simple test of the getItemByIdentity function of the store. 
     281                        //      description: 
     282                        //              Simple test of the getItemByIdentity function of the store. 
     283                         
     284                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     285                        var csvStore = new dojox.data.CsvStore(args); 
     286                         
     287                        var d = new tests.Deferred(); 
     288                        function completed(items, request){ 
     289                                t.is(7, items.length); 
     290                                var passed = true; 
     291                                for(var i = 0; i < items.length; i++){ 
     292                                        if(!(csvStore.getIdentity(items[i]) === i)){ 
     293                                                passed=false; 
     294                                                break; 
     295                                        } 
     296                                } 
     297                                t.assertTrue(passed); 
     298                                d.callback(true); 
     299                        } 
     300                         
     301                        //Get everything... 
     302                        csvStore.fetch({ onComplete: completed, onError: dojo.partial(dojox.tests.data.CsvStore.error, t, d)}); 
     303                        return d; //Object 
     304                }, 
     305                function testReadAPI_isItem(t){ 
     306                        //      summary:  
     307                        //              Simple test of the isItem function of the store 
     308                        //      description: 
     309                        //              Simple test of the isItem function of the store 
     310 
     311                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     312                        var csvStore = new dojox.data.CsvStore(args); 
     313 
     314                        for(var i=0; i<7; i++){ 
     315                                t.assertTrue(csvStore.isItem(csvStore.getItemByIdentity(i))); 
     316                        } 
     317                         
     318                        t.assertTrue(!csvStore.isItem({})); 
     319                        t.assertTrue(!csvStore.isItem({ item: "not an item" })); 
     320                        t.assertTrue(!csvStore.isItem("not an item")); 
     321                        t.assertTrue(!csvStore.isItem(["not an item"])); 
     322                }, 
     323                function testReadAPI_hasAttribute(t){ 
     324                        //      summary:  
     325                        //              Simple test of the hasAttribute function of the store 
     326                        //      description: 
     327                        //              Simple test of the hasAttribute function of the store 
     328 
     329                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     330                        var csvStore = new dojox.data.CsvStore(args); 
     331 
     332                        var item = csvStore.getItemByIdentity(1); 
     333                        t.assertTrue(item !== null); 
     334                        t.assertTrue(csvStore.hasAttribute(item, "Title")); 
     335                        t.assertTrue(csvStore.hasAttribute(item, "Producer")); 
     336                        t.assertTrue(!csvStore.hasAttribute(item, "Year")); 
     337                        t.assertTrue(!csvStore.hasAttribute(item, "Nothing")); 
     338                        t.assertTrue(!csvStore.hasAttribute(item, "title")); 
     339 
     340                        //Test that null attributes throw an exception 
     341                        var passed = false; 
     342                        try{ 
     343                                csvStore.hasAttribute(item, null); 
     344                        }catch (e){ 
     345                                passed = true; 
     346                        } 
     347                        t.assertTrue(passed); 
     348                }, 
     349 
     350                function testReadAPI_containsValue(t){ 
     351                        //      summary:  
     352                        //              Simple test of the containsValue function of the store 
     353                        //      description: 
     354                        //              Simple test of the containsValue function of the store 
     355 
     356                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     357                        var csvStore = new dojox.data.CsvStore(args); 
     358                         
     359                        var item = csvStore.getItemByIdentity("4"); 
     360                        t.assertTrue(item !== null); 
     361                        t.assertTrue(csvStore.containsValue(item, "Title", "Alien")); 
     362                        t.assertTrue(csvStore.containsValue(item, "Year", "1979")); 
     363                        t.assertTrue(csvStore.containsValue(item, "Producer", "Ridley Scott")); 
     364                        t.assertTrue(!csvStore.containsValue(item, "Title", "Alien2")); 
     365                        t.assertTrue(!csvStore.containsValue(item, "Year", "1979   ")); 
     366                        t.assertTrue(!csvStore.containsValue(item, "Title", null)); 
     367 
     368                        //Test that null attributes throw an exception 
     369                        var passed = false; 
     370                        try{ 
     371                                csvStore.containsValue(item, null, "foo"); 
     372                        }catch (e){ 
     373                                passed = true; 
     374                        } 
     375                        t.assertTrue(passed); 
     376                }, 
     377                 
     378                function testReadAPI_getAttributes(t){ 
     379                        //      summary:  
     380                        //              Simple test of the getAttributes function of the store 
     381                        //      description: 
     382                        //              Simple test of the getAttributes function of the store 
     383 
     384                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     385                        var csvStore = new dojox.data.CsvStore(args); 
     386 
     387                        var item = csvStore.getItemByIdentity("4"); 
     388                        t.assertTrue(item !== null); 
     389                        t.assertTrue(csvStore.isItem(item)); 
     390 
     391                        var attributes = csvStore.getAttributes(item); 
     392                        t.is(3, attributes.length); 
     393                        for(var i = 0; i < attributes.length; i++){ 
     394                                t.assertTrue((attributes[i] === "Title" || attributes[i] === "Year" || attributes[i] === "Producer")); 
     395                        } 
     396                         
     397                        // Test an item that does not have all of the attributes 
     398                        var item = csvStore.getItemByIdentity(1); 
     399                        t.assertTrue(item !== null); 
     400                        t.assertTrue(csvStore.isItem(item)); 
     401 
     402                        var attributes = csvStore.getAttributes(item); 
     403                        t.assertTrue(attributes.length === 2); 
     404                        t.assertTrue(attributes[0] === "Title"); 
     405                        t.assertTrue(attributes[1] === "Producer"); 
     406                }, 
     407                function testReadAPI_getFeatures(t){ 
     408                        //      summary:  
     409                        //              Simple test of the getFeatures function of the store 
     410                        //      description: 
     411                        //              Simple test of the getFeatures function of the store 
     412 
     413                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     414                        var csvStore = new dojox.data.CsvStore(args); 
     415 
     416                        var features = csvStore.getFeatures();  
     417                        var count = 0; 
     418                        for(i in features){ 
     419                                t.assertTrue((i === "dojo.data.api.Read" || i === "dojo.data.api.Identity")); 
     420                                count++; 
     421                        } 
     422                        t.assertTrue(count === 2); 
     423                }, 
     424                function testReadAPI_fetch_patternMatch0(t){ 
     425                        //      summary:  
     426                        //              Function to test pattern matching of everything starting with lowercase e 
     427                        //      description: 
     428                        //              Function to test pattern matching of everything starting with lowercase e 
     429 
     430                        var args = dojox.tests.data.CsvStore.getDatasource("data/movies.csv"); 
     431                        var csvStore = new dojox.data.CsvStore(args); 
     432 
     433                        var d = new tests.Deferred(); 
     434                        function completed(items, request){ 
     435                                t.is(2, items.length); 
     436                                var valueArray = [ "Alien", "The Sequel to \"Dances With Wolves.\""]; 
     437                                t.assertTrue(dojox.tests.data.CsvStore.verifyItems(csvStore, items, "Title", valueArray)); 
     438                                d.callback(true); 
     439                        } 
     440                         
     441                        csvStore.fetch({query: {Producer: "* Scott"}, onComplete: completed, onError: dojo.partial(dojox.tests.data.CsvStore.error, t, d)}); 
     442                        return d; //Object 
     443                }, 
     444                function testReadAPI_fetch_patternMatch1(t){ 
     445                        //      summary:  
     446                        //              Function to test pattern matching of everything with $ in it. 
     447                        //      description: 
     448                        //              Function to test pattern matching of everything with $ in it. 
     449                         
     450                        var args = dojox.tests.data.CsvStore.getDatasource("data/patterns.csv"); 
     451                        var csvStore = new dojox.data.CsvStore(args); 
     452                         
     453                        var d = new tests.Deferred(); 
     454                        function completed(items, request){ 
     455                                t.assertTrue(items.length === 2); 
     456                                var valueArray = [ "jfq4@#!$!@Rf14r14i5u", "bit$Bite"]; 
     457                                t.assertTrue(dojox.tests.data.CsvStore.verifyItems(csvStore, items, "value", valueArray)); 
     458                                d.callback(true); 
     459                        } 
     460                         
     461                        csvStore.fetch({query: {value: "*$*"}, onComplete: completed, onError: dojo.partial(dojox.tests.data.CsvStore.error, t, d)}); 
     462                        return d; //Object 
     463                }, 
     464                function testReadAPI_fetch_patternMatch2(t){ 
     465                        //      summary:  
     466                        //              Function to test exact pattern match 
     467                        //      description: 
     468                        //              Function to test exact pattern match 
     469                         
     470                        var args = dojox.tests.data.CsvStore.getDatasource("data/patterns.csv"); 
     471                        var csvStore = new dojox.data.CsvStore(args); 
     472                         
     473                        var d = new tests.Deferred(); 
     474                        function completed(items, request){ 
     475                                t.is(1, items.length); 
     476                                t.assertTrue(csvStore.getValue(items[0], "value") === "bar*foo"); 
     477                                d.callback(true); 
     478                        } 
     479                         
     480                        csvStore.fetch({query: {value: "bar\*foo"}, onComplete: completed, onError: dojo.partial(dojox.tests.data.CsvStore.error, t, d)}); 
     481                        return d; //Object 
     482                }, 
     483                function testReadAPI_fetch_sortNumeric(t){ 
     484                        //      summary:  
     485                        //              Function to test sorting numerically. 
     486                        //      description: 
     487                        //              Function to test sorting numerically. 
     488                         
     489                        var args = dojox.tests.data.CsvStore.getDatasource("data/patterns.csv"); 
     490                        var csvStore = new dojox.data.CsvStore(args); 
     491 
     492                        var d = new tests.Deferred(); 
     493                        function completed(items, request){ 
     494                                t.assertTrue(items.length === 10); 
     495                                // TODO: CsvStore treats everything like a string, so these numbers will be sorted lexicographically. 
     496                                var orderedArray = [ "1", "10", "2", "3", "4", "5", "6", "7", "8", "9" ]; 
     497                                t.assertTrue(dojox.tests.data.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray)); 
     498                                d.callback(true); 
     499                        } 
     500 
     501                        var sortAttributes = [{attribute: "uniqueId"}]; 
     502                        csvStore.fetch({onComplete: completed,  
     503                                                        onError: dojo.partial(dojox.tests.data.CsvStore.error, t, d), 
     504                                                        sort: sortAttributes}); 
     505                        return d; //Object 
     506                }, 
     507                function testReadAPI_fetch_sortNumericDescending(t){ 
     508                        //      summary:  
     509                        //              Function to test sorting numerically. 
     510                        //      description: 
     511                        //              Function to test sorting numerically. 
     512 
     513                        var args = dojox.tests.data.CsvStore.getDatasource("data/patterns.csv"); 
     514                        var csvStore = new dojox.data.CsvStore(args); 
     515                         
     516                        var d = new tests.Deferred(); 
     517                        function completed(items, request){ 
     518                                t.is(10, items.length); 
     519                                // TODO: CsvStore treats everything like a string, so these numbers will be sorted lexicographically. 
     520                                var orderedArray = [ "9", "8", "7", "6", "5", "4", "3", "2", "10", "1" ]; 
     521                                t.assertTrue(dojox.tests.data.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray)); 
     522                                d.callback(true); 
     523                        } 
     524                         
     525                        var sortAttributes = [{attribute: "uniqueId", descending: true}]; 
     526                        csvStore.fetch({ sort: sortAttributes, onComplete: completed, onError: dojo.partial(dojox.tests.data.CsvStore.error, t, d)}); 
     527                        return d; //Object 
     528                }, 
     529                function testReadAPI_fetch_sortNumericWithCount(t){ 
     530                        //      summary:  
     531                        //              Function to test sorting numerically in descending order, returning only a specified number of them. 
     532                        //      description: 
     533                        //              Function to test sorting numerically in descending order, returning only a specified number of them. 
     534                 
     535                        var args = dojox.tests.data.CsvStore.getDatasource("data/patterns.csv"); 
     536                        var csvStore = new dojox.data.CsvStore(args); 
     537                         
     538                        var d = new tests.Deferred(); 
     539                        function completed(items, request){ 
     540                                t.is(5, items.length); 
     541                                // TODO: CsvStore treats everything like a string, so these numbers will be sorted lexicographically. 
     542                                var orderedArray = [ "9", "8", "7", "6", "5" ]; 
     543                                t.assertTrue(dojox.tests.data.CsvStore.verifyItems(csvStore, items, "uniqueId", orderedArray)); 
     544                                d.callback(true);