• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / tigerdata-app / 5205f704-d89d-4c43-8cfa-9e6783edc33a

29 Feb 2024 07:04PM UTC coverage: 60.206% (-29.9%) from 90.092%
5205f704-d89d-4c43-8cfa-9e6783edc33a

push

circleci

jrgriffiniii
Ensuring that the storage usage and storage capacity is retrieved for
Mediaflux Projects and rendered on the "contents" Project View

11 of 34 new or added lines in 4 files covered. (32.35%)

451 existing lines in 34 files now uncovered.

935 of 1553 relevant lines covered (60.21%)

9.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

30.23
/app/models/mediaflux/http/iterator_request.rb
1
# frozen_string_literal: true
2
module Mediaflux
1✔
3
  module Http
1✔
4
    class IteratorRequest < Request
1✔
5
      # Constructor
6
      # @param session_token [String] the API token for the authenticated session
7
      # @iterator [Int] The iterator returned by Mediaflux (via QueryRequest)
8
      def initialize(session_token:, iterator:, action: "get-values", size: nil)
1✔
9
        super(session_token: session_token)
3✔
UNCOV
10
        @iterator = iterator
×
UNCOV
11
        @size = size
×
UNCOV
12
        @action = action
×
13
      end
14

15
      # Specifies the Mediaflux service to use when running a query
16
      # @return [String]
17
      def self.service
1✔
UNCOV
18
        "asset.query.iterate"
×
19
      end
20

21
      # Returns hash with the files fetched in this iteration as well as a flag on whether we are
22
      # done iterating (complete=true) or if we need to keep iterating
23
      def result
1✔
UNCOV
24
        xml = response_xml
×
25
        {
UNCOV
26
          files: parse_files(xml),
×
27
          complete: xml.xpath("/response/reply/result/iterated/@complete").text == "true",
28
          count: xml.xpath("/response/reply/result/iterated").text.to_i
29
        }
30
      end
31

32
      private
1✔
33

34
        def build_http_request_body(name:)
1✔
UNCOV
35
          super do |xml|
×
UNCOV
36
            xml.args do
×
UNCOV
37
              xml.id @iterator
×
UNCOV
38
              xml.size @size if @size.present?
×
39
            end
40
          end
41
        end
42

43
        def parse_files(xml)
1✔
UNCOV
44
          case @action
×
45
          when "get-name"
UNCOV
46
            parse_get_name(xml)
×
47
          when "get-meta"
UNCOV
48
            parse_get_meta(xml)
×
49
          when "get-values"
UNCOV
50
            parse_get_values(xml)
×
51
          else
52
            raise "Cannot parse result. Unknow action: #{@action}."
×
53
          end
54
        end
55

56
        # Extracts file information when the request was made with the "action: get-name" parameter
57
        def parse_get_name(xml)
1✔
UNCOV
58
          files = []
×
UNCOV
59
          xml.xpath("/response/reply/result/name").each do |node|
×
UNCOV
60
            file = Mediaflux::Asset.new(
×
61
              id: node.xpath("./@id").text,
62
              name: node.text,
63
              collection: node.xpath("./@collection").text == "true"
64
            )
UNCOV
65
            files << file
×
66
          end
UNCOV
67
          files
×
68
        end
69

70
        # Extracts file information when the request was made with the "action: get-meta" parameter
71
        def parse_get_meta(xml)
1✔
UNCOV
72
          files = []
×
UNCOV
73
          xml.xpath("/response/reply/result/asset").each do |node|
×
UNCOV
74
            file = Mediaflux::Asset.new(
×
75
              id: node.xpath("./@id").text,
76
              name: node.xpath("./name").text,
77
              path: node.xpath("./path").text,
78
              collection: node.xpath("./@collection").text == "true",
79
              size: node.xpath("./content/@total-size").text.to_i,
80
              last_modified_mf: node.xpath("mtime").text
81
            )
UNCOV
82
            files << file
×
83
          end
UNCOV
84
          files
×
85
        end
86

87
        # Extracts file information when the request was made with the "action: get-values" parameter
88
        # Notice that this code is coupled with the fields defined in QueryRequest.
89
        def parse_get_values(xml)
1✔
UNCOV
90
          files = []
×
UNCOV
91
          xml.xpath("/response/reply/result/asset").each do |node|
×
UNCOV
92
            file = Mediaflux::Asset.new(
×
93
              id: node.xpath("./@id").text,
94
              name: node.xpath("./name").text,
95
              path: node.xpath("./path").text,
96
              collection: node.xpath("./collection").text == "true",
97
              size: node.xpath("./total-size").text.to_i,
98
              last_modified_mf: node.xpath("mtime").text
99
            )
UNCOV
100
            files << file
×
101
          end
UNCOV
102
          files
×
103
        end
104
    end
105
  end
106
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc