예제 #1
0
    def test_calendar_publish_event(self):  # pylint: disable=no-self-use
        """ Test event publishing in GoogleCalendarBlock"""
        block = TestGoogleCalendarBlock.make_calendar_block()

        body = json.dumps(TEST_COMPLETE_PUBLISH_DATA)
        res = block.handle('publish_event', make_request(body))
        # pylint: disable=no-value-for-parameter
        assert_equals(json.loads(res.body), RESULT_SUCCESS)

        body = json.dumps(TEST_INCOMPLETE_PUBLISH_DATA)
        res = block.handle('publish_event', make_request(body))

        assert_equals(json.loads(res.body), RESULT_MISSING_EVENT_TYPE)
예제 #2
0
    def test_studio_document_submit(self):  # pylint: disable=no-self-use
        """ Test studio submission of GoogleDocumentBlock """
        block = TestGoogleDocumentBlock.make_document_block()

        body = json.dumps(TEST_SUBMIT_DATA)
        res = block.handle('studio_submit', make_request(body))
        # pylint: disable=no-value-for-parameter
        assert_equals(json.loads(res.body), RESULT_SUCCESS)

        assert_equals(block.display_name, TEST_SUBMIT_DATA['display_name'])
        assert_equals(block.embed_code, TEST_SUBMIT_DATA['embed_code'])
        assert_equals(block.alt_text, TEST_SUBMIT_DATA['alt_text'])

        body = json.dumps('')
        res = block.handle('studio_submit', make_request(body))
        assert_equals(json.loads(res.body), RESULT_ERROR)
예제 #3
0
    def test_calendar_document_submit(self):  # pylint: disable=no-self-use
        """ Test studio submission of GoogleCalendarBlock """
        block = TestGoogleCalendarBlock.make_calendar_block()

        body = json.dumps(TEST_SUBMIT_DATA)
        res = block.handle('studio_submit', make_request(body))
        # pylint: disable=no-value-for-parameter
        assert_equals(json.loads(res.body), RESULT_SUCCESS)

        assert_equals(block.display_name, TEST_SUBMIT_DATA['display_name'])
        assert_equals(block.calendar_id, TEST_SUBMIT_DATA['calendar_id'])
        assert_equals(block.default_view, TEST_SUBMIT_DATA['default_view'])

        body = json.dumps('')
        res = block.handle('studio_submit', make_request(body))
        # pylint: disable=no-value-for-parameter
        assert_equals(json.loads(res.body), RESULT_ERROR)
예제 #4
0
    def test_document_publish_event(self):  # pylint: disable=no-self-use
        """ Test event publishing in GoogleDocumentBlock"""
        block = TestGoogleDocumentBlock.make_document_block()

        body = json.dumps(TEST_COMPLETE_PUBLISH_DOCUMENT_DATA)
        res = block.handle('publish_event', make_request(body))
        # pylint: disable=no-value-for-parameter
        assert_equals(json.loads(res.body.decode('utf8')), RESULT_SUCCESS)

        body = json.dumps(TEST_COMPLETE_PUBLISH_IMAGE_DATA)
        res = block.handle('publish_event', make_request(body))

        assert_equals(json.loads(res.body.decode('utf8')), RESULT_SUCCESS)

        body = json.dumps(TEST_INCOMPLETE_PUBLISH_DATA)
        res = block.handle('publish_event', make_request(body))

        assert_equals(json.loads(res.body.decode('utf8')),
                      RESULT_MISSING_EVENT_TYPE)
예제 #5
0
    def test_check_document_url(self):  # pylint: disable=no-self-use
        """ Test verification of the provided Google Document URL"""
        block = TestGoogleDocumentBlock.make_document_block()

        data = json.dumps(TEST_VALIDATE_URL_DATA)
        res = block.handle('check_url', make_request(data))
        # pylint: disable=no-value-for-parameter
        assert_equals(json.loads(res.body), STATUS_CODE_200)

        data = json.dumps(TEST_VALIDATE_UNDEFINED_DATA)
        res = block.handle('check_url', make_request(data))

        assert_equals(json.loads(res.body), STATUS_CODE_400)

        data = json.dumps(TEST_VALIDATE_NONEXISTENT_URL_DATA)
        res = block.handle('check_url', make_request(data))

        assert_equals(json.loads(res.body), STATUS_CODE_404)

        data = json.dumps({})
        res = block.handle('check_url', make_request(data))

        assert_equals(json.loads(res.body), STATUS_CODE_400)