tests: Fix tests
[nit.git] / src / doc / commands / tests / test_commands_http.nit
index e435de2..1f51238 100644 (file)
@@ -38,15 +38,15 @@ class TestCommandsHttp
 
        fun test_cmd_http_entity is test do
                var req = new_request("/test_prog::Character")
-               var cmd = new CmdEntity(test_model, test_filter)
+               var cmd = new CmdEntity(test_model)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.mentity.as(not null).full_name == "test_prog::Character"
        end
 
        fun test_cmd_http_entity_not_found is test do
-               var req = new_request("/Characterzzz")
-               var cmd = new CmdEntity(test_model, test_filter)
+               var req = new_request("/Characterz")
+               var cmd = new CmdEntity(test_model)
                var res = cmd.http_init(req)
                assert res isa ErrorMEntityNotFound
                assert res.suggestions.first.full_name == "test_prog::Character"
@@ -54,7 +54,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_entity_conflict is test do
                var req = new_request("/+")
-               var cmd = new CmdEntity(test_model, test_filter)
+               var cmd = new CmdEntity(test_model)
                var res = cmd.http_init(req)
                assert res isa ErrorMEntityConflict
                assert res.conflicts.length == 2
@@ -64,7 +64,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_comment is test do
                var req = new_request("/test_prog::Character")
-               var cmd = new CmdComment(test_model, test_filter)
+               var cmd = new CmdComment(test_model)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.mdoc != null
@@ -72,7 +72,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_comment_no_mdoc is test do
                var req = new_request("/test_prog::Character?fallback=false")
-               var cmd = new CmdComment(test_model, test_filter)
+               var cmd = new CmdComment(test_model)
                var res = cmd.http_init(req)
                assert res isa WarningNoMDoc
        end
@@ -119,7 +119,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_parents is test do
                var req = new_request("/test_prog::Warrior")
-               var cmd = new CmdParents(test_model, test_main, test_filter)
+               var cmd = new CmdParents(test_model, test_main)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.results.as(not null).length == 1
@@ -127,7 +127,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_ancestors is test do
                var req = new_request("/test_prog::Warrior")
-               var cmd = new CmdAncestors(test_model, test_main, test_filter)
+               var cmd = new CmdAncestors(test_model, test_main)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.results.as(not null).length == 2
@@ -135,7 +135,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_ancestorsi_without_parents is test do
                var req = new_request("/test_prog::Warrior?parents=false")
-               var cmd = new CmdAncestors(test_model, test_main, test_filter)
+               var cmd = new CmdAncestors(test_model, test_main)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.results.as(not null).length == 1
@@ -143,7 +143,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_children is test do
                var req = new_request("/test_prog::Career")
-               var cmd = new CmdChildren(test_model, test_main, test_filter)
+               var cmd = new CmdChildren(test_model, test_main)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.results.as(not null).length == 3
@@ -151,17 +151,25 @@ class TestCommandsHttp
 
        fun test_cmd_http_descendants is test do
                var req = new_request("/test_prog::Career?children=false")
-               var cmd = new CmdDescendants(test_model, test_main, test_filter)
+               var cmd = new CmdDescendants(test_model, test_main)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.results.as(not null).length == 0
        end
 
+       fun test_cmd_http_ancestors_with_filter_match is test do
+               var req = new_request("/test_prog::Warrior?match=Object")
+               var cmd = new CmdAncestors(test_model, test_main)
+               var res = cmd.http_init(req)
+               assert res isa CmdSuccess
+               assert cmd.results.as(not null).length == 1
+       end
+
        # CmdSearch
 
        fun test_cmd_http_search is test do
                var req = new_request("/?q=Carer&l=1")
-               var cmd = new CmdSearch(test_model, test_filter)
+               var cmd = new CmdSearch(test_model)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.results.as(not null).first.full_name == "test_prog::Career"
@@ -170,7 +178,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_search_no_query is test do
                var req = new_request("/")
-               var cmd = new CmdSearch(test_model, test_filter)
+               var cmd = new CmdSearch(test_model)
                var res = cmd.http_init(req)
                assert res isa ErrorNoQuery
        end
@@ -179,7 +187,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_features is test do
                var req = new_request("/test_prog::Character?l=10")
-               var cmd = new CmdFeatures(test_model, test_filter)
+               var cmd = new CmdFeatures(test_model)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.results.as(not null).length == 10
@@ -187,24 +195,32 @@ class TestCommandsHttp
 
        fun test_cmd_http_features_no_features is test do
                var req = new_request("/test_prog$Career$strength_bonus?l=10")
