예제 #1
0
    def test_chain_check_empty_input(self, requests_get_patched):
        mock_response = Mock(spec=Response)
        mock_response.status_code = 404
        requests_get_patched.return_value = mock_response

        # noinspection PyTypeChecker
        self.assertFalse(NistBeacon.chain_check(None))
예제 #2
0
    def test_chain_check_no_records_around(self, requests_get_patched):
        first_response = Mock(spec=Response)
        first_response.status_code = 200
        first_response.text = self.expected_current.xml

        none_response = Mock(spec=Response)
        none_response.status_code = 404

        requests_get_patched.side_effect = [
            first_response,
            none_response,
            none_response,
        ]

        self.assertFalse(
            NistBeacon.chain_check(
                self.expected_current.timestamp
            )
        )
예제 #3
0
    def test_chain_check_last(self, requests_get_patched):
        first_response = Mock(spec=Response)
        first_response.status_code = 200
        first_response.text = self.expected_current.xml

        previous_response = Mock(spec=Response)
        previous_response.status_code = 200
        previous_response.text = self.expected_previous.xml

        next_response = Mock(spec=Response)
        next_response.status_code = 404

        requests_get_patched.side_effect = [
            first_response,
            previous_response,
            next_response,
        ]

        self.assertTrue(
            NistBeacon.chain_check(
                self.expected_current.timestamp,
            )
        )
예제 #4
0
    def test_chain_check_init(self, requests_get_patched):
        first_response = Mock(spec=Response)
        first_response.status_code = 200
        first_response.text = self.expected_first.xml

        previous_response = Mock(spec=Response)
        previous_response.status_code = 404

        next_response = Mock(spec=Response)
        next_response.status_code = 200
        next_response.text = self.expected_first_next.xml

        requests_get_patched.side_effect = [
            first_response,
            previous_response,
            next_response,
        ]

        self.assertTrue(
            NistBeacon.chain_check(
                self.init_timestamp,
            )
        )