Exemplo n.º 1
0
 def test_show_game(self):
     "Test viewing games"
     selection = videogame.find_one
     videogame_id = ObjectId.__str__(selection.get("_id"))
     result = self.client.get(f'/videogame/{videogame_id}')
     self.assertEqual(result.status, '200 OK')
     self.assertIn(b'Persona 3', result.data)
Exemplo n.º 2
0
 def test_store_show_item(self):
     """Test view single store item"""
     selection = itemlist.find_one({'title': 'Sketch'})
     itemlist_id = ObjectId.__str__(selection.get("_id"))
     result = self.client.get(f'/store_item/{itemlist_id}')
     #self.assertEqual(b'60.0', id)
     self.assertEqual(result.status, '200 OK')
     self.assertIn(b'Genius college student', result.data)
Exemplo n.º 3
0
 def test_store_purchase(self):
     """Buying an additional item"""
     selection = itemlist.find_one({'title': 'Sketch'})
     itemlist_id = ObjectId.__str__(selection.get("_id"))
     result = self.client.get(f'/store_item/{itemlist_id}/purchase')
     self.assertEqual(result.status, '302 FOUND')
     self.assertEqual(
         cartlist.find_one({'title': 'Sketch'})['item_id'],
         selection['_id'])
Exemplo n.º 4
0
    def post(self, request):
        try:
            _id = ObjectId(request.data['model_id'])
            message = request.data['message']
            nlu_model_manager = nlu_model_boundarie.getNluManager(
                _id.__str__())
            result = nlu_model_manager.parse(message)
        except Exception as e:
            print("{}: {}".format(type(e), e))
            return JsonResponse({"status": "fail", "message": e.__str__()})

        return JsonResponse({"result": result})
Exemplo n.º 5
0
 def test_cart_delete(self):
     """Test deleting item from cart"""
     #delete everything from cart to begin
     cartlist.delete_many({})
     #find one item, and push it into our cart
     selection = itemlist.find_one({'title': 'Sketch'})
     itemlist_id = ObjectId.__str__(selection.get("_id"))
     cartitem = {
         'item_id': selection.get('_id'),
         'title': selection.get('title'),
         'image_sm': selection.get('image_sm'),
         'price': selection.get('price'),
         'quantity': 1
     }
     cartlist.insert_one(cartitem).inserted_id
     #get data of the item
     selection = cartlist.find_one({'title': 'Sketch'})
     itemlist_id = ObjectId.__str__(selection.get("_id"))
     #test delete, verify a redirect, that our cartlist no longer contains the item, and the cart is empty
     result = self.client.post(f'/store_cart/{itemlist_id}/delete',
                               data=itemlist_id)
     self.assertEqual(result.status, '302 FOUND')
     self.assertIsNone(cartlist.find_one({'title': 'Sketch'}))
     self.assertEqual(cartlist.count_documents({}), 0)