Esempio n. 1
0
    def test_claim_pot_unclaimed(self):
        maker = PotMaker.create(name='bob',
                                number_of_pots_made=1,
                                total_weight_made=12,
                                number_of_cups_made=5,
                                largest_single_pot=2)
        State.create(state="FULL_TEAPOT",
                     timestamp=datetime(2016, 1, 1, 12, 0, 0),
                     num_of_cups=5,
                     weight=10)
        State.create(state="FULL_TEAPOT",
                     timestamp=datetime(2017, 1, 1, 12, 0, 0),
                     num_of_cups=2,
                     weight=5)
        result = self.app.post('/claimPot',
                               data=json.dumps({
                                   'potMaker': 'bob',
                               }))
        self.assertEqual(result.status_code, 200)
        data = json.loads(result.data)
        self.assertEqual(data['submitMessage'], 'Pot claimed, thanks, bob')

        updated_pot_maker = PotMaker.get_single_pot_maker('bob')
        self.assertEqual(updated_pot_maker.number_of_pots_made, 2)
        self.assertEqual(updated_pot_maker.total_weight_made, 17)
        self.assertEqual(updated_pot_maker.number_of_cups_made, 7)
        self.assertEqual(updated_pot_maker.largest_single_pot, 5)

        updated_state = State.get_latest_full_teapot()
        self.assertEqual(updated_state.claimed_by, maker)
Esempio n. 2
0
 def test_get_single_pot_maker(self):
     PotMaker.create(
         name='aaron',
         number_of_pots_made=1,
         total_weight_made=12,
         number_of_cups_made=5,
         largest_single_pot=2
     )
     result = PotMaker.get_single_pot_maker('aaron')
     self.assertEqual(result.name, 'aaron')
Esempio n. 3
0
 def test_pot_makers(self):
     PotMaker.create(name='aaron',
                     number_of_pots_made=1,
                     total_weight_made=12,
                     number_of_cups_made=5,
                     largest_single_pot=2)
     PotMaker.create(name='bob',
                     number_of_pots_made=1,
                     total_weight_made=12,
                     number_of_cups_made=5,
                     largest_single_pot=2)
     result = self.app.get('/potMakers')
     self.assertEqual(result.status_code, 200)
     data = json.loads(result.data)
     self.assertEqual(len(data['potMakers']), 2)
    def test_tea_ready_claimed(self, mock_slack):
        maker = PotMaker.create(
            name='bob',
            number_of_pots_made=1,
            total_weight_made=12,
            number_of_cups_made=5,
            largest_single_pot=2
        )
        State.create(
            state="FULL_TEAPOT",
            timestamp=datetime.now().isoformat(),
            num_of_cups=3,
            claimed_by=maker
        )
        result = self.app.post("/teaReady")
        self.assertEqual(result.status_code, 200)
        mock_slack.post_message_to_room.assert_any_call(
            "The Teapot :teapot: is ready with 3 cups, thanks to bob"
        )
        reaction_message = \
            "Want a cup of tea from the next teapot ? " + \
            "React to this message to let everyone know!"
        mock_slack.post_message_to_room.assert_any_call(
            reaction_message, True)

        self.assertEqual(mock_slack.post_message_to_room.call_count, 2)
Esempio n. 5
0
 def test_get_all_pots(self):
     PotMaker.create(
         name='aaron',
         number_of_pots_made=1,
         total_weight_made=12,
         number_of_cups_made=5,
         largest_single_pot=2
     )
     PotMaker.create(
         name='aaron2',
         number_of_pots_made=12,
         total_weight_made=24,
         number_of_cups_made=45,
         largest_single_pot=22
     )
     result = PotMaker.get_all()
     self.assertEqual(len(result), 2)
