Sha256: c54a25e474487f110bb543661bf2dcb76fff71e8a0454c80ad74b73e763293f1

Contents?: true

Size: 1.58 KB

Versions: 18

Compression:

Stored size: 1.58 KB

Contents

# -*- coding: utf-8 -*-
require 'helper'

class TestVortexClient < Test::Unit::TestCase

  def setup
    if(not(@vortex))
      user = ENV['DAVUSER']
      pass = ENV['DAVPASS']
      @vortex = Vortex::Connection.new("https://vortex-dav.uio.no/",user, pass)
    end
  end

  should "open connection" do
    user = ENV['DAVUSER']
    pass = ENV['DAVPASS']
    vortex = Vortex::Connection.new("https://vortex-dav.uio.no/",user, pass)
    assert vortex
    vortex.cd('/brukere/thomasfl/')
  end

  should "read content from webdav server" do
    content = @vortex.get('https://vortex-dav.uio.no/brukere/thomasfl/test/test_1.html')
    assert content.match('html.*body')
  end

  should "detect that a resource (file) exists or not" do
    assert @vortex.exists?('https://vortex-dav.uio.no/brukere/thomasfl/test/test_1.html')
    assert @vortex.exists?('https://vortex-dav.uio.no/brukere/thomasfl/test/test_1.html_not_exists') == false
  end

  should "turn normal sentences into readable valid filenames" do
    require 'vortex_client/string_utils'
    assert_equal  "a-small-test-aeoa", Vortex::StringUtils.create_filename("a small test æøå?")
  end

  should "publish articles" do
    url = 'https://vortex-dav.uio.no/brukere/thomasfl/nyheter/sample-title-1.html'
    if(@vortex.exists?(url))
      @vortex.delete(url)
    end

    @vortex.cd('/brukere/thomasfl/nyheter/')
    article = Vortex::HtmlArticle.new(:title => "Sample Title 1", :introduction => "Introduction",
                                      :body => "<p>Hello world</p>")
    @vortex.publish(article)
    assert @vortex.exists?(url)
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
vortex_client-0.7.3 test/test_vortex_client.rb
vortex_client-0.7.2 test/test_vortex_client.rb
vortex_client-0.7.0 test/test_vortex_client.rb
vortex_client-0.6.0 test/test_vortex_client.rb
vortex_client-0.5.9 test/test_vortex_client.rb
vortex_client-0.5.8 test/test_vortex_client.rb
vortex_client-0.5.6 test/test_vortex_client.rb
vortex_client-0.5.5 test/test_vortex_client.rb
vortex_client-0.5.4 test/test_vortex_client.rb
vortex_client-0.5.3 test/test_vortex_client.rb
vortex_client-0.5.2 test/test_vortex_client.rb
vortex_client-0.5.1 test/test_vortex_client.rb
vortex_client-0.5.0 test/test_vortex_client.rb
vortex_client-0.4.0 test/test_vortex_client.rb
vortex_client-0.3.1 test/test_vortex_client.rb
vortex_client-0.3.0 test/test_vortex_client.rb
vortex_client-0.2.0 test/test_vortex_client.rb
vortex_client-0.1.0 test/test_vortex_client.rb