Beispiel #1
0
    def test_update_dormat_session_with_stubs_and_module(self):
        self.hash.set('localhost:foo', 'bar', {
            'status': 'dormant',
            'session': 'bar',
            'scenario': 'localhost:foo'
        })
        module = {"system_date": "2013-09-24", "version": 1, "name": "funcky"}

        self._make_scenario('localhost:foo')
        from stubo.model.stub import create, Stub

        stub = Stub(create('<test>match this</test>', '<test>OK</test>'),
                    'localhost:foo')
        stub.set_module(module)
        doc = dict(scenario='localhost:foo', stub=stub)
        self.scenario.insert_stub(doc, stateful=True)
        self._get_cache().create_session_cache('foo', 'bar')
        session = self.hash.get('localhost:foo', 'bar')
        self.assertTrue('stubs' in session)
        stubs = session['stubs']
        self.assertEqual(len(stubs), 1)
        from stubo.model.stub import StubCache

        stub = StubCache(stubs[0], session["scenario"], session['session'])
        self.assertEqual(stub.module(), module)
Beispiel #2
0
 def test_it_with_module(self):   
     module = {"system_date": "2013-08-07", "version": 1, "name": "mymodule"}
     scenario_name = 'foo'
     self._make_scenario('localhost:foo')
     from stubo.model.stub import create, Stub, response_hash
     stub = Stub(create('<test>match this</test>', '<test>OK</test>'),
                 'localhost:foo')
     stub.set_module(module)
     doc = dict(scenario='localhost:foo', stub=stub)
     self.scenario.insert_stub(doc, stateful=True)  
     cache = self._get_cache()
     session = cache.create_session_cache('foo', 'bar') 
     self._func(session, stub)  
     self.assertEqual(self.hash.get('localhost:foo:request',
         'bar:1'),
        [[u'1'], u'', None, u'2013-09-05', module, u'12b0a0eced1ec13b53d186be7bd4909fa94d1916cca4daa25bd24d48'])
Beispiel #3
0
 def test_it_with_module(self):
     module = {
         "system_date": "2013-08-07",
         "version": 1,
         "name": "mymodule"
     }
     scenario_name = 'foo'
     self._make_scenario('localhost:foo')
     from stubo.model.stub import create, Stub, response_hash
     stub = Stub(create('<test>match this</test>', '<test>OK</test>'),
                 'localhost:foo')
     stub.set_module(module)
     doc = dict(scenario='localhost:foo', stub=stub)
     self.scenario.insert_stub(doc, stateful=True)
     cache = self._get_cache()
     session = cache.create_session_cache('foo', 'bar')
     self._func(session, stub)
     self.assertEqual(
         self.hash.get('localhost:foo:request', 'bar:1'),
         [[u'1'], u'', None, u'2013-09-05', module,
          u'12b0a0eced1ec13b53d186be7bd4909fa94d1916cca4daa25bd24d48'])
Beispiel #4
0
 def test_update_dormat_session_with_stubs_and_module(self):
     self.hash.set('localhost:foo', 'bar', {'status' : 'dormant',
                                           'session' : 'bar',
                                           'scenario' : 'localhost:foo'}) 
     module = {"system_date": "2013-09-24", "version": 1, "name": "funcky"}                                  
     
     self._make_scenario('localhost:foo')
     from stubo.model.stub import create, Stub
     stub = Stub(create('<test>match this</test>', '<test>OK</test>'),
                 'localhost:foo')
     stub.set_module(module)
     doc = dict(scenario='localhost:foo', stub=stub)
     self.scenario.insert_stub(doc, stateful=True)  
     self._get_cache().create_session_cache('foo', 'bar')  
     session = self.hash.get('localhost:foo', 'bar') 
     self.assertTrue('stubs' in session)
     stubs = session['stubs']
     self.assertEqual(len(stubs), 1)
     from stubo.model.stub import StubCache
     stub = StubCache(stubs[0], session["scenario"], session['session'])
     self.assertEqual(stub.module(), module)