def test_button_a_displays_a_message(self): self.run_scripts(Target(MB1, 'tests/e2e/flippers/mb.py'), Target(MB2, 'tests/e2e/flippers/mb.py'), Target(MB3, 'tests/e2e/flippers/mb.py')) self.press(MB1, BUTTON_A) self.expect(see(MB1, 'That hurt!'), see(MB2, 'Poor you!'), see(MB3, 'Poor you!'))
def test_digital_inputs(self): self.controller.run(Target('microbit 1', 'tests/e2e/digital_read.py')) self.controller.set_digital_input('microbit 1', 8) event = self.controller.read_event() assert_that(event, see('microbit 1', 'Ouch!')) self.controller.set_digital_input('microbit 1', 8, 0) self.controller.set_digital_input('microbit 1', 16) event = self.controller.read_event() assert_that(event, see('microbit 1', 'That hurt!'))
def test_button_and_display(self): self.controller.run(Target('microbit 1', 'tests/e2e/button_print.py'), Target('microbit 2', 'tests/e2e/button_print.py')) self.controller.press('microbit 1', BUTTON_A) event = self.controller.read_event() assert_that(event, see('microbit 1', 'Ouch!')) self.controller.press('microbit 2', BUTTON_A) event = self.controller.read_event() assert_that(event, see('microbit 2', 'Ouch!')) self.controller.press('microbit 1', BUTTON_B) event = self.controller.read_event() assert_that(event, see('microbit 1', 'That hurt!'))
def start_quiz(self): self.run_scripts(Target(QUIZ_RUNNER, '/home/romilly/git/active/bbc-microbit-nsp/src/quizrunner/quizrunner.py'), Target(TEAM1, '/home/romilly/git/active/bbc-microbit-nsp/src/quizrunner/quizrunner.py'), Target(TEAM2, '/home/romilly/git/active/bbc-microbit-nsp/src/quizrunner/quizrunner.py')) self.press(QUIZ_RUNNER, BUTTON_A) self.expect(see(QUIZ_RUNNER, 'runner')) self.expect(see(TEAM1, 'checking in'), see(TEAM2, 'checking in')) self.press(TEAM1, BUTTON_B) self.expect(see(TEAM1, 'check')) self.expect(see(QUIZ_RUNNER, 'team 1 checked in')) self.expect(see(TEAM1, 'team: 1')) sleep(0.1) # otherwise team 2 might get team 1's message after the button press! self.press(TEAM2, BUTTON_B) self.expect(see(TEAM2, 'check')) self.expect(see(QUIZ_RUNNER, 'team 2 checked in')) self.press(QUIZ_RUNNER, BUTTON_B) self.expect(see(TEAM2, 'team: 2'), see(QUIZ_RUNNER, 'all checked in')) sleep(0.1) # as there will be more radio messages to process
def test_forced_game_end(self): self.start_quiz() self.expect(see(QUIZ_RUNNER, 'Play time!')) ## play a round self.expect( see(QUIZ_RUNNER, 'round 1'), see(TEAM1, 'round 1'), see(TEAM2, 'round 1')) self.press(TEAM2, BUTTON_A) self.press(QUIZ_RUNNER, BUTTON_B) self.expect( see(QUIZ_RUNNER, 'team 2 buzzing'), see(TEAM2, 'team 2 buzzing')) self.press_extra(QUIZ_RUNNER, BUTTON_D) sleep(0.2) self.expect( see(QUIZ_RUNNER, 'game over'), see(QUIZ_RUNNER, all_of(contains_string("that's all"), contains_string('1:0'), contains_string('2:0'))), timeout_ms=1000) sleep(1.0) # wait for cool-down
def test_button_and_display(self): self.start_quiz() self.expect(see(QUIZ_RUNNER, 'Play time!')) ## play a round self.expect( see(QUIZ_RUNNER, 'round 1'), see(TEAM1, 'round 1'), see(TEAM2, 'round 1')) self.press(TEAM1, BUTTON_A) self.expect( see(QUIZ_RUNNER, 'team 1 buzzing'), see(TEAM1, 'team 1 buzzing')) self.press(QUIZ_RUNNER, BUTTON_B) self.press(TEAM2, BUTTON_A) self.expect( see(QUIZ_RUNNER, 'team 2 buzzing'), see(TEAM2, 'team 2 buzzing')) self.press(QUIZ_RUNNER, BUTTON_A) self.expect( see(QUIZ_RUNNER, 'round over'), see(TEAM1, 'round over'), see(TEAM2, 'round over')) # play another round self.expect( see(QUIZ_RUNNER, 'round 2'), see(TEAM1, 'round 2'), see(TEAM2, 'round 2')) self.press(TEAM2, BUTTON_A) self.expect( see(QUIZ_RUNNER, 'team 2 buzzing'), see(TEAM2, 'team 2 buzzing')) self.press(QUIZ_RUNNER, BUTTON_B) self.press(TEAM1, BUTTON_A) self.expect( see(QUIZ_RUNNER, 'team 1 buzzing'), see(TEAM1, 'team 1 buzzing')) self.press(QUIZ_RUNNER, BUTTON_B) self.press_extra(QUIZ_RUNNER, BUTTON_C) self.expect( see(QUIZ_RUNNER, 'round over'), see(TEAM1, 'round over'), see(TEAM2, 'round over')) sleep(1.0) # allow radio stuff to clear self.expect( see(QUIZ_RUNNER, 'round 3'), see(TEAM1, 'round 3'), see(TEAM2, 'round 3')) self.press_extra(QUIZ_RUNNER, BUTTON_D) self.expect( see(QUIZ_RUNNER, 'game over'), see(QUIZ_RUNNER, all_of(contains_string("that's all"), contains_string('1:0'), contains_string('2:1')))) sleep(1.0) # wait for cool-down
def test_button_and_display(self): # adjust these to reflect the relative or absolute path to the script to run on the microbit self.run_scripts(Target('microbit 1', 'tests/e2e/button_radio.py'), Target('microbit 2', 'tests/e2e/button_radio.py')) self.press('microbit 1', BUTTON_A) self.expect(see('microbit 2', 'signal received!'))