Пример #1
0
    def setUp(self):
        super(GitterAdapterTestCase, self).setUp()
        import requests

        requests.post = Mock(side_effect=mock_post_response)

        gitter.requests = requests

        self.adapter = Gitter(gitter_room='',
                              gitter_api_token='',
                              gitter_sleep_time=0,
                              gitter_only_respond_to_mentions=False)
    def setUp(self):
        super(GitterAdapterTestCase, self).setUp()
        import requests

        requests.post = Mock(side_effect=mock_post_response)

        gitter.requests = requests

        self.adapter = Gitter(
            gitter_room="", gitter_api_token="", gitter_sleep_time=0, gitter_only_respond_to_mentions=False
        )
Пример #3
0
class GitterAdapterTestCase(TestCase):
    def setUp(self):
        super(GitterAdapterTestCase, self).setUp()
        import requests

        requests.post = Mock(side_effect=mock_post_response)

        gitter.requests = requests

        self.adapter = Gitter(gitter_room='',
                              gitter_api_token='',
                              gitter_sleep_time=0,
                              gitter_only_respond_to_mentions=False)

    def test_validate_status_code_200(self):
        response = MockResponse(200, {})

        try:
            self.adapter._validate_status_code(response)
        except Gitter.HTTPStatusException:
            self.fail('Test raised HTTPStatusException unexpectedly!')

    def test_validate_status_code_201(self):
        response = MockResponse(201, {})

        try:
            self.adapter._validate_status_code(response)
        except Gitter.HTTPStatusException:
            self.fail('Test raised HTTPStatusException unexpectedly!')

    def test_response_status_code_not_ok(self):
        response = MockResponse(404, {})

        with self.assertRaises(Gitter.HTTPStatusException):
            self.adapter._validate_status_code(response)

    def test_join_room(self):
        data = self.adapter.join_room('room_name')
        self.assertIn('id', data)

    def test_send_message(self):
        pass

    def test_process_response(self):
        statement = Statement('Hello')
        output_statement = self.adapter.process_response(statement)

        self.assertEqual(output_statement, statement)
class GitterAdapterTestCase(TestCase):
    def setUp(self):
        super(GitterAdapterTestCase, self).setUp()
        import requests

        requests.post = Mock(side_effect=mock_post_response)

        gitter.requests = requests

        self.adapter = Gitter(
            gitter_room="", gitter_api_token="", gitter_sleep_time=0, gitter_only_respond_to_mentions=False
        )

    def test_validate_status_code_200(self):
        response = MockResponse(200, {})

        try:
            self.adapter._validate_status_code(response)
        except Gitter.HTTPStatusException:
            self.fail("Test raised HTTPStatusException unexpectedly!")

    def test_validate_status_code_201(self):
        response = MockResponse(201, {})

        try:
            self.adapter._validate_status_code(response)
        except Gitter.HTTPStatusException:
            self.fail("Test raised HTTPStatusException unexpectedly!")

    def test_response_status_code_not_ok(self):
        response = MockResponse(404, {})

        with self.assertRaises(Gitter.HTTPStatusException):
            self.adapter._validate_status_code(response)

    def test_join_room(self):
        data = self.adapter.join_room("room_name")
        self.assertIn("id", data)

    def test_send_message(self):
        pass

    def test_process_response(self):
        statement = Statement("Hello")
        output_statement = self.adapter.process_response(statement)

        self.assertEqual(output_statement, statement)