class TestSyncing(TestCaseWithTestDB): no_sync_status_doc = True def make_config(self): config = TestCaseWithTestDB.make_config(self) # now add our smtp account acct = config.accounts['test_smtp'] = {} acct['proto'] = 'smtp' acct['username'] = '******' acct['id'] = 'smtp_test' return config def get_conductor(self): if self._conductor is None: self._conductor = SyncConductor(self.pipeline) self._conductor.initialize() # clobber the 'real' SMTP account with a stub. self._conductor.outgoing_handlers['rd.msg.outgoing.smtp'] = [StubSMTP()] return self._conductor def test_sync_state_doc(self, expected_num_syncs=1): self.deferMakeAnotherTestMessage(None) self.ensure_pipeline_complete() # open the document with the sync state. wanted = ["raindrop", "sync-status"], 'rd.core.sync-status' si = self.doc_model.open_schemas([wanted])[0] self.failUnless(si) self.failUnlessEqual(si.get('new_items'), 1) self.failUnlessEqual(si.get('num_syncs'), expected_num_syncs) def test_sync_state_doc_twice(self): # make sure it works twice with the same conductor instance/db self.test_sync_state_doc() self.test_sync_state_doc(2)
def get_conductor(self): if self._conductor is None: self._conductor = SyncConductor(self.pipeline) self._conductor.initialize() # clobber the 'real' SMTP account with a stub. self._conductor.outgoing_handlers['rd.msg.outgoing.smtp'] = [StubSMTP()] return self._conductor
def get_conductor(self): if self._conductor is None: details = self.config.accounts['test_twitter'] self.stub_twitter = StubTwitter(self.doc_model, details, self) self._conductor = SyncConductor(self.pipeline) self._conductor.initialize() # clobber the 'real' twitter account with out stub. self._conductor.outgoing_handlers['rd.msg.outgoing.tweet'] = [self.stub_twitter] return self._conductor
class TestSendStub(TestCaseWithTestDB): def make_config(self): config = TestCaseWithTestDB.make_config(self) # now add our twitter account acct = config.accounts['test_twitter'] = {} acct['id'] = 'twitter' acct['proto'] = 'twitter' acct['username'] = '******' return config def get_conductor(self): if self._conductor is None: details = self.config.accounts['test_twitter'] self.stub_twitter = StubTwitter(self.doc_model, details, self) self._conductor = SyncConductor(self.pipeline) self._conductor.initialize() # clobber the 'real' twitter account with out stub. self._conductor.outgoing_handlers['rd.msg.outgoing.tweet'] = [self.stub_twitter] return self._conductor def test_simple(self): self.get_conductor() result = self.doc_model.create_schema_items([ {'rd_key': ['test', 'tweet_test'], 'rd_ext_id': 'testsuite', 'rd_schema_id': 'rd.msg.outgoing.tweet', 'items': { 'outgoing_state': 'outgoing', 'body': 'this is a test tweet', 'in_reply_to' : None, # more fields?? }, }]) self.ensure_pipeline_complete() self.failUnlessEqual(self.stub_twitter.num_sends, 1)