Class: TestDoctorWriter

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
ext/docdata/test/parser_test.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



12
13
14
15
16
# File 'ext/docdata/test/parser_test.rb', line 12

def setup
	@writer = ODDB::DocData::DoctorWriter.new
	formatter = ODDB::DocData::DoctorFormatter.new(@writer)
	@parser = ODDB::HtmlParser.new(formatter)
end

#test_parse__multiple_addressesObject



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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'ext/docdata/test/parser_test.rb', line 17

def test_parse__multiple_addresses
	html_path = File.expand_path('data/html/14488.html',
		File.dirname(__FILE__))
	html = File.read(html_path)
	@parser.feed(html)
	@writer.extract_data
	expected = {
		:addresses	=> [
			{
				:plz		=>  '6500',
				:city   =>  'Bellinzona',
				:fax    =>  '',
				:fon		=>	'091 820 91 11',
				:lines	=>	[
					'Egregio Prof.',
					'Claudio Marone',
					'Studio medico',
					'Ospedale San Giovanni',
					'6500 Bellinzona',
					'',
				],
				:type	=> :praxis,
			},
			{
				:plz		=>	'6500',
				:city		=>	'Bellinzona',
				:fon		=>	'091 811 91 11',
				:fax		=>	'091 811 91 60',
				:lines	=>	[
					'Ospedale San Giovanni',
					'Reparto nefrologia',
					'Soleggio',
					'6500 Bellinzona',
					'',
				],
				:type	=> :work,
			},
			{
				:plz		=>  '6597',
				:city   =>  'Agarone',
				:fon		=>	'092 64 11 41',
				:fax    =>  '',
				:lines	=>	[
					'Clinica Sassariente',
					'Medoscio',
					'6597 Agarone',
					'',
				],
				:type	=> :work,
			},
			{
				:plz		=>  '6500',
				:city   =>  'Bellinzona',
				:fon		=>	'091 811 91 09',
				:fax    =>  '091 811 87 99',
				:lines  => [
					"Ospedale San Giovanni",
					"Reparto medicina interna",
				  "Soleggio",
					"6500 Bellinzona",
					"",
				],
				:type	=> :work,
			},
			{
				:plz		=>  '6500',
				:city   =>  'Bellinzona',
				:fon		=>	'091 811 91 11',
				:fax    =>  '',
				:lines  => [
					"Ospedale San Giovanni",
					"Centro Cure Intense",
				  "Soleggio",
					"6500 Bellinzona",
					"",
				],
				:type	=> :work,
			},
		],
		:specialities	=>	['Innere Medizin', 'Nephrologie'],
		:language		=>	'italienisch',
		:praxis			=>	"Ja",
		:exam				=>	"1970",
		:salutation	=>  "Herrn",
		:title			=>	"Prof. Dr. med.",
		:firstname	=>	"Claudio",
		:name	=>	"Marone",
		:email	=>	"[email protected]",
	}
	result = @writer.collected_values
	expected.each { |key, value|
		assert_equal(value, result[key], "while checking key: #{key}")
	}
	assert_equal(expected, result)
end