def test_market_prices(self): with unittest.mock.patch('sys.stdout', new=io.StringIO()) as fake_out: main.get_price() fake_out = fake_out.getvalue() fake_out = fake_out.strip() self.assertEqual(fake_out, "Get price") # def test_main_menu(self): # mock_input = [2] # # with unittest.mock.patch('builtins.input', side_effect=mock_input): # main.main_menu() # self.assertIn(2, main.full_inventory) # new_dict = main.full_inventory[12] # See TEST_IMPROVEMENTS ################### #TEST_IMPROVEMENTS# ################### # line 34 # ---class test_main, method test_item_info--- # This part proved troubling. I wanted to take mock_input, run it through # main.add_new_item, and then use main.item_info() to test the print output. # Please add comments or help on this portion if possible. # line 68 # ---class test_main, method test_main_menu--- # Testing the main_menu proved difficult as I wanted to initialize # user_prompt, but was not sure how I could do this. Possibly stringIO method, # but what I tried did not work properly.
def test_get_price(self, print_mock): with mock.patch("market_prices.get_latest_price") as market_patch: market_patch.return_value = 1 main.get_price('abc') market_patch.assert_called() print_mock.assert_called_with(1)
def test_sell(self): rv = self.app.post('/submit', data=dict( quantity=100, ), follow_redirects=True) assert '1' in rv.data with main.APP.test_request_context(): main.query = "some thing wrong with request" main.get_price() self.app.get('/get_price') print "bad query test for get_price"
def test_get_price(self): """ Calls main.get_price and verifies the content of its print statement. """ expected_output = "Get price\n" captured_output = io.StringIO() sys.stdout = captured_output main.get_price() sys.stdout = sys.__stdout__ self.assertEqual(expected_output, captured_output.getvalue())
def test_get_latest_price(self): ''' Testing pricing return ''' # pylint: disable=W0201 self.get_price = MagicMock(return_value=24) self.assertEqual(24, main.get_price(1))
def find_route(event_id): start_long = request.args.get("longitude") start_lat = request.args.get("latitude") end_vals = get_lat_long(event_id) end_lat = end_vals['lat'] end_long = end_vals['lng'] return jsonify(main.get_price(start_lat, start_long, end_lat, end_long))
def checkout(idVal): try: print G['event_price'] except Exception as exp: print("ERROR {}".format(exp)) g = { 'end_long': '34.9704971', 'city': u'Spartanburg', 'name': u'The Black Out Party', 'long': u'-82.30639559999997', 'state': u'SC', 'location': u'Spartanburg, SC 29307', 'end_lat': '-81.91012490000003', 'time': u'Fri, Nov 23, 2018, 8:00 PM \u2013 | Sat, Nov 24, 2018, 12:00 AM EST', 'lat': u'34.7189712', 'full_location': u'| Drayton Mills Marketplace | 1800 Drayton Road | Spartanburg, SC 29307', 'event_price': 10 } info = {} info['event1'] = G['event_price'] info['sub1'] = info['event1'] + 6.25 #info['transport'] = 11.31 info['transport_info'] = main.get_price(G['lat'], G['long'], G['end_lat'], G['end_long']) info['transport'] = info['transport_info']['low_estimate'] info['sub2'] = info['transport'] + 4.25 info['total'] = info['sub1'] + info['transport'] + 4.25 info['name'] = G['name'] info[ 'description'] = 'My Description My Description My Description My Description My Description My Description My Description My Description My Description My Description' info['location'] = 'My Location' info['time'] = G['time'] info['location'] = G['location'] info['city'] = G['city'] info['state'] = G['state'] info['full_location'] = G['full_location'] info['lat'] = G['lat'] info['long'] = G['long'] info['end_lat'] = G['end_lat'] info['end_long'] = G['end_long'] info['event1'] = '${:,.2f}'.format(info['event1']) info['sub1'] = '${:,.2f}'.format(info['sub1']) info['sub2'] = '${:,.2f}'.format(info['sub2']) info['total'] = '${:,.2f}'.format(info['total']) info['transport'] = '${:,.2f}'.format(info['transport']) print G return render_template("checkout.html", info=info, ride=info['transport_info'])
def test_get_price(self): """Tests that get_price returns the expected, bad value""" self.assertEqual(get_price(100), 100) self.assertEqual(get_price(1000), 1000) self.assertEqual(get_price(-100), -100) self.assertEqual(get_price(-1000), -1000)
def test_get_price(self): """Test the get_price() method""" self.assertEqual(main.get_price('DISH2K'), 'Current price of DISH2K: 24')
def test_market_prices(self): """ Verify that the get_price function returns correct value""" self.assertEqual(get_price(), 24)
def test_get_price_abnormal_input(self): self.assertEqual(get_price("test"), ValueError) self.assertEqual(get_price(14.5), 1)
def test_get_price(): assert get_price(200) == 200 assert get_price(2000) == 2000 assert get_price(-200) == 2100 assert get_price(-2000) == -2000
def test_get_price(self): price = get_price(1) self.assertEqual(1, price)
def test_get_price(self): self.assertEqual(get_price(), get_latest_price())
def test_get_price_normal_input(self): # Test every age prices = [ 0, 0, 0, 5, 5, # 0 to 4 5, 5, 5, 5, 5, # 5 to 9 5, 5, 5, 5, 5, # 10 to 14 5, 5, 5, 10, 10, # 15 to 19 10, 10, 10, 10, 10, # 20 to 24 10, 10, 10, 10, 10, # 25 to 29 10, 10, 10, 10, 10, # 30 to 34 10, 10, 10, 10, 10, # 35 to 39 10, 10, 10, 10, 10, # 40 to 44 10, 10, 10, 10, 10, # 45 to 49 10, 10, 10, 10, 10, # 50 to 54 10, 10, 10, 10, 10, # 55 to 59 10, 10, 10, 10, 8, # 60 to 64 8, 8, 8, 8, 8, # 65 to 69 8, 8, 8, 8, 8, # 70 to 74 8, 8, 8, 8, 8, # 75 to 79 8, 8, 8, 8, 8, # 80 to 84 8, 8, 8, 8, 8, # 85 to 89 8, 8, 8, 8, 8, # 90 to 94 8, 8, 8, 8, 8, # 95 to 99 8, 8, 8, 8, 8 # 100 to 104 ] for i in range(1, len(prices)): self.assertEqual(get_price(i), prices[i - 1])
def test_get_price(self): """Testing of get price item""" expected_output = 24 actual_output = main.get_price(100) self.assertEquals(expected_output, actual_output)
def test_get_prices(self): self.assertEqual(main.get_price(69420), 'get price for 69420')
def test_get_price(self): """Tests get_price method""" self.assertEqual(24, get_price(5))
def test_get_price(self): """Tests get_price method from main""" assert main.get_price(2) == "Get price for 2"
def test_get_price(): """Tests that get_price returns the expected""" assert get_price(200) == 200 assert get_price(2000) == 2000 assert get_price(-200) == 2100 assert get_price(-2000) == -2000
def test_get_price(): """Tests that get_price returns the expected, bad value""" assert get_price(100) == 100 assert get_price(1000) == 1000 assert get_price(-100) == -100 assert get_price(-1000) == -1000
def test_get_price(self): with patch('builtins.input', side_effect=['345', 'Table', '59.99', 'y', 'Wood', 'L']): main.add_new_item() self.assertEqual(main.get_price('345'), 24)
def test_get_price(self): output = get_price(1) self.assertEqual(output, 'Get price for item 1.')