Esempio n. 1
0
class Reader:
    def __init__(self):
        conf = SparkConf().setAppName("appTest").setMaster("local[*]")
        self._sc = SparkContext(conf=conf)
        self._counter = Counters()

    def stop(self):
        self._sc.stop()

    def read(self, filePlace):
        movies = self._sc.textFile(filePlace)
        return self._counter.year_with_more_movies(movies)
class TestCounters(unittest.TestCase):
    def setUp(self):
        conf = SparkConf().setAppName("appTest").setMaster("local[*]")
        self.sc = SparkContext(conf=conf)
        self.counter = Counters()

    def tearDown(self):
        self.sc.stop()

    def test_when_exist_one_movie_in_rdd(self):
        movieList = ["1::Toy Story (1995)::Animation|Children's|Comedy"]
        movies = self.sc.parallelize(movieList)
        self.assertEqual(self.counter.year_with_more_movies(movies), '(1995)')

    def test_when_exist_three_movies_in_rdd(self):
        movieList = [
            "1993::Toy Story (1995)::Animation|Children's|Comedy",
            "1993::Toy Story (1996)::Animation|Children's|Comedy",
            "1993::Toy Story (1996)::Animation|Children's|Comedy"
        ]
        movies = self.sc.parallelize(movieList)
        self.assertEqual(self.counter.year_with_more_movies(movies), '(1996)')
Esempio n. 3
0
class Reader :

	def __init__(self):
	   conf = SparkConf().setAppName("appTest").setMaster("local[*]")
	   self._sc = SparkContext(conf=conf)
	   self._counter = Counters()


	def stop(self):
	   self._sc.stop()

	def read(self,filePlace):
	   movies = self._sc.textFile(filePlace)
	   return self._counter.year_with_more_movies(movies)   
 def setUp(self):
     conf = SparkConf().setAppName("appTest").setMaster("local[*]")
     self.sc = SparkContext(conf=conf)
     self.counter = Counters()
Esempio n. 5
0
 def __init__(self):
     conf = SparkConf().setAppName("appTest").setMaster("local[*]")
     self._sc = SparkContext(conf=conf)
     self._counter = Counters()
Esempio n. 6
0
	def __init__(self):
	   conf = SparkConf().setAppName("appTest").setMaster("local[*]")
	   self._sc = SparkContext(conf=conf)
	   self._counter = Counters()