How to use test_presenter method in SeleniumBase

Best Python code snippet using SeleniumBase

test_presenter.py

Source:test_presenter.py Github

copy

Full Screen

1import unittest2from .read import Read3from .alignment import Alignment4from .reference import Reference5from .presenter import Presenter6class TestPresenter(unittest.TestCase):7 def create_aligned_pairs(self, read_sequence, reference_positions):8 return tuple(zip(range(len(read_sequence)), reference_positions))9 def create_test_reference(self, name):10 self.n20 = "aaaatttc"11 self.sequence = "tactactacaaaatttccggt"12 self.pam = "ngg"13 reference_positions_a = [8, None, None, None, 9, 10, 11, None, None, None, None, 12, 13, 14]14 seq_a = "ctttaaattttatt"15 read_a = Read("a", reference_positions_a, seq_a, self.create_aligned_pairs(seq_a, reference_positions_a))16 reference_positions_b = [10, 15]17 seq_b = "at"18 read_b = Read("b", reference_positions_b, seq_b, ((0,10),(None, 11), (None, 12), (None, 13), (None, 14), (1, 15)))19 reference_positions_c = [10, 11, 12, 13, 14]20 seq_c = "aaatt"21 read_c = Read("c", reference_positions_c, seq_a, self.create_aligned_pairs(seq_c, reference_positions_c))22 reference_positions_d = [6, 7, 8, 9, 10, 11, 12, 13, None, None, None, None, 14]23 seq_d = "tacaaaattggggt"24 read_d = Read("d", reference_positions_d, seq_d, self.create_aligned_pairs(seq_d, reference_positions_d))25 reference_positions_e = [18, 20]26 seq_e = "gt"27 read_e = Read("e", reference_positions_e, seq_e, ((0,18),(None, 19),(1,20)))28 reference_positions_f = [None, None, None, 0, 1, 2]29 seq_f = "gggtac"30 read_f = Read("f", reference_positions_f, seq_f, self.create_aligned_pairs(seq_f, reference_positions_f))31 reads = [read_a, read_b, read_c, read_d, read_e, read_f]32 return Reference(name, self.n20, self.sequence, self.pam, reads)33 def test_reference_presenter_results(self):34 references = [self.create_test_reference("foo"), self.create_test_reference("bar")]35 test_presenter = Presenter(references)36 results = test_presenter.present()37 self.assertEqual(len(results), 2)38 self.assertEqual(results[0].sequence(), self.sequence.upper())39 self.assertEqual(results[0].n20(), self.n20.upper())40 self.assertEqual(results[0].pam(), self.pam.upper())41 self.assertEqual(results[0].name(), "foo")42 self.assertEqual(len(results[0].mutation_clusters), 1)43 self.assertEqual(results[0].total_reads(), 6)44 self.assertEqual(results[1].sequence(), self.sequence.upper())45 self.assertEqual(results[1].n20(), self.n20.upper())46 self.assertEqual(results[1].pam(), self.pam.upper())47 self.assertEqual(results[1].name(), "bar")48 self.assertEqual(len(results[1].mutation_clusters), 1)49 self.assertEqual(results[1].total_reads(), 6)50 def test_cluster_results(self):51 references = [self.create_test_reference("foo")]52 test_presenter = Presenter(references)53 results = test_presenter.present()54 mutation_clusters = results[0].mutation_clusters55 self.assertEqual(mutation_clusters[0].count(), 1)56 expected = [('A___||_T', 'A___||_T', 'AAAT||TT')]57 actual = []58 for cluster in mutation_clusters:59 got = (cluster.cas9_region.read, cluster.alignments[0].read, cluster.alignments[0].reference)60 actual.append(got)...

Full Screen

Full Screen

ringmaster_test_support.py

Source:ringmaster_test_support.py Github

copy

Full Screen

1"""Test support code for testing Ringmasters."""2from collections import defaultdict3from cStringIO import StringIO4from gomill import ringmasters5from gomill import ringmaster_presenters6class Test_presenter(ringmaster_presenters.Presenter):7 """Presenter which stores the messages."""8 def __init__(self):9 ringmaster_presenters.Presenter.__init__(self)10 self.channels = defaultdict(list)11 shows_warnings_only = False12 def clear(self, channel):13 self.channels[channel] = []14 def say(self, channel, s):15 self.channels[channel].append(s)16 def refresh(self):17 pass18 def recent_messages(self, channel):19 """Retrieve messages sent since the channel was last cleared.20 Returns a list of strings.21 """22 return self.channels[channel][:]23class Testing_ringmaster(ringmasters.Ringmaster):24 """Variant of ringmaster suitable for use in tests.25 This doesn't read from or write to the filesystem.26 (If you're testing run(), make sure record_games is False, and either27 stderr_to_log is False, or else discard_stderr is True for each player.)28 (Currently, write_status is made to do nothing, so it's not usefully29 testable.)30 Instantiate with the control file contents as an 8-bit string.31 It will act as if the control file had been loaded from32 /nonexistent/ctl/test.ctl.33 You'll want to run set_display_mode('test') with this.34 """35 def __init__(self, control_file_contents):36 self._control_file_contents = control_file_contents37 self._test_status = None38 self._written_status = None39 ringmasters.Ringmaster.__init__(self, '/nonexistent/ctl/test.ctl')40 self.set_stdout(StringIO())41 _presenter_classes = {42 'test' : Test_presenter,43 }44 def _open_files(self):45 self.logfile = StringIO()46 self.historyfile = StringIO()47 def _close_files(self):48 # Don't want to close the StringIOs49 pass50 def _read_control_file(self):51 return self._control_file_contents52 def set_test_status(self, test_status):53 """Specify the value that will be loaded from the state file.54 test_status -- fake state file contents55 test_status should be a pair (status_format_version, status dict)56 """57 self._test_status = test_status58 def _load_status(self):59 return self._test_status60 def status_file_exists(self):61 return (self._test_status is not None)62 def _write_status(self, value):63 self._written_status = value64 def retrieve_printed_output(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful