def test0110_find_customer(self):
        customer_1 = Customer(name='Raven', phone='010-9508-1111')
        customer_1.save()
        customer_2 = Customer(name='Julia', phone='010-9508-1112')
        customer_2.save()
        # results = Customer.objects({}).exclude('id').as_pymongo()
        results = Customer.objects().fields(id=0).to_json()
        # results = Customer.objects().fields(id=0).to_mongo().to_dict()

        print(results)
Exemplo n.º 2
0
 def post(self):
     request.get_json(force=True)
     args = customers_parser.parse_args()
     customer = Customer(**args)
     db_session.add(customer)
     db_session.commit()
     return None
 def test0130_delete_model_customer(self):
     customer = Customer(name='Raven', phone='010-9508-1111')
     customer.save()
     result = Customer.objects(customer_id=1).delete()
     print(result)
     result = Customer.objects(customer_id=1)
     print(result)
Exemplo n.º 4
0
 def post(self):
     request.get_json(force=True)
     args = customers_parser.parse_args()
     logger.debug(args)
     customer = Customer(**args)
     customer.save()
     return None
 def test0120_patch_model_customer(self):
     customer = Customer(name='Raven', phone='010-9508-1111')
     customer.save()
     Customer.objects().update(name="Julia")
     customer.reload()
     # fresh_pers = Customer.objects().exclude('id').first()
     self.assertEqual(customer.name, 'Julia')
     self.assertEqual(customer.phone, '010-9508-1111')
Exemplo n.º 6
0
 def test106_customers_filter(self):
     name = 'Raven'
     phone = '010-9508-0875'
     c = Customer(name, phone)
     self.session.add(c)
     self.session.commit()
     r = self.session.query(Customer) \
         .filter_by(name=name) \
         .first()
     self.assertEqual(name, r.name)
     self.assertEqual(phone, r.phone)
    def test0200_create_rental(self):
        customer = Customer(name='Raven', phone='010-9508-1111')
        customer.save()
        book = Book(title="ABC", author='Julia', publisher='WinWin')
        book.save()

        rental = Rental(book=book, customer=customer)
        rental.rental_start = datetime.datetime(2020, 8, 15, 00, 00, 00)
        rental.save()

        result = Rental.objects().fields(id=0).first()
        print(result.to_json(follow_reference=True))
 def test0100_check_model_customer(self):
     customer = Customer(name='Raven', phone='010-9508-1111')
     customer.save()
     # fresh_pers = Customer.objects().exclude('id').first()
     self.assertEqual(customer.name, 'Raven')
Exemplo n.º 9
0
 def test105_customers_new(self):
     name = 'Raven'
     phone = '010-9508-0875'
     c = Customer(name, phone)
     self.assertEqual(name, c.name)
     self.assertEqual(phone, c.phone)
Exemplo n.º 10
0
 def add_customers(self):
     for customer in USERS:
         self.session.add(Customer(*customer))
     self.session.commit()