Exemple #1
0
 def test_get_build(self):
     m = Mock()
     self.mock_travis.build.return_value = m
     res = self.cls.get_build(123)
     assert res == m
     assert self.mock_travis.mock_calls == [
         call.build(123),
         call.build().check_state()
     ]
Exemple #2
0
    def test_should_update_before_building(self):
        out = StringIO()
        err = StringIO()
        parent_mock = Mock()
        build_mock = Mock()
        update_mock = Mock()
        parent_mock.build = build_mock
        parent_mock.update = update_mock
        with patch('probes.models.Probes.build_rules', build_mock), patch('rules.models.Ruleset.update', update_mock):
            call_command('refreshprobes', '-bu', 'probe1', stdout=out, stderr=err)

        parent_mock.assert_has_calls([call.update(), call.build()])
    def test_station_mapper(self):
        assert_that(self.strike_mapper.create_object(self.result), is_(self.station))

        assert_that(self.station_builder.method_calls, is_([
            call.set_number(31),
            call.set_user('<user>'),
            call.set_name('<name>'),
            call.set_country('<country>'),
            call.set_x(11.0),
            call.set_y(49.0),
            call.set_timestamp(self.timestamp),
            call.build()
        ]))
    def test_strike_mapper(self):
        assert_that(self.strike_mapper.create_object(self.result), is_(self.strike))

        assert_that(self.strike_builder.method_calls, is_([
            call.set_id(12),
            call.set_timestamp(self.timestamp, 789),
            call.set_x(11.0),
            call.set_y(51.0),
            call.set_altitude(123),
            call.set_amplitude(21323),
            call.set_station_count(12),
            call.set_lateral_error(5000),
            call.build()
        ]))
    def test_station_mapper(self):
        assert_that(self.strike_mapper.create_object(self.result)).is_equal_to(
            self.station)

        assert_that(self.station_builder.method_calls).is_equal_to([
            call.set_number(31),
            call.set_user('<user>'),
            call.set_name('<name>'),
            call.set_country('<country>'),
            call.set_x(11.0),
            call.set_y(49.0),
            call.set_timestamp(self.timestamp),
            call.build()
        ])
Exemple #6
0
    def test_interpreter_state_machine_members_initialized_as_expected(
            self, test_context):

        expected_state = InterpreterState.START
        expected_actions = self._mock_actions
        expected_frame = {}
        expected_calls = [
            call.from_state(InterpreterState.START),
            call.given_trigger_state(InterpreterState.PARSE_TOKENS),
            call.take_transition_action(self._mock_actions.parse),
            call.transition_to_state(InterpreterState.PARSE_TOKENS),
            call.append(),
            call.from_state(InterpreterState.DISPATCH_PARSER),
            call.append(),
            call.from_state(InterpreterState.PARSE_TOKENS),
            call.given_trigger_state(InterpreterState.DISPATCH_PARSER),
            call.take_transition_action(self._mock_actions.dispatch),
            call.transition_to_state(InterpreterState.DISPATCH_PARSER),
            call.append(),
            call.from_state(InterpreterState.START),
            call.given_trigger_state(InterpreterState.EVALUATE),
            call.take_transition_action(self._mock_actions.evaluate),
            call.transition_to_state(InterpreterState.EVALUATE),
            call.append(),
            call.from_state(InterpreterState.REPORT_RESULT),
            call.append(),
            call.from_state(InterpreterState.EVALUATE),
            call.given_trigger_state(InterpreterState.REPORT_RESULT),
            call.take_transition_action(self._mock_actions.report),
            call.transition_to_state(InterpreterState.REPORT_RESULT),
            call.build()
        ]

        test_context.context_service.get_context_variable.return_value = expected_state
        state_machine = InterpreterStateMachine(
            test_context.logger,
            self._mock_actions,
            self._mock_transition_builder,
            context_service=test_context.context_service)

        self.assertIs(state_machine._logger, test_context.logger)
        self.assertIs(state_machine._actions, expected_actions)
        self.assertEqual(state_machine._frame, expected_frame)

        self.assertIs(state_machine._trigger_to_transition,
                      self._mock_transition_builder.build.return_value)
        self.assertIs(state_machine.current_state, expected_state)

        self.assertEqual(self._mock_transition_builder.mock_calls,
                         expected_calls)
    def test_strike_mapper(self):
        assert_that(self.strike_mapper.create_object(self.result)).is_equal_to(
            self.strike)

        assert_that(self.strike_builder.method_calls).is_equal_to([
            call.set_id(12),
            call.set_timestamp(self.timestamp, 789),
            call.set_x(11.0),
            call.set_y(51.0),
            call.set_altitude(123),
            call.set_amplitude(21323),
            call.set_station_count(12),
            call.set_lateral_error(5000),
            call.build()
        ])