view · edit · sidebar · attach · print · history

20110804-testcases-url-format-oddb_org

<< | Index | >>


  1. Testcases oddb.org
  2. Debug registration and sequence error
  3. Develop migel search function suspend
  4. Replace all the link URL format, registration, sequence, and package

Goal/Estimate/Evaluation
  • Test oddb.org / 100% / 100%
  • Change URL format oddb.org / 100% / 80%
Milestones
Summary
Commits

Testcases oddb.org

Current status

  1) Error:
test_update(ODDB::SwissmedicPluginTest):
NoMethodError: undefined method `each_registration' for <FlexMock:app>:FlexMock
    /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:105:in `method_missing'
    /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:191:in `flexmock_wrap'
    /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:98:in `method_missing'
    /home/masa/ywesee/oddb.org/src/plugin/swissmedic.rb:65:in `set_all_export_flag_false'
    /home/masa/ywesee/oddb.org/src/plugin/swissmedic.rb:44:in `update'
    /home/masa/ywesee/oddb.org/test/test_plugin/swissmedic.rb:1462:in `test_update'


4098 tests, 6568 assertions, 0 failures, 1 errors

Updated

4101 tests, 6572 assertions, 0 failures, 0 errors

Commit

Debug registration and sequence error

Problem

  • If a search result has PI link, the registration and sequence number link does not work
  • This must be related to the update yesterday

Commit

Note

Commit

Note

  • 'model' in src/view/additional_information.rb#patinfo method becomes Package or Sequence instance
  • I added :seqnr property in Package class because I need to get a sequence number to create PI URL

Develop migel search function

Task

  • If I click a migel group number, then a product list of the same migel group should be shown

Replace all the link URL format, registration, sequence, and package

Task

Design (for example)

Experiment

      def resolve
        if(@session.request_path == @request_path)
          self
        elsif(iksnr = @session.user_input(:swissmedicnr)) \
          && (pointer = @session.app.registration(iksnr).pointer) \
          && pointer.is_a?(Persistence::Pointer) \
          && (model = pointer.resolve(@session.app))
          if(klass = resolve_state(pointer))
            klass.new(@session, model)
          else
            State::Admin::TransparentLogin.new(@session, model)
          end
        elsif((pointer = @session.user_input(:pointer)) \
          && pointer.is_a?(Persistence::Pointer) \
          && (model = pointer.resolve(@session.app)))
          if(klass = resolve_state(pointer))
            klass.new(@session, model)
          else
            State::Admin::TransparentLogin.new(@session, model)
          end
        end
      end

Run

  • bin/currencyd
  • bin/yusd
  • bin/oddbd

Access

Result

  • success (I can see the registration result)

Experiment

      def resolve
        if(@session.request_path == @request_path)
          self
        elsif(iksnr = @session.user_input(:reg)) \
          && (pointer = @session.app.registration(iksnr).pointer)           && pointer.is_a?(Persistence::Pointer)           && (model = pointer.resolve(@session.app))
          if(klass = resolve_state(pointer))
            klass.new(@session, model)
          else
            State::Admin::TransparentLogin.new(@session, model)
          end
        elsif((pointer = @session.user_input(:pointer)) \
          && pointer.is_a?(Persistence::Pointer) \
          && (model = pointer.resolve(@session.app)))
          if(klass = resolve_state(pointer))
            klass.new(@session, model)
          else
            State::Admin::TransparentLogin.new(@session, model)
          end
        end
      end
    alias :reg :iksnr

Access

Result

  • success

Experiment

  • src/state/global.rb
      alias :drug :resolve
  • src/util/validator.rb
    EVENTS = [
...
      :drug,
...

Access

Result

  • success

Experiment

      def resolve
        if(@session.request_path == @request_path)
          self
        else
          iksnr = @session.user_input(:reg)
          seqnr = @session.user_input(:seq)     
          ikscd = @session.user_input(:pack)
          pointer = if iksnr && seqnr && ikscd
                      @session.app.registration(iksnr).sequence(seqnr).package(ikscd).pointer
                    elsif iksnr && seqnr
                      @session.app.registration(iksnr).sequence(seqnr).pointer
                    elsif iksnr
                      @session.app.registration(iksnr).pointer
                    else
                      @session.user_input(:pointer)
                    end
          if pointer.is_a?(Persistence::Pointer) \
          && (model = pointer.resolve(@session.app))
            if(klass = resolve_state(pointer))
              klass.new(@session, model)
            else
              State::Admin::TransparentLogin.new(@session, model)
            end
          end
        end
      end
      alias :drug :resolve

Access

Result

  • success

Note

  • If I log in, the event becomes 'resolve', but if I do not log in, the event becomes 'show'
  • In the case of not-logged-in, the URLs do not work for the moment. (later)

Next

  • Update the part to generate the URL

Experiment

    class PointerLink < View::PointerValue
      def init
        super
        arguments = {'pointer'  => @model.pointer.to_s}
        iksnr = if match = @model.pointer.to_s.match(/registration,(\d+)/)
                  match[1]
                end
        seqnr = if match = @model.pointer.to_s.match(/sequence,(\d+)/)
                  match[1]
                end
        ikscd = if match = @model.pointer.to_s.match(/package,(\d+)/)
                  match[1]
                end
        smart_link = if iksnr && seqnr && ikscd
                       {:reg => iksnr, :seq => seqnr, :pack => ikscd}
                     elsif iksnr && seqnr
                       {:reg => iksnr, :seq => seqnr}
                     elsif iksnr
                       {:reg => iksnr}
                     end
        if smart_link
          @attributes['href'] = @lookandfeel._event_url(:drug, smart_link)
        else
          @attributes['href'] = @lookandfeel._event_url(:resolve, arguments)
        end
        #@attributes['href'] = @lookandfeel._event_url(:resolve, arguments)
      end

Result

  • success (only in the case of logged-in)

Refactor

    class PointerLink < View::PointerValue
      def init
        super
        arguments = {'pointer'  => @model.pointer.to_s}
        # @model.pointer.to_s might be like this:
        # :!registration,31706!sequence,01!package,017.
        # in such case, URL link will be smarter than the URL by using pointer
        # z.B.) http://ch.oddb.org/de/gcc/drug/reg/31706/seq/01/pack/017
        # The old format is also available.
        list = @model.pointer.to_s.gsub(/\./,'').split(/!/).delete_if{|v| v == ":"}.map{|i| i.split(",")}.flatten
        nrs  = Hash[*list]
        iksnr = nrs['registration']
        seqnr = nrs['sequence']
        ikscd = nrs['package']
        smart_link = if iksnr && seqnr && ikscd
                       {:reg => iksnr, :seq => seqnr, :pack => ikscd}
                     elsif iksnr && seqnr
                       {:reg => iksnr, :seq => seqnr}
                     elsif iksnr
                       {:reg => iksnr}
                     end
        if smart_link
          @attributes['href'] = @lookandfeel._event_url(:drug, smart_link)
        else
          @attributes['href'] = @lookandfeel._event_url(:resolve, arguments)
        end
      end

Result

  • also success

Next

  • In the case of unlogged-in

Goal

Experiment

      def show
        if(@session.request_path == @request_path)
          self
        else
          iksnr = @session.user_input(:reg)
          seqnr = @session.user_input(:seq) 
          ikscd = @session.user_input(:pack)
          pointer = if iksnr && seqnr && ikscd
                      @session.app.registration(iksnr).sequence(seqnr).package(ikscd).pointer
                    elsif iksnr && seqnr
                      @session.app.registration(iksnr).sequence(seqnr).pointer
                    elsif iksnr
                      @session.app.registration(iksnr).pointer
                    else
                      @session.user_input(:pointer)
                    end
          if pointer.is_a?(Persistence::Pointer) \
          && (model = pointer.resolve(@session.app)) \
          && klass = resolve_state(pointer, :readonly)
            klass.new(@session, model)
          end
        end
      end

Access

Result

  • success

Next

  • Update the generating part

Experiment

      def pointer_descr(model, session=@session)
        link = PointerLink.new(:pointer_descr, model, @session, self)
        unless(@session.allowed?('edit', model))
          # model.pointer.to_s might be like this:
          # :!registration,31706!sequence,01!package,017.
          # in such case, URL link will be smarter than the URL by using pointer.
          # z.B.) http://ch.oddb.org/de/gcc/show/reg/31706/seq/01/pack/017
          # The old format is also available.
          list = model.pointer.to_s.gsub(/\./,'').split(/!/).delete_if{|v| v == ":"}.map{|i| i.split(",")}.flatten
          nrs  = Hash[*list]
          iksnr = nrs['registration']
          seqnr = nrs['sequence']
          ikscd = nrs['package']
          smart_link = if iksnr && seqnr && ikscd
                         {:reg => iksnr, :seq => seqnr, :pack => ikscd}
                       elsif iksnr && seqnr
                         {:reg => iksnr, :seq => seqnr}
                       elsif iksnr
                         {:reg => iksnr}
                       end
          if smart_link
            link.href = @lookandfeel._event_url(:show, smart_link)
          else
            link.href = @lookandfeel._event_url(:show, {:pointer => model.pointer})
          end
        end
        link
      end
    end

Result

  • success

Note

  • But the link from the composition is still in old format
view · edit · sidebar · attach · print · history
Page last modified on August 05, 2011, at 07:37 AM