-               var cmd = new CmdFeatures(test_model, test_filter)
+               var cmd = new CmdFeatures(test_model)
                var res = cmd.http_init(req)
                assert res isa WarningNoFeatures
        end
 
+       fun test_cmd_http_features_with_filter_inherited is test do
+               var req = new_request("/test_prog::TestGame?inherited=TestGame")
+               var cmd = new CmdFeatures(test_model)
+               var res = cmd.http_init(req)
+               assert res isa CmdSuccess
+               assert cmd.results.as(not null).length == 4
+       end
+
        # CmdLinearization
 
        fun test_cmd_http_lin is test do
                var req = new_request("/init?l=10")
-               var cmd = new CmdLinearization(test_model, test_main, test_filter)
+               var cmd = new CmdLinearization(test_model, test_main)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
-               assert cmd.results.as(not null).length == 10
+               assert cmd.results.as(not null).length == 9
        end
 
        fun test_cmd_http_lin_no_lin is test do
                var req = new_request("/test_prog?l=10")
-               var cmd = new CmdLinearization(test_model, test_main, test_filter)
+               var cmd = new CmdLinearization(test_model, test_main)
                var res = cmd.http_init(req)
                assert res isa WarningNoLinearization
        end
@@ -213,7 +229,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_code is test do
                var req = new_request("/test_prog::Career")
-               var cmd = new CmdEntityCode(test_model, test_builder, test_filter)
+               var cmd = new CmdEntityCode(test_model, test_builder)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.node isa AStdClassdef
@@ -222,7 +238,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_code_format is test do
                var req = new_request("/test_prog::Career?format=html")
-               var cmd = new CmdEntityCode(test_model, test_builder, test_filter)
+               var cmd = new CmdEntityCode(test_model, test_builder)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.node isa AStdClassdef
@@ -231,7 +247,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_code_no_code is test do
                var req = new_request("/test_prog")
-               var cmd = new CmdEntityCode(test_model, test_builder, test_filter)
+               var cmd = new CmdEntityCode(test_model, test_builder)
                var res = cmd.http_init(req)
                assert res isa WarningNoCode
        end
@@ -240,7 +256,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_results is test do
                var req = new_request("/?kind=modules&l=2")
-               var cmd = new CmdModelEntities(test_model, test_filter, kind = "modules")
+               var cmd = new CmdModelEntities(test_model, kind = "modules")
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.results.as(not null).length == 2
@@ -248,7 +264,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_results_random is test do
                var req = new_request("/?kind=packages&l=1")
-               var cmd = new CmdRandomEntities(test_model, test_filter, kind = "packages")
+               var cmd = new CmdRandomEntities(test_model, kind = "packages")
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.results.as(not null).length == 1
@@ -258,7 +274,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_uml is test do
                var req = new_request("/test_prog::Character?format=svg")
-               var cmd = new CmdUML(test_model, test_main, test_filter)
+               var cmd = new CmdUML(test_model, test_main)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.uml != null
@@ -267,7 +283,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_uml_not_found is test do
                var req = new_request("/strength_bonus")
-               var cmd = new CmdUML(test_model, test_main, test_filter)
+               var cmd = new CmdUML(test_model, test_main)
                var res = cmd.http_init(req)
                assert res isa WarningNoUML
                assert cmd.format == "dot"
@@ -276,7 +292,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_inh_graph is test do
                var req = new_request("/test_prog::Character?pdepth=1&cdepth=1")
-               var cmd = new CmdInheritanceGraph(test_model, test_main, test_filter)
+               var cmd = new CmdInheritanceGraph(test_model, test_main)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.graph != null
@@ -288,7 +304,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_catalog_search is test do
                var req = new_request("/?q=testprog&l=1")
-               var cmd = new CmdCatalogSearch(test_model, test_catalog, test_filter)
+               var cmd = new CmdCatalogSearch(test_model, test_catalog)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.results.as(not null).first.full_name == "test_prog"
@@ -298,7 +314,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_catalog_tag is test do
                var req = new_request("/test", "/:tid")
-               var cmd = new CmdCatalogTag(test_model, test_catalog, test_filter)
+               var cmd = new CmdCatalogTag(test_model, test_catalog)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.tag == "test"
@@ -307,7 +323,7 @@ class TestCommandsHttp
 
        fun test_cmd_http_catalog_person is test do
                var req = new_request("/Alexandre%20Terrasa", "/:pid")
-               var cmd = new CmdCatalogPerson(test_model, test_catalog, test_filter)
+               var cmd = new CmdCatalogPerson(test_model, test_catalog)
                var res = cmd.http_init(req)
                assert res isa CmdSuccess
                assert cmd.person.as(not null).name == "Alexandre Terrasa"