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]
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]
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
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]
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
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
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
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
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]
def test_bundle_empty_list(): # we can successfully bundle an empty list of resources resources = bundle_resources([]) assert resources == []