From: Jan Provaznik <[email protected]>

---
 src/spec/fixtures/packagegroups.json |   54 ++++++++++++++
 src/spec/fixtures/packages.json      |  128 ++++++++++++++++++++++++++++++++++
 src/spec/fixtures/repositories.json  |   19 +++++
 src/spec/utils/repository_manager.rb |   45 ++++++++++++
 4 files changed, 246 insertions(+), 0 deletions(-)
 create mode 100644 src/spec/fixtures/packagegroups.json
 create mode 100644 src/spec/fixtures/packages.json
 create mode 100644 src/spec/fixtures/repositories.json
 create mode 100644 src/spec/utils/repository_manager.rb

diff --git a/src/spec/fixtures/packagegroups.json 
b/src/spec/fixtures/packagegroups.json
new file mode 100644
index 0000000..9dd6008
--- /dev/null
+++ b/src/spec/fixtures/packagegroups.json
@@ -0,0 +1,54 @@
+{ "JBoss   Social Networking Web Application" : { "_id" : "JBoss Social 
Networking Web  Application",
+      "conditional_package_names" : {  },
+      "default" : true,
+      "default_package_names" : [  ],
+      "description" : "This group contains a JBoss social networking 
application",
+      "display_order" : 1024,
+      "id" : "JBoss Social Networking Web Application",
+      "immutable" : true,
+      "langonly" : null,
+      "mandatory_package_names" : [  ],
+      "name" : "JBoss Social Networking Web Application",
+      "optional_package_names" : [ "JSocNet" ],
+      "repo_defined" : true,
+      "translated_description" : {  },
+      "translated_name" : {  },
+      "user_visible" : true
+    },
+  "JBoss Drools" : { "_id" : "JBoss Drools",
+      "conditional_package_names" : {  },
+      "default" : true,
+      "default_package_names" : [  ],
+      "description" : "This group contains the JBoss Drools component",
+      "display_order" : 1024,
+      "id" : "JBoss Drools",
+      "immutable" : true,
+      "langonly" : null,
+      "mandatory_package_names" : [  ],
+      "name" : "JBoss Drools",
+      "optional_package_names" : [ "drools-guvnor" ],
+      "repo_defined" : true,
+      "translated_description" : {  },
+      "translated_name" : {  },
+      "user_visible" : true
+    },
+  "JBoss" : { "_id" : "JBoss",
+      "conditional_package_names" : {  },
+      "default" : true,
+      "default_package_names" : [ "jboss-jgroups",
+          "jboss-as5"
+        ],
+      "description" : "This group is a collection of core JBoss packages",
+      "display_order" : 1024,
+      "id" : "JBoss",
+      "immutable" : true,
+      "langonly" : null,
+      "mandatory_package_names" : [  ],
+      "name" : "JBoss Core Packages",
+      "optional_package_names" : [ "jboss-       rails" ],
+      "repo_defined" : true,
+      "translated_description" : {  },
+      "translated_name" : {  },
+      "user_visible" : true
+    }
+}
diff --git a/src/spec/fixtures/packages.json b/src/spec/fixtures/packages.json
new file mode 100644
index 0000000..bb98881
--- /dev/null
+++ b/src/spec/fixtures/packages.json
@@ -0,0 +1,128 @@
+{ "101f17d4-018b-4af4-bfed-46b142c8b721" : { "_id" : 
"101f17d4-018b-4af4-bfed-46b142c8b721",
+      "_ns" : "packages",
+      "arch" : "noarch",
+      "checksum" : { "sha256" : "ec00a837f6995b4af77b0eaa5edf69570e0149a8" },
+      "description" : "The Drools Guvnor Repository for JBoss AS 5",
+      "download_url" : 
"http://localhost//pub/jboss/J-SocialNet-1.0.1.GA-1.noarch.rpm";,
+      "epoch" : "0",
+      "filename" : "J-SocialNet-1.0.1.GA-1.noarch.rpm",
+      "id" : "101f17d4-018b-4af4-bfed-46b142c8b721",
+      "name" : "J-SocialNet",
+      "provides" : [ "J-SocialNet" ],
+      "release" : "1",
+      "requires" : [ "/bin/sh",
+          "jboss- as5"
+        ],
+      "vendor" : null,
+      "version" : "1.0.1.    GA"
+    },
+  "124eef28-0d3d-46eb-8b8b-ae1acba104e0" : { "_id" : 
"124eef28-0d3d-46eb-8b8b-ae1acba104e0",
+      "_ns" : "packages",
+      "arch" : "noarch",
+      "checksum" : { "sha256" : "cf09c311b72b9b0fb0a93ab94fa40aa8c31550de" },
+      "description" : "JBoss JGroups",
+      "download_url" : "http://localhost//pub/jboss/jboss-jgroups-2.6.7.GA-1.  
 noarch.rpm",
+      "epoch" : "0",
+      "filename" : "jboss-jgroups-2.6.7.GA-1.noarch.rpm",
+      "id" : "124eef28-0d3d-46eb-8b8b-ae1acba104e0",
+      "name" : "jboss-jgroups",
+      "provides" : [ "jboss-jgroups" ],
+      "release" : "1",
+      "requires" : [ "/bin/sh" ],
+      "vendor" : null,
+      "version" : "2.6.7.GA"
+    },
+  "1668d633-b86d-4cf0-86d9-745b023c1a16" : { "_id" : 
"1668d633-b86d-4cf0-86d9-745b023c1a16",
+      "_ns" : "packages",
+      "arch" : "noarch",
+      "checksum" : { "sha256" : "7b3c66d475357a7d1fc1697f81bc8076388d35aa" },
+      "description" : "The JBoss Rails deployer for AS5",
+      "download_url" : 
"http://localhost//pub/jboss/jboss-rails-1.0.0.Beta3-1.noarch.rpm";,
+      "epoch" : "0",
+      "filename" : "jboss-rails-1.0.0.Beta3-1.noarch.rpm",
+      "id" : "1668d633-b86d-4cf0-86d9-745b023c1a16",
+      "name" : "jboss-rails",
+      "provides" : [ "perl(jdbc_adapter)",
+          "jboss-rails"
+        ],
+      "release" : "1",
+      "requires" : [ "/bin/sh" ],
+      "vendor" : null,
+      "version" : "1.0.0.Beta3"
+    },
+  "229f8733-0996-4d38-af2d-8e10ceea6661" : { "_id" : 
"229f8733-0996-4d38-af2d-8e10ceea6661",
+      "_ns" : "packages",
+      "arch" : "noarch",
+      "checksum" : { "sha256" : "5148c747ced6a5e25728e49b55f97b5cb8d2e7a0" },
+      "description" : "The Drools Guvnor Repository for JBoss AS 5",
+      "download_url" : 
"http://localhost//pub/jboss/drools-guvnor-5.0.1.GA-1.noarch.rpm";,
+      "epoch" : "0",
+      "filename" : "drools-guvnor-5.0.1.GA-1.noarch.rpm",
+      "id" : "229f8733-0996-4d38-af2d-8e10ceea6661",
+      "name" : "drools-guvnor",
+      "provides" : [ "drools-guvnor" ],
+      "release" : "1",
+      "requires" : [ "/bin/sh",
+          "jboss-as5"
+        ],
+      "vendor" : null,
+      "version" : "5.0.1.GA"
+    },
+  "9fcca05a-af6e-47f0-a4ea-0e31d4a38192" : { "_id" : 
"9fcca05a-af6e-47f0-a4ea-0e31d4a38192",
+      "_ns" : "packages",
+      "arch" : "noarch",
+      "checksum" : { "sha256" : "d373add70015c6aa4d0ef24175ea4ca74f26e54f" },
+      "description" : "A script that produces javadoc-style documentation 
from\nwell-formed JavaScript sourcefiles. At the moment, this means 
it\nsupports    sourcefiles where all functions are mapped to a class\nusing 
prototype-based inheritance.  Anonymous function\ndefinitions (e.g. 
Circle.prototype.getRadius =         function(){ ...} )\nare supported.",
+      "download_url" : 
"http://localhost//pub/jboss/JSDoc-1.10.2-7.fc11.noarch.rpm";,
+      "epoch" : "0",
+      "filename" : "JSDoc-1.10.2-7.fc11.noarch.rpm",
+      "id" : "9fcca05a-af6e-47f0-a4ea-          0e31d4a38192",
+      "name" : "JSDoc",
+      "provides" : [ "perl(JSDoc::XML)",
+          "perl(JSDoc)",
+          "JSDoc",
+          "perl(JavaScript::Syntax::HTML)",
+          "perl(JSDoc::XMI)"
+        ],
+      "release" : "7.fc11",
+      "requires" : [ "perl(Data::Dumper)",
+          "perl(constant)",
+          "perl(:MODULE_COMPAT_5.10.0)",
+          "perl(File::Basename)",
+          "perl(JavaScript::Syntax::HTML)",
+          "perl(warnings)",
+          "perl(JSDoc)",
+          "perl(File::Path)",
+          "perl(JSDoc::XML)",
+          "perl(lib)",
+          "perl(Exporter)",
+          "perl",
+          "/usr/bin/perl",
+          "perl(HTML::         Template)",
+          "perl(Getopt::Long)",
+          "perl(vars)",
+          "perl(File::Copy)",
+          "perl(File::Find)",
+          "perl(JSDoc::XMI)",
+          "perl(strict)"
+        ],
+      "vendor" : null,
+      "version" : "1.10.2"
+    },
+  "a2d1440e-2f22-480f-ace9-04d40361856f" : { "_id" : 
"a2d1440e-2f22-480f-ace9-04d40361856f",
+      "_ns" : "packages",
+      "arch" : "noarch",
+      "checksum" : { "sha256" : "0c77cb7f6c57a39b00ec6ece7fb372ac6ed08277" },
+      "description" : "The JBossAS 5 Java Application Server",
+      "download_url" : 
"http://localhost//pub/jboss/jboss-as5-5.0.0.GA-1.noarch.rpm";,
+      "epoch" : "0",
+      "filename" : "jboss-as5-5.0.0.GA-1.noarch.rpm",
+      "id" : "a2d1440e-2f22-480f-ace9-04d40361856f",
+      "name" : "jboss-as5",
+      "provides" : [ "jboss-as5" ],
+      "release" : "1",
+      "requires" : [ "/bin/sh" ],
+      "vendor" : null,
+      "version" : "5.0.0.GA"
+    }
+}
diff --git a/src/spec/fixtures/repositories.json 
b/src/spec/fixtures/repositories.json
new file mode 100644
index 0000000..f3a2723
--- /dev/null
+++ b/src/spec/fixtures/repositories.json
@@ -0,0 +1,19 @@
+[ { "_id" : "jboss",
+    "arch" : "x86_64",
+    "errata" : "/repositories/jboss/errata/",
+    "id" : "jboss",
+    "name" : "jboss",
+    "packagegroupcategories" : "/repositories/jboss/packagegroupcategories/",
+    "packagegroups" : "/repositories/jboss/packagegroups/",
+    "packages" : "/repositories/jboss/packages/",
+    "source" : { "supported_types" : [ "yum",
+            "local",
+            "rhn"
+          ],
+        "type" : "yum",
+        "url" : "http://example/jboss";
+      },
+    "sync_schedule" : null,
+    "uri_ref" : "/repositories/jboss/",
+    "use_symlinks" : false
+  } ]
diff --git a/src/spec/utils/repository_manager.rb 
b/src/spec/utils/repository_manager.rb
new file mode 100644
index 0000000..cac151c
--- /dev/null
+++ b/src/spec/utils/repository_manager.rb
@@ -0,0 +1,45 @@
+require 'spec_helper'
+
+describe RepositoryManager do
+  before(:all) do
+    @repositories_json = File.read(File.join(File.dirname(__FILE__),
+                                             '../fixtures/repositories.json'))
+    @packagegroups_json = File.read(File.join(File.dirname(__FILE__),
+                                              
'../fixtures/packagegroups.json'))
+    @packages_json = File.read(File.join(File.dirname(__FILE__),
+                                         '../fixtures/packages.json'))
+  end
+
+  before(:each) do
+    hydra = Typhoeus::Hydra.hydra
+    hydra.stub(:get, "http://pulptest/repositories/";).and_return(
+      Typhoeus::Response.new(:code => 200, :body => @repositories_json))
+    hydra.stub(:get, 
"http://pulptest/repositories/jboss/packagegroups/";).and_return(
+      Typhoeus::Response.new(:code => 200, :body => @packagegroups_json))
+    hydra.stub(:get, 
"http://pulptest/repositories/jboss/packages/";).and_return(
+      Typhoeus::Response.new(:code => 200, :body => @packages_json))
+
+    @rmanager = RepositoryManager.new(:config => [{
+      'baseurl' => 'http://pulptest',
+      'yumurl' => 'http://pulptest',
+      'type'    => 'pulp',
+    }])
+  end
+
+  it "should return a list of repositories" do
+    @rmanager.repositories.should have(1).items
+    @rmanager.repositories.first.id.should eql('jboss')
+  end
+
+  it "should return a list of packagegroups" do
+    rep = @rmanager.repositories.first
+    rep.groups.keys.sort.should == ["JBoss Core Packages", "JBoss Drools",
+      "JBoss Social Networking Web Application"]
+  end
+
+  it "should return a list of packages" do
+    rep = @rmanager.repositories.first
+    rep.packages.map {|p| p[:name]}.sort.should == ["J-SocialNet", "JSDoc",
+      "drools-guvnor", "jboss-as5", "jboss-jgroups", "jboss-rails"]
+  end
+end
-- 
1.7.2.2

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to