source: MILK/trunk/milk_server/milk_server/tests/models/testdiscoverystate.py @ 4472

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/MILK/trunk/milk_server/milk_server/tests/models/testdiscoverystate.py@4472
Revision 4472, 1.1 KB checked in by cbyrom, 12 years ago (diff)

Strip out code not relevant to MILK - mainly WCS and WMS stuff - also including the CSML server code + trackback code
Also tidy up structure of 'public' dir - setting up new 'style' dir and
centralising icons in icons dir + remove all unused icons, javascript and stylesheets.
Also strip out testcase code and populate new test directory structure.

Line 
1import unittest
2from milk_server.models.DiscoveryState import DiscoveryState
3DummyEnviron={'QUERY_STRING':'start=10&howmany=10','HTTP_HOST':'example.ndg',
4                  'PATH_INFO':'/discovery','wsgi.url_scheme':'http','SERVER_PORT':'80'}
5
6class TestCase(unittest.TestCase):
7   
8    def testDiscoveryState(self):
9        ''' Test creation of a discovery state variable '''
10        d=DiscoveryState('123','blah',DummyEnviron,12,'(none)')
11        self.assertEqual(d.geturl(offset='11',stride='20'),
12                        '/discovery?start=11&howmany=20')
13        print d
14
15    def testStrideself(self):
16        ''' Test striding through a dataset '''
17       
18        s=DiscoveryState('123','blah',DummyEnviron,15,'(none)',1,10)
19        res=s.getNext()
20        self.assertEqual([[11,5],[]],res)
21       
22        s=DiscoveryState('123','blah',DummyEnviron,15,'(none)',11,5)
23        res=s.getNext()
24        self.assertEqual([[],[1,10]],res)
25       
26        s=DiscoveryState('123','blah',DummyEnviron,50,'(none)',11,10)
27        res=s.getNext()
28        self.assertEqual([[21,10],[1,10]],res) 
29
30           
31if __name__=="__main__":
32    unittest.main()
Note: See TracBrowser for help on using the repository browser.