Exemplo n.º 1
0
    def test_command_line_args(self):
        """
        Check that Go handles command line args switch correctly.
        @param self. Object reference.
        """
        inputer = InputPyEmptyDocument(1)
        transformer = MapPyDoNothing()
        merger = ReducePyDoNothing()
        outputer = OutputPyJSON(open(self.tmp_file, 'w'))
        arg_temp = copy.deepcopy(sys.argv)
        sys.argv = [arg_temp[0]]

        Go(inputer, transformer, merger, outputer, config_file=self.config, \
                                                      command_line_args = True)

        outputer = OutputPyJSON(open(self.tmp_file, 'w'))
        arg_temp = copy.deepcopy(sys.argv)
        sys.argv = [arg_temp[0], "bob"]
        with self.assertRaises(SystemExit):
            Go(inputer, transformer, merger, outputer, \
                              config_file=self.config, command_line_args = True)

        sys.argv = [arg_temp[0], "-verbose_level", "1"]
        Go(inputer, transformer, merger, outputer, \
                             config_file=self.config, command_line_args = True)

        sys.argv = arg_temp
Exemplo n.º 2
0
 def test_dataflows(self):
     """  
     Make sure get_possible_dataflows() doesn't return nonsense
     @param self. Object reference.
     """
     keys = Go.get_possible_dataflows().keys()
     self.assertTrue('pipeline_single_thread' in keys)
Exemplo n.º 3
0
 def test_dataflows(self):
     """  
     Make sure get_possible_dataflows() doesn't return nonsense
     @param self. Object reference.
     """
     keys = Go.get_possible_dataflows().keys()
     self.assertTrue('pipeline_single_thread' in keys)
Exemplo n.º 4
0
    def test_input_birth(self):
        """
        Check that Go raises error with bad input.
        @param self. Object reference.
        """
        inputer = FakeWorker()
        transformer = MapPyDoNothing()
        merger = ReducePyDoNothing()
        outputer = OutputPyJSON(open(self.tmp_file, 'w'))

        with self.assertRaises(AssertionError):
            Go(inputer, transformer, merger, outputer, \
                              config_file=self.config, command_line_args=False)
Exemplo n.º 5
0
    def test_output_birth(self):
        """
        Check that Go raises error with bad outputter.
        @param self. Object reference.
        """
        inputer = InputPyEmptyDocument(1)
        transformer = MapPyDoNothing()
        merger = ReducePyDoNothing()
        outputer = FakeWorker()

        with self.assertRaises(AssertionError):
            Go(inputer, transformer, merger, outputer, \
                               config_file=self.config, command_line_args=False)
Exemplo n.º 6
0
 def test_dataflow_multi_process(self):
     """
     Check that Go executes okay with multi_process dataflow.
     @param self. Object reference.
     """
     inputer = InputPyEmptyDocument(1)
     transformer = MapPyDoNothing()
     merger = ReducePyDoNothing()
     outputer = OutputPyJSON(open(self.tmp_file, 'w'))
     for map_red_type in ['multi_process']:
         config = StringIO(u"""type_of_dataflow="%s" """ % map_red_type)
         with self.assertRaises(Exception):
             Go(inputer, transformer, merger, outputer, config, \
                    command_line_args = False)
Exemplo n.º 7
0
    def test_dataflow_single_thread(self):
        """
        Check that Go executes okay with pipeline_single_thread dataflow.
        @param self. Object reference.
        """
        inputer = InputPyEmptyDocument(1)
        transformer = MapPyDoNothing()
        merger = ReducePyDoNothing()
        outputer = OutputPyJSON(open(self.tmp_file, 'w'))
        for map_red_type in ['pipeline_single_thread']:
            config = StringIO(u"""type_of_dataflow="%s" """ % map_red_type)

            Go(inputer, transformer, merger, outputer, config, \
                   command_line_args = False)
Exemplo n.º 8
0
    def test_dataflow_not_implemented(self):
        """
        Check that Go notifies user of unimplemented dataflow.
        @param self. Object reference.
        """
        inputer = InputPyEmptyDocument(1)
        transformer = MapPyDoNothing()
        merger = ReducePyDoNothing()
        outputer = OutputPyJSON(open(self.tmp_file, 'w'))
        for map_red_type in ['many_local_threads']:
            config = StringIO(u"""type_of_dataflow="%s" """ % map_red_type)

            with self.assertRaises(NotImplementedError):
                Go(inputer, transformer, merger, outputer, config, \
                       command_line_args = False)
Exemplo n.º 9
0
    def test_type_of_dataflow_bad(self):
        """
        Check that Go raises error with bad dataflow type.
        @param self. Object reference.
        """
        inputer = InputPyEmptyDocument(1)
        transformer = MapPyDoNothing()
        merger = ReducePyDoNothing()
        outputer = OutputPyJSON(open(self.tmp_file, 'w'))

        config = StringIO(u"""type_of_dataflow="bad_type" """)

        with self.assertRaises(LookupError):
            Go(inputer, transformer, merger, outputer, config, \
               command_line_args = False)
