[LON-CAPA-cvs] cvs: modules /jerf/tests utils_authorTest.pm

bowersj2 lon-capa-cvs@mail.lon-capa.org
Thu, 10 Jul 2003 19:36:25 -0000


bowersj2		Thu Jul 10 15:36:25 2003 EDT

  Modified files:              
    /modules/jerf/tests	utils_authorTest.pm 
  Log:
  Can now test for correct metadata types being generated when files are
  published; this should catch that .99.2-ish bug we had if it, or anything
  like it, ever rises again.
  
  
Index: modules/jerf/tests/utils_authorTest.pm
diff -u modules/jerf/tests/utils_authorTest.pm:1.2 modules/jerf/tests/utils_authorTest.pm:1.3
--- modules/jerf/tests/utils_authorTest.pm:1.2	Wed Jul  9 17:04:21 2003
+++ modules/jerf/tests/utils_authorTest.pm	Thu Jul 10 15:36:25 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # testing the course and user objects w.r.t. authoring
 #
-# $Id: utils_authorTest.pm,v 1.2 2003/07/09 21:04:21 bowersj2 Exp $
+# $Id: utils_authorTest.pm,v 1.3 2003/07/10 19:36:25 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -94,12 +94,10 @@
     my $testResource = $Data::HTMLResources[0];
     $user->copyResource($testResource);
     $self->assert($user->publishResource($r, $testResource));
-    print Dumper(%Apache::lonpublisher::metadatakeys) . "\n";
 
     $testResource = "radio.problem";
     $user->copyResource($testResource);
     $self->assert($user->publishResource($r, $testResource));
-    print Dumper(%Apache::lonpublisher::metadatakeys) . "\n";
 }
 
 sub test_metadata_publication {
@@ -117,9 +115,10 @@
 
     $user->initializeResourceSpace();
 
-    for my $type, my $source (each %Data::simpleProblems) {
+    while ((my $type, my $source) = each %Data::typesToProblems) {
 	$user->copyResource($source);
-	$self->assert($user->publishResource($r, $source));
+	$self->assert($user->publishResource($r, $source),
+		      "Test resource $source failed to publish.");
 	
 	my %metadata = %Apache::lonpublisher::metadatakeys;
 	my %comparision = ();
@@ -131,17 +130,30 @@
 	}
 	# Add any problem-type-specific overlays
 	for (keys %{$Data::metadata{$type}}) {
-	    $comparision{$destKey} = $Data::metadata{$type}->{$_};
+	    if (!defined($Data::metadata{$type}->{$_})) {
+		delete $comparision{$_};
+	    } else {
+		$comparision{$_} = $Data::metadata{$type}->{$_};
+	    }
 	}
 
+	my %m2 = %metadata;
+	my %c2 = %comparision;
+	for (keys %metadata) { delete $c2{$_}; }
+	for (keys %comparision) { delete $m2{$_}; }
+
 	$self->assert(scalar(keys(%comparision)) == scalar(keys(%metadata)),
 		      "Publishing problem type $type had mismatched metadata: ".
 		      "\nMetadata from lonpublisher:\n" . Dumper(%metadata) .
-		      "\nMetadata from Data.pm:\n" . Dumper(%comparision));
+		      "\nMetadata from Data.pm:\n"
+		      . Dumper(%comparision) . "\nStuff in comparision" .
+		      " but not in metadata:\n" . Dumper(%c2)
+		      . "\n\nStuff in metadata but not comparision:\n"
+		      . Dumper(%m2));
 	for (keys(%metadata)) {
 	    $self->assert($metadata{$_} eq $comparision{$_},
 			  "Metadata key $_ not equal in the Data.pm hash while ".
-			  "publishing.\nValue from lonpublisher: " .
+			  "publishing $source.\nValue from lonpublisher: " .
 			  $metadata{$_} . "\nValue from Data.pm: " .
 			  $comparision{$_});
 	}