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)
def test_latest_full_teapot(self): State.create( state="FULL_TEAPOT", timestamp=datetime(2015, 1, 1).isoformat(), num_of_cups=3 ) State.create( state="FULL_TEAPOT", timestamp=datetime(2016, 1, 1).isoformat(), num_of_cups=4 ) State.create( state="FULL_TEAPOT", timestamp=datetime(2017, 1, 1).isoformat(), num_of_cups=5 ) result = State.get_latest_full_teapot() self.assertEqual(result.num_of_cups, 5)
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)