Exemplo n.º 10
0
 def test_get_job_header(self):
     """
     Check that the job header is initialised okay
     """
     cards = {'maus_version': 'some_version', 'cow': 'moo'}
     header = Go.get_job_header(cards)
     my_datetime = header["start_of_job"]["date_time"]
     start_time_as_dt = datetime.datetime.strptime(my_datetime,
                                                   "%Y-%m-%d %H:%M:%S.%f")
     self.assertLess(start_time_as_dt, datetime.datetime.utcnow())
     self.assertGreater(len(header['bzr_configuration']), 0)
     self.assertGreater(len(header['bzr_revision']), 0)
     # clean bzr checkout has no output from bzr_status
     self.assertEqual(type(header['bzr_status']), type(''))
     self.assertEqual(header['maus_version'], 'some_version')
     self.assertEqual(header['json_configuration'], json.dumps(cards))
     self.assertEqual(header['maus_event_type'], 'JobHeader')
Exemplo n.º 11
0
 def test_get_job_header(self):
     """
     Check that the job header is initialised okay
     """
     cards = {'maus_version':'some_version', 'cow':'moo'}
     header = Go.get_job_header(cards)
     my_datetime = header["start_of_job"]["date_time"]
     start_time_as_dt = datetime.datetime.strptime(my_datetime,
                                                     "%Y-%m-%d %H:%M:%S.%f")
     self.assertLess(start_time_as_dt, datetime.datetime.utcnow())
     self.assertGreater(len(header['bzr_configuration']), 0)
     self.assertGreater(len(header['bzr_revision']), 0)
     # clean bzr checkout has no output from bzr_status
     self.assertEqual(type(header['bzr_status']), type(''))
     self.assertEqual(header['maus_version'], 'some_version')
     self.assertEqual(header['json_configuration'], json.dumps(cards))
     self.assertEqual(header['maus_event_type'], 'JobHeader')