Esempio n. 6
0
 def test_get_number_of_teapot_requests(self):
     PotMaker.create(
         name='aaron',
         number_of_pots_made=1,
         total_weight_made=12,
         number_of_cups_made=5,
         largest_single_pot=2,
         mac_address='123'
     )
     PotMaker.create(
         name='gareth',
         number_of_pots_made=1,
         total_weight_made=12,
         number_of_cups_made=5,
         largest_single_pot=2,
         mac_address='123',
         requested_teapot=True
     )
     PotMaker.create(
         name='mario',
         number_of_pots_made=1,
         total_weight_made=12,
         number_of_cups_made=5,
         largest_single_pot=2,
         mac_address='123',
         requested_teapot=True
     )
     result = PotMaker.get_number_of_teapot_requests()
     self.assertEqual(result, 2)
 def test_pot_makers(self):
     PotMaker.create(
         name='aaron',
         number_of_pots_made=1,
         total_weight_made=12,
         number_of_cups_made=5,
         largest_single_pot=2
     )
     PotMaker.create(
         name='bob',
         number_of_pots_made=1,
         total_weight_made=12,
         number_of_cups_made=5,
         largest_single_pot=2
     )
     result = self.app.get('/potMakers')
     self.assertEqual(result.status_code, 200)
     data = json.loads(result.data)
     self.assertEqual(len(data['potMakers']), 2)
    def test_claim_pot_unclaimed(self):
        maker = PotMaker.create(
            name='bob',
            number_of_pots_made=1,
            total_weight_made=12,
            number_of_cups_made=5,
            largest_single_pot=2
        )
        State.create(
            state="FULL_TEAPOT",
            timestamp=datetime(2016, 1, 1, 12, 0, 0),
            num_of_cups=5,
            weight=10
        )
        State.create(
            state="FULL_TEAPOT",
            timestamp=datetime(2017, 1, 1, 12, 0, 0),
            num_of_cups=2,
            weight=5
        )
        result = self.app.post(
            '/claimPot',
            data=json.dumps({
                'potMaker': 'bob',
            })
        )
        self.assertEqual(result.status_code, 200)
        data = json.loads(result.data)
        self.assertEqual(data['submitMessage'], 'Pot claimed, thanks, bob')

        updated_pot_maker = PotMaker.get_single_pot_maker(
            'bob'
        )
        self.assertEqual(updated_pot_maker.number_of_pots_made, 2)
        self.assertEqual(updated_pot_maker.total_weight_made, 17)
        self.assertEqual(updated_pot_maker.number_of_cups_made, 7)
        self.assertEqual(updated_pot_maker.largest_single_pot, 5)

        updated_state = State.get_latest_full_teapot()
        self.assertEqual(updated_state.claimed_by, maker)
Esempio n. 9
0
 def test_claim_pot_already_claimed(self):
     maker = PotMaker.create(name='bob',
                             number_of_pots_made=1,
                             total_weight_made=12,
                             number_of_cups_made=5,
                             largest_single_pot=2)
     State.create(state="FULL_TEAPOT",
                  timestamp=datetime(2016, 1, 1, 12, 0, 0),
                  num_of_cups=2,
                  claimed_by=maker)
     result = self.app.post('/claimPot')
     self.assertEqual(result.status_code, 200)
     data = json.loads(result.data)
     self.assertEqual(data['submitMessage'], 'Pot has already been claimed')
 def test_claim_pot_already_claimed(self):
     maker = PotMaker.create(
         name='bob',
         number_of_pots_made=1,
         total_weight_made=12,
         number_of_cups_made=5,
         largest_single_pot=2
     )
     State.create(
         state="FULL_TEAPOT",
         timestamp=datetime(2016, 1, 1, 12, 0, 0),
         num_of_cups=2,
         claimed_by=maker
     )
     result = self.app.post('/claimPot')
     self.assertEqual(result.status_code, 200)
     data = json.loads(result.data)
     self.assertEqual(data['submitMessage'], 'Pot has already been claimed')
Esempio n. 11
0
 def test_flip_requested_teapot_false_true(self):
     PotMaker.create(
         name='aaron',
         number_of_pots_made=1,
         total_weight_made=12,
         number_of_cups_made=5,
         largest_single_pot=2,
         mac_address='123'
     )
     maker = PotMaker.get_single_pot_maker('aaron')
     self.assertFalse(maker.requested_teapot)
     PotMaker.flip_requested_teapot('123')
     maker = PotMaker.get_single_pot_maker('aaron')
     self.assertTrue(maker.requested_teapot)
Esempio n. 12
0
    def test_tea_ready_claimed(self, mock_slack):
        maker = PotMaker.create(name='bob',
                                number_of_pots_made=1,
                                total_weight_made=12,
                                number_of_cups_made=5,
                                largest_single_pot=2)
        State.create(state="FULL_TEAPOT",
                     timestamp=datetime.now().isoformat(),
                     num_of_cups=3,
                     claimed_by=maker)
        result = self.app.post("/teaReady")
        self.assertEqual(result.status_code, 200)
        mock_slack.post_message_to_room.assert_any_call(
            "The Teapot :teapot: is ready with 3 cups, thanks to bob")
        reaction_message = \
            "Want a cup of tea from the next teapot ? " + \
            "React to this message to let everyone know!"
        mock_slack.post_message_to_room.assert_any_call(reaction_message, True)

        self.assertEqual(mock_slack.post_message_to_room.call_count, 2)