File: test_helper_run.py

package info (click to toggle)
pyexiftool 0.5.6-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 356 kB
  • sloc: python: 1,406; makefile: 5
file content (66 lines) | stat: -rw-r--r-- 2,046 bytes parent folder | download | duplicates (2)
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
# -*- coding: utf-8 -*-
"""
Test :: ExifToolHelper - Helper's start/run wrappers tests
"""

# standard
import unittest

# test helpers
from tests.common_util import TEST_IMAGE_JPG

# custom
import exiftool
from exiftool.exceptions import ExifToolNotRunning




class TestHelperRunWrappers(unittest.TestCase):

	# ---------------------------------------------------------------------------------------------------------
	def setUp(self):
		self.et = exiftool.ExifToolHelper(common_args=["-G", "-n", "-overwrite_original"])

	def tearDown(self):
		self.et.terminate()


	# ---------------------------------------------------------------------------------------------------------
	def test_run(self):
		# no warnings when terminating when not running
		self.assertFalse(self.et.running)
		self.et.run()
		self.assertTrue(self.et.running)
		self.et.run()


	# ---------------------------------------------------------------------------------------------------------
	def test_terminate(self):
		# no warnings when terminating when not running
		self.assertFalse(self.et.running)
		self.et.terminate()


	# ---------------------------------------------------------------------------------------------------------
	def test_auto_start(self):

		# test that a RuntimeError gets thrown if auto_start is false
		self.et = exiftool.ExifToolHelper(auto_start=False)
		self.assertFalse(self.et.auto_start)
		with self.assertRaises(ExifToolNotRunning):
			self.et.get_metadata(TEST_IMAGE_JPG)

		# test that no errors returned if auto_start=True
		self.et = exiftool.ExifToolHelper(auto_start=True)
		self.assertTrue(self.et.auto_start)
		metadata = self.et.get_metadata(TEST_IMAGE_JPG)
		self.assertEqual(type(metadata), list)


	# ---------------------------------------------------------------------------------------------------------


# ---------------------------------------------------------------------------------------------------------
if __name__ == '__main__':
	unittest.main()