Class: ODDB::Swissreg::TestWriter

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

Instance Method Summary collapse

Instance Method Details

#setupObject



13
14
15
16
17
# File 'ext/swissreg/test/test_writer.rb', line 13

def setup
	@writer = DetailWriter.new
	@formatter = ODDB::HtmlFormatter.new(@writer)
	@parser = ODDB::HtmlParser.new(@formatter)
end

#test_extract_dataObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'ext/swissreg/test/test_writer.rb', line 18

def test_extract_data
     path = File.expand_path('data/sildenafil_detail.html', 
                             File.dirname(__FILE__))
     html = File.read(path)
	@parser.feed(html)
	expected = {
		:base_patent				=> "EP00463756",
		:base_patent_date		=> Date.new(1991, 6, 7),
		#:base_patent_srid		=> "31042544",
		:certificate_number	=> "C00463756/01",
		:expiry_date				=> Date.new(2013, 6, 21),
		:iksnrs							=> ["54642"],
		:issue_date					=> Date.new(1999, 7, 30),
		:protection_date		=> Date.new(2011, 6, 7),
		:publication_date		=> Date.new(1998, 8, 31),
		:registration_date	=> Date.new(1998, 8, 11),
	}
	assert_equal(expected, @writer.extract_data)
end

#test_extract_data__bagObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'ext/swissreg/test/test_writer.rb', line 37

def test_extract_data__bag
     path = File.expand_path('data/pertactin_detail.html', 
                             File.dirname(__FILE__))
     html = File.read(path)
	@parser.feed(html)
	expected = {
		:base_patent				=> "EP00471726",
		:base_patent_date		=> Date.new(1990, 4, 26),
		#:base_patent_srid		=> "2000471726",
		:certificate_number	=> "C00471726/02",
		:expiry_date				=> Date.new(2012, 2, 25),
		:iksnrs							=> ["00595"],
		:issue_date					=> Date.new(1999, 3, 31),
		:protection_date		=> Date.new(2010, 4, 26),
		:publication_date		=> Date.new(1997, 9, 15),
		:registration_date	=> Date.new(1997, 8, 18),
	}
	assert_equal(expected, @writer.extract_data)
end

#test_extract_data__frObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'ext/swissreg/test/test_writer.rb', line 56

def test_extract_data__fr
     path = File.expand_path('data/ondansetron_detail.html', 
                             File.dirname(__FILE__))
     html = File.read(path)
	@parser.feed(html)
	expected = {
		:base_patent				=> "CH664152",
		:base_patent_date		=> Date.new(1985, 1, 25),
		:certificate_number	=> "C664152/01",
		:deletion_date			=> Date.new(2006, 8, 13),
		:expiry_date				=> Date.new(2006, 8, 13),
		:iksnrs							=> ["50709"],
		:issue_date					=> Date.new(1996, 3, 29),
		:protection_date		=> Date.new(2005, 1, 25),
		:publication_date		=> Date.new(1995, 10, 13),
		:registration_date	=> Date.new(1995, 9, 8),
	}
	assert_equal(expected, @writer.extract_data)
end

#test_extract_data__multiple_iksnrsObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'ext/swissreg/test/test_writer.rb', line 75

def test_extract_data__multiple_iksnrs
     path = File.expand_path('data/venlafaxin_detail.html', 
                             File.dirname(__FILE__))
     html = File.read(path)
	@parser.feed(html)
	expected = {
		:base_patent				=> "EP00112669",
		:base_patent_date		=> Date.new(1983, 12, 7),
		:certificate_number	=> "C00112669/01",
		:expiry_date				=> Date.new(2008, 12, 6),
		:iksnrs							=> ["52762", "52943"],
		:issue_date					=> Date.new(1996, 4, 30),
		:protection_date		=> Date.new(2003, 12, 7),
		:publication_date		=> Date.new(1996, 2, 29),
		:registration_date	=> Date.new(1995, 10, 17),
	}
	assert_equal(expected, @writer.extract_data)
end

#test_extract_data__swissmedicObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'ext/swissreg/test/test_writer.rb', line 93

def test_extract_data__swissmedic
     path = File.expand_path('data/pemetrexed_detail.html', 
                             File.dirname(__FILE__))
     html = File.read(path)
	@parser.feed(html)
	expected = {
		:base_patent				=> "EP00432677",
		:base_patent_date		=> Date.new(1990, 12, 10),
		:certificate_number	=> "C00432677/01",
		:expiry_date				=> Date.new(2015, 12, 9),
		:iksnrs							=> ["57039"],
		:issue_date					=> Date.new(2006, 12, 29),
		:protection_date		=> Date.new(2010, 12, 10),
		:publication_date		=> Date.new(2005, 4, 15),
		:registration_date	=> Date.new(2005, 3, 16),
	}
	assert_equal(expected, @writer.extract_data)
end