Commits

Jan-Jaap Driessen  committed 63dba12 Merge
  • Participants
  • Parent commits 4ac7bc0, ee0cb4b
  • Branches pluggable-injector

Comments (0)

Files changed (4)

File fanstatic/injector.py

 from fanstatic.config import convert_config
 from fanstatic import ConfigurationError
 from fanstatic import compat
-from fanstatic.config import convert_config
 from fanstatic.core import Bundle
 from fanstatic import DEBUG, MINIFIED
 import fanstatic

File tests/test_compiler.py

 from fanstatic import Library, Resource, NeededResources
-from fanstatic import compat, Inclusion
+from fanstatic import compat, Inclusion, MINIFIED
 from fanstatic import set_resource_file_existence_checking as check_files
 from fanstatic.compiler import Compiler, Minifier
 from .test_checksum import _copy_testdata
     lib = Library('lib', '')
     a = Resource(lib, 'a.js', compiler='mock', minifier='mock')
 
-    needed = NeededResources(minified=True, resources=[a])
-    incl = Inclusion(needed, compile=True)
+    needed = NeededResources(resources=[a])
+    incl = Inclusion(needed, compile=True, mode=MINIFIED)
     assert len(incl.resources) == 1
     assert incl.resources[0].relpath == 'a.min.js'
     assert incl.resources[0] != a
     lib = Library('lib', '')
     a = Resource(lib, 'foo/bar/a.js', compiler='mock', minifier='mock')
 
-    needed = NeededResources(resources=[a], minified=True)
-    resources = needed.resources()
-    incl = Inclusion(needed, compile=True)
-    assert len(resources) == 1
-    assert resources[0].relpath == 'foo/bar/a.min.js'
-    assert resources[0] != a
+    needed = NeededResources(resources=[a])
+    incl = Inclusion(needed, compile=True, mode=MINIFIED)
+    assert len(incl.resources) == 1
+    assert incl.resources[0].relpath == 'foo/bar/a.min.js'
+    assert incl.resources[0] != a
 
 
 def test_nothing_given_on_resource_uses_settings_from_library(compilers):

File tests/test_config.py

     assert injector.config == {
         'versioning': True,
         'recompute_hashes': False,
-        'rollup': False,
     }
 
 
     assert fanstatic.app.config == {
         'versioning': True,
         'recompute_hashes': False,
-        'rollup': False,
         'publisher_signature': 'foo',
     }

File tests/test_core.py

     a4 = Resource(foo, 'a4.js', depends=[a1])
     a5 = Resource(foo, 'a5.js', depends=[a4, a3])
 
-    needed = NeededResources()
-    needed.need(a1)
-    needed.need(a2)
-    needed.need(a3)
-    assert needed.resources() == [a1, a2, a3]
+    needed = NeededResources(resources=[a1, a2, a3])
+    assert needed.resources() == set([a1, a2, a3])
     # For some reason,for example an error page needs to be rendered,
     # the currently needed resources need to be cleared.
     needed.clear()
-    assert needed.resources() == []
+    assert len(needed.resources()) == 0
     needed.need(a4)
     needed.need(a5)
-    assert needed.resources() == [a1, a2, a4, a3, a5]
+    assert needed.resources() == set([a1, a2, a4, a3, a5])
 
 
 def test_convenience_clear():
     z1 = Resource(foo, 'd.js')
     z2 = Resource(foo, 'e.js', depends=[z1, x1])
 
-    needed = init_needed()
+    needed = init_needed(resources=[y1])
 
-    y1.need()
-    assert needed.resources() == [x2, x1, y1]
+    assert sort_resources(needed.resources()) == [x2, x1, y1]
     # For some reason,for example an error page needs to be rendered,
     # the currently needed resources need to be cleared.
     clear_needed()
-    assert needed.resources() == []
+    assert len(needed.resources()) == 0
     z2.need()
-    assert needed.resources() == [x1, z1, z2]
+    assert sort_resources(needed.resources()) == [x1, z1, z2]
 
 
 def test_check_resource_dependencies():
     style1 = Resource(lib3, 'style1.css')
     style2 = Resource(lib4, 'style2.css', depends=[style1])
 
-    needed = NeededResources()
-
-    needed.need(js3)
-    needed.need(style2)
-    resources = needed.resources()
-    assert resources == [style1, style2, js1, js2, js3]
+    needed = NeededResources(resources=[js3, style2])
+    assert sort_resources(needed.resources()) == \
+        [style1, style2, js1, js2, js3]
 
 
 def test_library_ordering_bug():
 
     app = Resource(app_lib, 'app.js', depends=[bread, obviel_datepicker])
 
-    needed = NeededResources()
-
-    needed.need(app)
-    resources = needed.resources()
+    needed = NeededResources(resources=[app])
+    resources = sort_resources(needed.resources())
     for resource in resources:
         print((resource, resource.library.library_nr))
     assert resources == [jquery, jqueryui, obviel, obviel_forms,