Exemplo n.º 12
0
 def initialise_board(self):
     """Initialise the board"""
     s1 = Go("Go", 0)
     s2 = Property(
         "Crumlin",
         TitleDeedCard("Crumlin", True, 60, 30, [2, 10, 30, 90, 160, 250],
                       "A", "brown", 50, 50, "resources/crumlin.png"), 1,
         False, None)
     s3 = CardSquare("Community Chest", 2)
     s4 = Property(
         "Kimmage",
         TitleDeedCard("Kimmage", True, 60, 30, [4, 20, 60, 180, 320, 450],
                       "A", "brown", 50, 50, "resources/kimmage.png"), 3,
         False, None)
     s5 = Tax("Income Tax", 4, 200)
     s6 = Station(
         "Busaras Dublin", False, False, 200,
         TitleDeedCard("Busaras Dublin", True, 200, 100, [25, 50, 100, 200],
                       "B", None, None, None,
                       "resources/BusarasDublin.png"), 5)
     s7 = Property(
         "Rathgar Road",
         TitleDeedCard("Rathgar Road", True, 100, 50,
                       [6, 30, 90, 270, 400, 550], "C", "lightblue", 50, 50,
                       "resources/rathgar.png"), 6, False, None)
     s8 = CardSquare("Chance", 7)
     s9 = Property(
         "South Circular Road",
         TitleDeedCard("South Circular Road", True, 100, 50,
                       [6, 30, 90, 270, 400, 550], "C", "lightblue", 50, 50,
                       "resources/southcircular.png"), 8, False, None)
     s10 = Property(
         "Rathmines Road",
         TitleDeedCard("Rathmines Road", True, 120, 60,
                       [8, 40, 100, 300, 450, 600], "C", "lightblue", 50,
                       50, "resources/rathmines.png"), 9, False, None)
     s11 = Jail("Jail", 10)
     s12 = Property(
         "Dawson Street",
         TitleDeedCard("Dawson Street", True, 140, 70,
                       [10, 50, 150, 450, 625, 750], "D", "pink", 100, 100,
                       "resources/dawson.png"), 11, False, None)
     s13 = UtilitySquare(
         "Electric Company", 12,
         TitleDeedCard("Electric Company", True, 150, 75, [4, 10], "E",
                       None, None, None, "resources/Utility1.png"), 150)
     s14 = Property(
         "Kildare Street",
         TitleDeedCard("Kildare Street", True, 140, 70,
                       [10, 50, 150, 450, 625, 750], "D", "pink", 100, 100,
                       "resources/kildare.png"), 13, False, None)
     s15 = Property(
         "Nassau Street",
         TitleDeedCard("Nassau Street", True, 160, 80,
                       [12, 60, 180, 500, 700, 900], "D", "pink", 100, 100,
                       "resources/nassau.png"), 14, False, None)
     s16 = Station(
         "Dublin Airport", False, None, 200,
         TitleDeedCard("Dublin Airport", True, 200, 100, [25, 50, 100, 200],
                       "B", None, None, None,
                       "resources/DublinAirport.png"), 15)
     s17 = Property(
         "Pearse Street",
         TitleDeedCard("Pearse Street", True, 180, 90,
                       [14, 70, 200, 550, 750, 950], "F", "orange", 100,
                       100, "resources/pearse.png"), 16, False, None)
     s18 = CardSquare("Community Chest", 17)
     s19 = Property(
         "Dame Street",
         TitleDeedCard("Dame Street", True, 180, 90,
                       [14, 70, 200, 550, 750, 950], "F", "orange", 100,
                       100, "resources/dame.png"), 18, False, None)
     s20 = Property(
         "Westmoreland Street",
         TitleDeedCard("Westmoreland Street", True, 200, 100,
                       [16, 80, 220, 600, 800, 1000], "F", "orange", 100,
                       100, "resources/westmoreland.png"), 19, False, None)
     s21 = FreeParking("Free Parking", 20)
     s22 = Property(
         "Abbey Street",
         TitleDeedCard("Abbey Street", True, 220, 110,
                       [18, 90, 250, 700, 875, 1050], "G", "red", 150, 150,
                       "resources/abbey.png"), 21, False, None)
     s23 = CardSquare("Chance", 22)
     s24 = Property(
         "Capel Street",
         TitleDeedCard("Capel Street", True, 220, 110,
                       [18, 90, 250, 700, 875, 1050], "G", "red", 150, 150,
                       "resources/capel.png"), 23, False, None)
     s25 = Property(
         "Henry Street",
         TitleDeedCard("Henry Street", True, 240, 120,
                       [20, 100, 300, 750, 925, 1100], "G", "red", 150, 150,
                       "resources/henry.png"), 24, False, None)
     s26 = Station(
         "Heuston Station", False, False, 200,
         TitleDeedCard("Heuston Station", True, 200, 100,
                       [25, 50, 100, 200], "B", None, None, None,
                       "resources/HeustonStation.png"), 25)
     s27 = Property(
         "Talbot Street",
         TitleDeedCard("Talbot Street", True, 260, 130,
                       [22, 110, 330, 800, 975, 1150], "H", "yellow", 150,
                       150, "resources/talbot.png"), 26, False, None)
     s28 = Property(
         "North Earl Street",
         TitleDeedCard("North Earl Street", True, 260, 130,
                       [22, 110, 330, 800, 975, 1150], "H", "yellow", 150,
                       150, "resources/northearl.png"), 27, False, None)
     s29 = UtilitySquare(
         "Waterworks", 28,
         TitleDeedCard("Waterworks", True, 150, 75, [4, 10], "E", None,
                       None, None, "resources/Utility.png"), 150)
     s30 = Property(
         "O'Connell Street",
         TitleDeedCard("O'Connell Street", True, 280, 140,
                       [24, 120, 360, 850, 1025, 1200], "H", "yellow", 150,
                       150, "resources/oconnellstreet.png"), 29, False,
         None)
     s31 = GoToJail("Go To Jail", 30)
     s32 = Property(
         "George's Street",
         TitleDeedCard("George's Street", True, 300, 150,
                       [26, 130, 390, 900, 1100, 1275], "I", "green", 200,
                       200, "resources/George.png"), 31, False, None)
     s33 = Property(
         "Wicklow Street",
         TitleDeedCard("Wicklow Street", True, 300, 150,
                       [26, 130, 390, 900, 1100, 1275], "I", "green", 200,
                       200, "resources/wicklow.png"), 32, False, None)
     s34 = CardSquare("Community Chest", 33)
     s35 = Property(
         "Grafton Street",
         TitleDeedCard("Grafton Street", True, 320, 160,
                       [28, 150, 450, 1000, 1200, 1400], "I", "green", 200,
                       200, "resources/Grafton.png"), 34, False, None)
     s36 = Station(
         "Shannon Airport", False, None, 200,
         TitleDeedCard("Shannon Airport", True, 200, 100,
                       [25, 50, 100, 200], "B", None, None, None,
                       "resources/ShannonAirport.png"), 35)
     s37 = CardSquare("Chance", 36)
     s38 = Property(
         "Ailesbury Road",
         TitleDeedCard("Ailesbury Road", True, 350, 175,
                       [35, 175, 500, 1100, 1300, 1500], "J", "navy", 200,
                       200, "resources/ailesbury.png"), 37, False, None)
     s39 = Tax("Super Tax", 38, 100)
     s40 = Property(
         "Shrewsbury Road",
         TitleDeedCard("Shrewsbury Road", True, 400, 200,
                       [50, 200, 600, 1400, 1700, 2000], "J", "navy", 200,
                       200, "resources/shrewsbury.png"), 39, False, None)
     squares = [
         s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15,
         s16, s17, s18, s19, s20, s21, s22, s23, s24, s25, s26, s27, s28,
         s29, s30, s31, s32, s33, s34, s35, s36, s37, s38, s39, s40
     ]
     for player in self.players:
         player.set_square(s1)
     self.board = Board(squares)