Example #1
0
 def _check_license_url_against_parameters(parameters, expected_url):
     """
     See if the license's url given by the chooser for PARAMETERS
     matches EXPECTED_URL
     """
     util._clear_test_template_context()
     TESTAPP.get('/choose/?' + urllib.urlencode(parameters))
     license = util.TEST_TEMPLATE_CONTEXT[
         'chooser_pages/interactive_chooser.html']['license']
     assert_equal(license.uri, expected_url)
 def _check_license_url_against_parameters(parameters, expected_url):
     """
     See if the license's url given by the chooser for PARAMETERS
     matches EXPECTED_URL
     """
     util._clear_test_template_context()
     TESTAPP.get(
         '/choose/?' +
         urllib.urlencode(parameters))
     license = util.TEST_TEMPLATE_CONTEXT[
         'chooser_pages/interactive_chooser.html']['license']
     assert_equal(license.uri, expected_url)
    def test_cc0_results_email_send(self):
        util._clear_test_template_context()
        # For doing a POST (email sending time!)
        # --------------------------------------
        response = TESTAPP.post(
            '/choose/zero/results',
            {'email': '*****@*****.**'})

        # assert that there's 1 message in the inbox,
        # and that it's the right one
        assert_equal(len(util.EMAIL_TEST_INBOX), 1)
        sent_mail = util.EMAIL_TEST_INBOX.pop()
        assert_equal(sent_mail['To'], '*****@*****.**')
        assert_equal(sent_mail['From'], '*****@*****.**')
        assert_equal(
            sent_mail['Subject'],
            "Your Creative Commons License Information")
        mail_body = sent_mail.get_payload()

        assert 'You have selected CC0 1.0 Universal' in mail_body
        assert 'To the extent possible under law,' in mail_body

        # check that the right template was loaded
        assert util.TEST_TEMPLATE_CONTEXT.has_key(
            'chooser_pages/zero/results.html')

        # For doing a GET (shouldn't send email!)
        # ---------------------------------------
        util._clear_test_inboxes()
        util._clear_test_template_context()

        response = TESTAPP.get(
            '/choose/zero/[email protected]')

        # assert that there's no messages in the inbox
        assert_equal(len(util.EMAIL_TEST_INBOX), 0)

        # check that the right template was loaded
        assert util.TEST_TEMPLATE_CONTEXT.has_key(
            'chooser_pages/zero/results.html')
Example #4
0
    def test_cc0_results_email_send(self):
        util._clear_test_template_context()
        # For doing a POST (email sending time!)
        # --------------------------------------
        response = TESTAPP.post('/choose/zero/results',
                                {'email': '*****@*****.**'})

        # assert that there's 1 message in the inbox,
        # and that it's the right one
        assert_equal(len(util.EMAIL_TEST_INBOX), 1)
        sent_mail = util.EMAIL_TEST_INBOX.pop()
        assert_equal(sent_mail['To'], '*****@*****.**')
        assert_equal(sent_mail['From'], '*****@*****.**')
        assert_equal(sent_mail['Subject'],
                     "Your Creative Commons License Information")
        mail_body = sent_mail.get_payload()

        assert 'You have selected CC0 1.0 Universal' in mail_body
        assert 'To the extent possible under law,' in mail_body

        # check that the right template was loaded
        assert util.TEST_TEMPLATE_CONTEXT.has_key(
            'chooser_pages/zero/results.html')

        # For doing a GET (shouldn't send email!)
        # ---------------------------------------
        util._clear_test_inboxes()
        util._clear_test_template_context()

        response = TESTAPP.get(
            '/choose/zero/[email protected]')

        # assert that there's no messages in the inbox
        assert_equal(len(util.EMAIL_TEST_INBOX), 0)

        # check that the right template was loaded
        assert util.TEST_TEMPLATE_CONTEXT.has_key(
            'chooser_pages/zero/results.html')
 def setUp(self):
     util._clear_test_inboxes()
     util._clear_test_template_context()
Example #6
0
 def setUp(self):
     util._clear_test_inboxes()
     util._clear_test_template_context()