File: test_class_methods.rb

package info (click to toggle)
ruby-mini-exiftool 2.9.0-2
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 688 kB
  • sloc: ruby: 2,616; makefile: 2
file content (80 lines) | stat: -rw-r--r-- 2,088 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# -- encoding: utf-8 --
require 'helpers_for_test'

class TestClassMethods < TestCase

  def test_new
    assert_nothing_raised do
      @mini_exiftool = MiniExiftool.new
    end
    assert_equal nil, @mini_exiftool.filename
    assert_nothing_raised do
      MiniExiftool.new nil
    end
    assert_raises MiniExiftool::Error do
      MiniExiftool.new false 
    end
    assert_raises MiniExiftool::Error do
      MiniExiftool.new ''
    end
    assert_raises MiniExiftool::Error do
      MiniExiftool.new 'not_existing_file'
    end
    assert_raises MiniExiftool::Error do
      MiniExiftool.new '.' # directory
    end
    begin
      MiniExiftool.new 'not_existing_file'
    rescue MiniExiftool::Error => e
      assert_match /File 'not_existing_file' does not exist/, e.message
    end
  end

  def test_command
    cmd = MiniExiftool.command
    assert_equal 'exiftool', cmd
    MiniExiftool.command = 'non_existend'
    assert_equal 'non_existend', MiniExiftool.command
    assert_raises MiniExiftool::Error do
      met = MiniExiftool.new(File.join(File.dirname(__FILE__), 
                                       'data/test.jpg'))
    end
    MiniExiftool.command = cmd
  end

  def test_opts
    opts = MiniExiftool.opts
    assert_kind_of Hash, opts
    begin
      org = MiniExiftool.opts[:composite]
      met1 = MiniExiftool.new
      MiniExiftool.opts[:composite] = !org
      met2 = MiniExiftool.new
      MiniExiftool.opts[:composite] = org
      met3 = MiniExiftool.new
      assert_equal org, met1.composite
      assert_equal !org, met2.composite
      assert_equal org, met1.composite
    ensure
      MiniExiftool.opts[:composite] = org
    end
  end

  def test_all_tags
    all_tags = MiniExiftool.all_tags
    assert all_tags.include?('ISO')
    assert all_tags.include?('ExifToolVersion')
  end

  def test_writable_tags
    w_tags = MiniExiftool.writable_tags
    assert w_tags.include?('ISO')
    assert ! w_tags.include?('ExifToolVersion')
  end

  def test_exiftool_version
    v = MiniExiftool.exiftool_version
    assert_match /\A\d+\.\d+\z/, v
  end

end