Beispiel #1
0
    def test_jquery_from_cdn_without_custom_sri_hash(self):
        include_jquery = _moment.include_jquery(version='2.1.1',
                                                sri='sha384-12345678')

        assert ('<script src=\"//code.jquery.com/jquery-2.1.1.min.js\"'
                ' integrity=\"sha384-12345678\" crossorigin=\"anonymous\">'
                '</script>') == include_jquery
    def test_jquery_from_cdn_without_custom_sri_hash(self):
        include_jquery = _moment.include_jquery(version='2.1.1',
                                                sri='sha384-12345678')

        assert ('<script src=\"//code.jquery.com/jquery-2.1.1.min.js\"'
                ' integrity=\"sha384-12345678\" crossorigin=\"anonymous\">'
                '</script>') == include_jquery
Beispiel #3
0
    def test_include_jquery_default(self):
        include_jquery = _moment.include_jquery()

        assert isinstance(include_jquery, Markup)
        assert all([
            each in str(include_jquery)
            for each in ['code.jquery.com', '2.1.0']
        ])
    def test_disabling_sri_jquery_custom_version(self):
        include_jquery = _moment.include_jquery(version='2.1.1', sri=False)

        assert 'src=\"' in include_jquery
        assert 'integrity=\"' not in include_jquery
        assert 'crossorigin\"' not in include_jquery
    def test_disabling_sri_jquery_custom_js(self):
        include_jquery = _moment.include_jquery(local_js=True, sri=False)

        assert 'src=\"' in include_jquery
        assert 'integrity=\"' not in include_jquery
        assert 'crossorigin\"' not in include_jquery
    def test_disabling_sri_jquery_default(self):
        include_jquery = _moment.include_jquery(sri=False)

        assert 'src=\"' in include_jquery
        assert 'integrity=\"' not in include_jquery
        assert 'crossorigin\"' not in include_jquery
    def test_jquery_local_with_sri(self):
        include_jquery = _moment.include_jquery(local_js=True,
                                                sri='sha384-12345678')

        assert ('<script src=\"True\" integrity=\"sha384-12345678\"'
                ' crossorigin=\"anonymous\"></script>\n') == include_jquery
    def test_jquery_local_has_no_sri_as_default(self):
        include_jquery = _moment.include_jquery(local_js=True)

        assert 'src=\"' in include_jquery
        assert 'integrity=\"' not in include_jquery
        assert 'crossorigin\"' not in include_jquery
Beispiel #9
0
    def test_jquery_with_default_version(self):
        include_jquery = _moment.include_jquery()

        assert 'src=\"' in include_jquery
        assert 'integrity=\"sha' in include_jquery
        assert 'crossorigin=\"anonymous\"' in include_jquery
    def test_jquery_with_non_default_version(self):
        include_jquery = _moment.include_jquery(version='2.0.9')

        assert 'src=\"' in include_jquery
        assert 'integrity=\"' not in include_jquery
        assert 'crossorigin=\"' not in include_jquery
Beispiel #11
0
    def test_disabling_sri_jquery_custom_version(self):
        include_jquery = _moment.include_jquery(version='2.1.1', sri=False)

        assert 'src=\"' in include_jquery
        assert 'integrity=\"' not in include_jquery
        assert 'crossorigin\"' not in include_jquery
Beispiel #12
0
    def test_disabling_sri_jquery_custom_js(self):
        include_jquery = _moment.include_jquery(local_js=True, sri=False)

        assert 'src=\"' in include_jquery
        assert 'integrity=\"' not in include_jquery
        assert 'crossorigin\"' not in include_jquery
Beispiel #13
0
    def test_disabling_sri_jquery_default(self):
        include_jquery = _moment.include_jquery(sri=False)

        assert 'src=\"' in include_jquery
        assert 'integrity=\"' not in include_jquery
        assert 'crossorigin\"' not in include_jquery
Beispiel #14
0
    def test_jquery_local_with_sri(self):
        include_jquery = _moment.include_jquery(local_js=True,
                                                sri='sha384-12345678')

        assert ('<script src=\"True\" integrity=\"sha384-12345678\"'
                ' crossorigin=\"anonymous\"></script>\n') == include_jquery
Beispiel #15
0
    def test_jquery_local_has_no_sri_as_default(self):
        include_jquery = _moment.include_jquery(local_js=True)

        assert 'src=\"' in include_jquery
        assert 'integrity=\"' not in include_jquery
        assert 'crossorigin\"' not in include_jquery
    def test_include_jquery_default(self):
        include_jquery = _moment.include_jquery()

        assert isinstance(include_jquery, Markup)
        assert all([each in str(include_jquery) for each in [
            'code.jquery.com', default_jquery_version]])
    def test_include_jquery_local(self):
        include_jquery = _moment.include_jquery(local_js=True)

        assert all([each in str(include_jquery) for each in [
            '<script', '</script>']])
    def test_jquery_with_default_version(self):
        include_jquery = _moment.include_jquery()

        assert 'src=\"' in include_jquery
        assert 'integrity=\"sha' in include_jquery
        assert 'crossorigin=\"anonymous\"' in include_jquery
Beispiel #19
0
    def test_include_jquery_local(self):
        include_jquery = _moment.include_jquery(local_js=True)

        assert all(
            [each in str(include_jquery) for each in ['<script', '</script>']])
Beispiel #20
0
    def test_jquery_with_non_default_version(self):
        include_jquery = _moment.include_jquery(version='2.0.9')

        assert 'src=\"' in include_jquery
        assert 'integrity=\"' not in include_jquery
        assert 'crossorigin=\"' not in include_jquery