Commits

Anonymous committed a3c9050

Fix bundle tests (bundle=true option).

  • Participants
  • Parent commits 9f53af1
  • Branches pluggable-injector

Comments (0)

Files changed (2)

File tests/test_bundle.py

-from fanstatic import Library, Resource, NeededResources, bundle_resources
+from fanstatic import Library, Resource, NeededResources, bundle_resources, sort_resources
 from fanstatic import Inclusion
 
 from fanstatic.core import Bundle
     bundle = bundle_resources([x1, x3, x2])
     assert bundle == [x1, x3, x2]
 
-    # XXX sort_resources does not take care of this for us:
-    needed = NeededResources(bundle=True)
-    needed.need(x1)
-    needed.need(x3)
-    needed.need(x2)
     # The resources are sorted by renderer order, library dependencies
     # and resource dependencies.
-    bundle = bundle_resources(needed.resources())
+    bundle = bundle_resources(sort_resources([x1, x3, x2]))
     assert len(bundle) == 2
     assert isinstance(bundle[0], Bundle)
     assert bundle[1] == x3

File tests/test_core.py

     a = Resource(foo, 'a.css')
     b = Resource(foo, 'b.css')
 
-    needed = NeededResources(bundle=True)
-    needed.need(a)
-    needed.need(b)
-
-    resources = bundle_resources(needed.resources())
+    resources = bundle_resources([a, b])
     assert len(resources) == 1
     bundle = resources[0]
     assert bundle.resources() == [a, b]
     b = Resource(foo, 'b.css')
     c = Resource(foo, 'c.css', dont_bundle=True)
 
-    needed = NeededResources(bundle=True)
-    needed.need(a)
-    needed.need(b)
-    needed.need(c)
-
-    resources = bundle_resources(needed.resources())
+    resources = bundle_resources([a, b, c])
     assert len(resources) == 2
     assert resources[0].resources() == [a, b]
     assert resources[-1] is c
     b = Resource(foo, 'b.css')
     c = Resource(foo, 'c.css')
 
-    needed = NeededResources(bundle=True)
-    needed.need(a)
-    needed.need(b)
-    needed.need(c)
-
-    resources = bundle_resources(needed.resources())
+    resources = bundle_resources([a, b, c])
     assert len(resources) == 2
     assert resources[0] is a
     assert resources[1].resources() == [b, c]
     b = Resource(foo, 'b.css', dont_bundle=True)
     c = Resource(foo, 'c.css')
 
-    needed = NeededResources(bundle=True)
-    needed.need(a)
-    needed.need(b)
-    needed.need(c)
-
-    resources = needed.resources()
+    resources = bundle_resources([a, b, c])
     assert len(resources) == 3
     assert resources[0] is a
     assert resources[1] is b
     a = Resource(foo, 'a.css')
     b = Resource(foo, 'b.js')
 
-    needed = NeededResources(bundle=True)
-    needed.need(a)
-    needed.need(b)
-
-    resources = needed.resources()
-
+    resources = bundle_resources([a, b])
     assert len(resources) == 2
     assert resources[0] is a
     assert resources[1] is b
     a = Resource(l1, 'a.js')
     b = Resource(l2, 'b.js')
 
-    needed = NeededResources(bundle=True)
-    needed.need(a)
-    needed.need(b)
-
-    resources = needed.resources()
-
+    resources = bundle_resources([a, b])
     assert len(resources) == 2
     assert resources[0] is a
     assert resources[1] is b
     a = Resource(foo, 'first/a.css')
     b = Resource(foo, 'second/b.css')
 
-    needed = NeededResources(bundle=True)
-    needed.need(a)
-    needed.need(b)
-
-    resources = needed.resources()
-
+    resources = bundle_resources([a, b])
     assert len(resources) == 2
     assert resources[0] is a
     assert resources[1] is b
 
 def test_bundle_empty_list():
     # we can successfully bundle an empty list of resources
-    needed = NeededResources(bundle=True)
-
-    resources = needed.resources()
+    resources = bundle_resources([])
     assert resources == []
 
 
     foo = Library('foo', '')
     a = Resource(foo, 'a.js')
 
-    needed = NeededResources(bundle=True)
-    needed.need(a)
-    resources = needed.resources()
-
+    resources = bundle_resources([a])
     assert resources == [a]
 
 
     foo = Library('foo', '')
     a = Resource(foo, 'a.js', dont_bundle=True)
 
-    needed = NeededResources(bundle=True)
-    needed.need(a)
-    resources = needed.resources()
-
+    resources = bundle_resources([a])
     assert resources == [a]