best way to test that AF has connected?

9 views
Skip to first unread message

Bess Sadler

unread,
Aug 11, 2011, 3:44:15 PM8/11/11
to active...@googlegroups.com
Hi, everyone. 

I'm incorporating AF into a ruby gem I'm writing (https://github.com/sul-dlss/ruby_ftk_toolkit). What's the best way to test that a fedora connection has been successfully established? 

Here's what I have right now:

    it "can accept a fedora url as an argument and intialize a connection to fedora" do
      fedora_config = File.join(File.dirname(__FILE__), "/../config/fedora.yml")
      hfo = HypatiaFileObject.new(:fedora_config => fedora_config)
      Fedora::Repository.instance.fedora_version.should eql("3.4.2")
    end

I'm assuming that it wouldn't be able to get the fedora version number if it didn't have a connection. However, this is a little brittle, as the test will break whenever hydra-jetty upgrades its version of fedora. Not a huge deal, as that won't happen a lot, but I'm wondering if there's a better pattern I should be using. 

Thanks in advance, 
Bess

John Scofield

unread,
Aug 11, 2011, 4:08:33 PM8/11/11
to active...@googlegroups.com
Hi Bess,

If AF doesn't make a connection I believe you will get an error when referencing Fedora::Repository.instance.version_number along the lines of:

RuntimeError: did you register a repo?

With your current test, you could just check to make sure it is not an empty string to make it compatible with upgrading/changing fedora version so you'll be covered.

Anyway that's my two cents.

Cheers,

John

--
You received this message because you are subscribed to the Google Groups "ActiveFedora / Ruby + Fedora Commons" group.
To post to this group, send email to active...@googlegroups.com.
To unsubscribe from this group, send email to active-fedor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/active-fedora?hl=en.

Reply all
Reply to author
Forward
0 new messages