movieDB 0.3.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,97 +0,0 @@
1
- require 'test/unit'
2
- require "imdb"
3
- require "redis"
4
- require 'fileutils'
5
- require 'movieDB'
6
- begin
7
- require 'movieDB'
8
- rescue
9
- end
10
-
11
- class TestMovieDB < Test::Unit::TestCase
12
- # This unit test writes an excel file to the reports directory
13
- # in your gem folder. So, this method removes and empty the reports folder of
14
- # all or any pre-existing test files.
15
- def remove_test_files_from_reports_directory
16
- testxlsfiles = File.join("**", "reports", "*.xls")
17
- FileUtils.rm Dir.glob(testxlsfiles)
18
- end
19
-
20
- def test_movie_new
21
- m = MovieDB::Movie.new
22
- assert_instance_of MovieDB::Movie, m
23
- assert_equal "Method Missing 2: Rails Roars!", m.title
24
- assert_equal ["David Black", "Paola Perotta", "Obie Fernandez", "David Chelimsky"], m.cast_members
25
- assert_equal ["David Black => Developer", "Paola Perotta => Police Officer", "Obie Fernandez =>Hunter", "David Chelimsky =>Hostage"], m.cast_members_characters
26
- assert_equal ["nm3901234", "nm4901244", "nm5901235", "nm3601266"], m.cast_member_ids
27
- assert_equal "http://imdb.com/video/screenplay/vi581042457/", m.trailer_url
28
- assert_equal "Yukihiro 'Matz' Matsumoto", m.director
29
- assert_equal 'David Heinemeier Hansson', m.writers
30
- assert_equal ["Manhattan, New York, USA"], m.filming_locations
31
- assert_equal "Open Source Community Film Corporation", m.company
32
- assert_equal ["Bromantic", "Syfy"], m.genres
33
- assert_equal ["English", "German", "Italian"], m.languages
34
- assert_equal ["USA", "Germany", "Italy"], m.countries
35
- assert_equal 146, m.length
36
- assert_equal ["David Black, a ruby developer, tries to write his flagship ruby book 'The Well-Grounded Rubyist vol. 186' only to find out that Ruby 9.0.2 and Rails 16.0.3 release dates have been postponed"], m.plot
37
- assert_equal "http://ia.media-imdb.com/images/M/MV5BMTY@@.jpg", m.poster
38
- assert_equal 9.9, m.rating
39
- assert_equal 110636, m.votes
40
- assert_equal "Rated R for dynamic OOD language usage and private methods access (certificate 33087)", m.mpaa_rating
41
- assert_equal 'Only One MVC Will Rule Them All.', m.tagline
42
- assert_equal 2013, m.year
43
- assert_equal "11 October 2013 (USA)", m.release_date
44
- assert_equal 456790, m.revenue
45
- end
46
-
47
- def test_find_imdb_id
48
- assert_raise(ArgumentError) { MovieDB::Movie.find_imdb_id() }
49
- assert_equal("imdb_JurassicWorld_.xls", MovieDB::Movie.find_imdb_id('0369610'))
50
-
51
- remove_test_files_from_reports_directory
52
- end
53
-
54
- def test_get_imdb_movie_data
55
- imdb_ids = ['0369610', '2395427']
56
- wrong_ids = ['abcd', 'cdef']
57
-
58
- assert_equal(2, MovieDB::Movie.get_imdb_movie_data(imdb_ids).length)
59
- assert_nil(nil, MovieDB::Movie.get_imdb_movie_data(wrong_ids))
60
-
61
- m = MovieDB::Movie.get_imdb_movie_data(imdb_ids)
62
- assert_equal("Jurassic World", m[0].title)
63
- assert_equal("Avengers: Age of Ultron", m[1].title)
64
- end
65
-
66
- def test_get_tmdb_movie_data
67
- imdb_ids = ['0078748', '0120338']
68
- assert_equal(2, MovieDB::Movie.get_tmdb_movie_data(imdb_ids).length)
69
-
70
- m = MovieDB::Movie.get_tmdb_movie_data(imdb_ids)
71
- assert_equal(104931801, m[0]['revenue'])
72
- assert_equal(1845034188, m[1]['revenue'])
73
- end
74
-
75
- def test_store_movie_data_to_redis
76
- imdb_ids = ["0369610"]
77
-
78
- MovieDB::Movie.get_imdb_movie_data(imdb_ids)
79
- MovieDB::Movie.get_tmdb_movie_data(imdb_ids)
80
-
81
- m = MovieDB::Movie.cache_movie_data_to_redis(imdb_ids)
82
- assert_equal("Jurassic World", (m.hget "movie:0369610", "title"))
83
- end
84
-
85
- def test_write_imdb_data_to_xls
86
- imdb_ids = ['0369610', '2395427']
87
-
88
- MovieDB::Movie.get_imdb_movie_data(imdb_ids)
89
- MovieDB::Movie.get_tmdb_movie_data(imdb_ids)
90
- m = MovieDB::Movie.cache_movie_data_to_redis(imdb_ids)
91
-
92
- assert_equal("imdb_JurassicWorld_Avengers:AgeofUltron_.xls", MovieDB::Movie.export_movie_data(m, imdb_ids))
93
-
94
- remove_test_files_from_reports_directory
95
- end
96
- end
97
-