summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-07-16 14:14:14 +0200
committerfranck cuny <franck@lumberjaph.net>2010-07-16 14:14:14 +0200
commitf4b1e8d72d89383b75ea39febf05255215a49bb1 (patch)
tree7f0de874d0efdab2daee9afb7549ee01dd9cccd9
parentadd attributes to edge (diff)
downloadgraph-gexf-f4b1e8d72d89383b75ea39febf05255215a49bb1.tar.gz
reflect API change on tests
-rw-r--r--t/02-graph.t4
-rw-r--r--t/03-node.t18
-rw-r--r--t/07-attributes.t13
3 files changed, 24 insertions, 11 deletions
diff --git a/t/02-graph.t b/t/02-graph.t
index a81f889..f2ad146 100644
--- a/t/02-graph.t
+++ b/t/02-graph.t
@@ -10,9 +10,9 @@ ok my $graph = Graph::GEXF->new(), 'graph created';
 $graph->add_node_attribute('url', 'anyURI');
 $graph->add_node_attribute('lf', 'integer');
 
-is $graph->total_attributes, 2, 'got 2 attributes';
+is $graph->attributes_node_total, 2, 'got 2 attributes';
 
-ok my $attr = $graph->get_attribute('url'), 'fetch first attribute';
+ok my $attr = $graph->get_node_attribute('url'), 'fetch first attribute';
 is $attr->{title}, 'url', 'first attribute is url';
 
 done_testing;
diff --git a/t/03-node.t b/t/03-node.t
index ccd79fe..f7db7fa 100644
--- a/t/03-node.t
+++ b/t/03-node.t
@@ -1,19 +1,19 @@
 use strict;
 use warnings;
 use Test::More;
-
+use Test::Exception;
 use Graph::GEXF::Node;
 
-ok my $node = Graph::GEXF::Node->new(id =>0), 'node created';
+ok my $node = Graph::GEXF::Node->new(id => 0), 'node created';
 
-ok !$node->attribute('url', 'http://linkfluence.net'), 'can\'t add attribute, not attributes defined';
+dies_ok { $node->attribute('url', 'http://linkfluence.net') }
+'can\'t add attribute, no attributes defined';
 
-ok $node = Graph::GEXF::Node->new(
-    id         => 0,
-    attributes => {url => {title => 'url', type => 'anyURI'}}
-  ),
-  'node created';
+ok $node = Graph::GEXF::Node->new(id => 0,), 'node created';
+ok $node->set_node_attribute(
+    url => {id => 0, name => 'url', type => 'anyURL'}), 'attribute added';
 
-ok $node->attribute('url', 'http://linkfluence.net'), 'add attribute url to node';
+ok $node->attribute('url', 'http://linkfluence.net'),
+  'add attribute url to node';
 
 done_testing;
diff --git a/t/07-attributes.t b/t/07-attributes.t
new file mode 100644
index 0000000..c4d13dd
--- /dev/null
+++ b/t/07-attributes.t
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+use Test::More;
+
+use Graph::GEXF;
+
+my $graph = Graph::GEXF->new();
+ok $graph->add_node_attribute('foo','bar','baz');
+ok $graph->add_edge_attribute('baz', 'bar', 'foo');
+
+print $graph->to_xml;
+
+done_testing;