Пример #1
0
def test_bundle_single_entry():
    # we can successfully bundle a single resource (it's not bundled though)
    foo = Library('foo', '')
    a = Resource(foo, 'a.js')

    resources = bundle_resources([a])
    assert resources == [a]
Пример #2
0
def test_bundle_single_entry():
    # we can successfully bundle a single resource (it's not bundled though)
    foo = Library('foo', '')
    a = Resource(foo, 'a.js')

    resources = bundle_resources([a])
    assert resources == [a]
Пример #3
0
def test_bundle():
    foo = Library('foo', '')
    a = Resource(foo, 'a.css')
    b = Resource(foo, 'b.css')

    resources = bundle_resources([a, b])
    assert len(resources) == 1
    bundle = resources[0]
    assert bundle.resources() == [a, b]
Пример #4
0
def test_bundle():
    foo = Library('foo', '')
    a = Resource(foo, 'a.css')
    b = Resource(foo, 'b.css')

    resources = bundle_resources([a, b])
    assert len(resources) == 1
    bundle = resources[0]
    assert bundle.resources() == [a, b]
Пример #5
0
def test_bundle_different_renderer():
    # resources with different renderers aren't bundled
    foo = Library('foo', '')
    a = Resource(foo, 'a.css')
    b = Resource(foo, 'b.js')

    resources = bundle_resources([a, b])
    assert len(resources) == 2
    assert resources[0] is a
    assert resources[1] is b
Пример #6
0
def test_bundle_dont_bundle_at_the_start():
    foo = Library('foo', '')
    a = Resource(foo, 'a.css', dont_bundle=True)
    b = Resource(foo, 'b.css')
    c = Resource(foo, 'c.css')

    resources = bundle_resources([a, b, c])
    assert len(resources) == 2
    assert resources[0] is a
    assert resources[1].resources() == [b, c]
Пример #7
0
def test_bundle_dont_bundle_at_the_end():
    foo = Library('foo', '')
    a = Resource(foo, 'a.css')
    b = Resource(foo, 'b.css')
    c = Resource(foo, 'c.css', dont_bundle=True)

    resources = bundle_resources([a, b, c])
    assert len(resources) == 2
    assert resources[0].resources() == [a, b]
    assert resources[-1] is c
Пример #8
0
def test_bundle_different_renderer():
    # resources with different renderers aren't bundled
    foo = Library('foo', '')
    a = Resource(foo, 'a.css')
    b = Resource(foo, 'b.js')

    resources = bundle_resources([a, b])
    assert len(resources) == 2
    assert resources[0] is a
    assert resources[1] is b
Пример #9
0
def test_bundle_dont_bundle_at_the_start():
    foo = Library('foo', '')
    a = Resource(foo, 'a.css', dont_bundle=True)
    b = Resource(foo, 'b.css')
    c = Resource(foo, 'c.css')

    resources = bundle_resources([a, b, c])
    assert len(resources) == 2
    assert resources[0] is a
    assert resources[1].resources() == [b, c]
Пример #10
0
def test_bundle_dont_bundle_at_the_end():
    foo = Library('foo', '')
    a = Resource(foo, 'a.css')
    b = Resource(foo, 'b.css')
    c = Resource(foo, 'c.css', dont_bundle=True)

    resources = bundle_resources([a, b, c])
    assert len(resources) == 2
    assert resources[0].resources() == [a, b]
    assert resources[-1] is c
Пример #11
0
def test_bundle_different_directory():
    # resources with different directories aren't bundled
    foo = Library('foo', '')
    a = Resource(foo, 'first/a.css')
    b = Resource(foo, 'second/b.css')

    resources = bundle_resources([a, b])
    assert len(resources) == 2
    assert resources[0] is a
    assert resources[1] is b
Пример #12
0
def test_bundle_different_directory():
    # resources with different directories aren't bundled
    foo = Library('foo', '')
    a = Resource(foo, 'first/a.css')
    b = Resource(foo, 'second/b.css')

    resources = bundle_resources([a, b])
    assert len(resources) == 2
    assert resources[0] is a
    assert resources[1] is b
Пример #13
0
def test_bundle_different_library():
    # resources with different libraries aren't bundled
    l1 = Library('l1', '')
    l2 = Library('l2', '')
    a = Resource(l1, 'a.js')
    b = Resource(l2, 'b.js')

    resources = bundle_resources([a, b])
    assert len(resources) == 2
    assert resources[0] is a
    assert resources[1] is b
Пример #14
0
def test_bundle_different_library():
    # resources with different libraries aren't bundled
    l1 = Library('l1', '')
    l2 = Library('l2', '')
    a = Resource(l1, 'a.js')
    b = Resource(l2, 'b.js')

    resources = bundle_resources([a, b])
    assert len(resources) == 2
    assert resources[0] is a
    assert resources[1] is b
Пример #15
0
def test_bundle_dont_bundle_in_the_middle():
    # now construct a scenario where a dont_bundle resource is in the way
    # of bundling
    foo = Library('foo', '')
    a = Resource(foo, 'a.css')
    b = Resource(foo, 'b.css', dont_bundle=True)
    c = Resource(foo, 'c.css')

    resources = bundle_resources([a, b, c])
    assert len(resources) == 3
    assert resources[0] is a
    assert resources[1] is b
    assert resources[2] is c
Пример #16
0
def test_bundle_dont_bundle_in_the_middle():
    # now construct a scenario where a dont_bundle resource is in the way
    # of bundling
    foo = Library('foo', '')
    a = Resource(foo, 'a.css')
    b = Resource(foo, 'b.css', dont_bundle=True)
    c = Resource(foo, 'c.css')

    resources = bundle_resources([a, b, c])
    assert len(resources) == 3
    assert resources[0] is a
    assert resources[1] is b
    assert resources[2] is c
Пример #17
0
def test_bundle_single_dont_bundle_entry():
    foo = Library('foo', '')
    a = Resource(foo, 'a.js', dont_bundle=True)

    resources = bundle_resources([a])
    assert resources == [a]
Пример #18
0
def test_bundle_empty_list():
    # we can successfully bundle an empty list of resources
    resources = bundle_resources([])
    assert resources == []
Пример #19
0
def test_bundle_empty_list():
    # we can successfully bundle an empty list of resources
    resources = bundle_resources([])
    assert resources == []
Пример #20
0
def test_bundle_single_dont_bundle_entry():
    foo = Library('foo', '')
    a = Resource(foo, 'a.js', dont_bundle=True)

    resources = bundle_resources([a])
    assert resources == [a]