Beispiel #1
0
    def create_activity(row):
        name = row[cols[header_name]].value
        capacity = row[cols[header_capacity]].value
        if row[cols[header_repeatability]].value.lower() == "no":
            repeatability = False
        elif row[cols[header_repeatability]].value.lower() == "yes":
            repeatability = True

        return Activity(name, capacity, repeatability)
Beispiel #2
0
 def get_activity(self, id):
     sid = str(id)
     if sid in self.pool.keys():
         logging.debug("Found activity in pool")
         #Have accessed this activity, place at end of queue
         self.pool_queue.remove(sid)
         self.pool_queue.append(sid)
     else:
         logging.debug("Activity NOT found in pool")
         self.pool[sid] = Activity(pytrainer_main=self.pytrainer_main,
                                   id=id)
         self.pool_queue.append(sid)
     if len(self.pool_queue) > self.max_size:
         sid_to_remove = self.pool_queue.pop(0)
         logging.debug("Removing activity: %s" % sid_to_remove)
         del self.pool[sid_to_remove]
     logging.debug("ActivityPool queue length: %d" % len(self.pool_queue))
     logging.debug("ActivityPool queue: %s" % str(self.pool_queue))
     return self.pool[sid]
 def test_participants_is_hash(self):
     activity = Activity("Brunch")
     assert type(activity.participants), hash
 def test_activity_has_name(self):
     activity = Activity("Brunch")
     assert activity.name, "Brunch"
    def test_breakout(self):
        activity = Activity("Brunch")
        activity.add_participant("Maria", 20)
        activity.add_participant("Luther", 40)

        assert activity.owed(), {'Maria': 10, 'Luther': -10}
    def test_returns_amount_owed(self):
        activity = Activity("Brunch")
        activity.add_participant("Maria", 20)
        activity.add_participant("Luther", 40)

        assert activity.owed(), {'Maria': 10, 'Luther': -10}
    def test_can_split_costs(self):
        activity = Activity("Brunch")
        activity.add_participant("Maria", 20)
        activity.add_participant("Luther", 40)

        assert activity.split(), 30
    def test_calculates_total_cost(self):
        activity = Activity("Brunch")
        activity.add_participant("Maria", 20)
        activity.add_participant("Luther", 40)

        assert activity.total_cost, 60
 def test_participants_returns_name_cost(self):
     activity = Activity("Brunch")
     activity.add_participant("Maria", 20)
     activity.add_participant("Luther", 40)
     assert type(activity.participants), hash
     assert activity.participants, {"Maria": 20, "Luther": 40}
    def test_total_cost_breakout_and_summary(self):
        reunion = Reunion("Lambert Family Reunion")
        activity_1 = Activity("Brunch")
        activity_1.add_participant("Maria", 20)
        activity_1.add_participant("Luther", 40)
        reunion.add_activity(activity_1)

        assert reunion.total_cost, 60

        activity_2 = Activity("Drinks")
        activity_2.add_participant("Maria", 60)
        activity_2.add_participant("Luther", 60)
        activity_2.add_participant("Louis", 0)
        reunion.add_activity(activity_2)
        assert reunion.total_cost, 180
        assert reunion.breakout(), {"Maria": -10, "Luther": -30, "Louis": 40}
        assert type(reunion.summary()), String