Пример #1
0
    def test_0a_1_2_1_get_dict(self):
        user = User(username="******", password="******")

        class tst(object):
            def __init__(self):
                self.Id = 41
                self.paSSword = "******"
                self.username = "******"
                self.bool1 = True
                self.bool2 = False
                self.nr = NotReceived()
                self.unsupported1 = {}
                self.unsupported2 = user

        validation_obj = tst()
        the_dict = get_dict(validation_obj)
        self.assertEqual(the_dict, {
            "username": "******",
            "bool1": True,
            "bool2": False
        })
        the_dict = get_dict(validation_obj, id=True, dangerous=True)
        self.assertEqual(
            the_dict, {
                "username": "******",
                "bool1": True,
                "bool2": False,
                "paSSword": "******",
                "Id": 41
            })
        print("Test 0a_1_2_1 : get_dict: with object")
Пример #2
0
    def test_0a_1_2_3_get_dict(self):
        user = User(username="******", password="******")
        the_dict = {
            "Id": 41,
            "paSSword": "******",
            "username": "******",
            "bool1": True,
            "bool2": False,
            "nr": NotReceived(),
            "unsupported1": {},
            "unsupported2": user
        }
        validated = get_dict(the_dict, id=True, dangerous=True)
        self.assertEqual(
            validated, {
                "username": "******",
                "bool1": True,
                "bool2": False,
                "paSSword": "******",
                "Id": 41
            })

        validated = get_dict(the_dict)
        self.assertEqual(validated, {
            "username": "******",
            "bool1": True,
            "bool2": False
        })
        print("Test 0a_1_2_3 : get_dict: with dict")
Пример #3
0
 def test_0a_1_4_1_MyModel(self):
     # Testing update
     # Creating the product
     product_to_del = Product(name="Cheese",
                              price=50.4,
                              quantity=7.89,
                              id=10000000,
                              code=789456611)
     product_to_del.insert()
     product_dict = get_dict(product_to_del, id=True, dangerous=True)
     self.assertEqual(
         product_dict, {
             "id": 1,
             "name": "Cheese",
             "price": 50.4,
             "quantity": 7.89,
             "code": 789456611
         })
     product_to_del.update(id=14,
                           name="QUU",
                           price=90,
                           quantity=7000,
                           code=0)
     product_dict = get_dict(product_to_del, id=True, dangerous=True)
     self.assertEqual(product_dict, {
         "id": 1,
         "name": "QUU",
         "price": 90,
         "quantity": 7000,
         "code": 0
     })
     product_to_del.delete()
     print("Test 0a_1_4_1 : MyModel: update")
Пример #4
0
    def test_0a_1_2_3_get_dict(self):
        product = Product(name="Cheese",
                          price=50.4,
                          quantity=7.89,
                          code=789456611)
        the_dict = {
            "Id": 41,
            "paSSword": "******",
            "username": "******",
            "bool1": True,
            "bool2": False,
            "nr": NotReceived(),
            "unsupported1": {},
            "unsupported2": product
        }
        validated = get_dict(the_dict, id=True, dangerous=True)
        self.assertEqual(
            validated, {
                "username": "******",
                "bool1": True,
                "bool2": False,
                "paSSword": "******",
                "Id": 41
            })

        validated = get_dict(the_dict)
        self.assertEqual(validated, {
            "username": "******",
            "bool1": True,
            "bool2": False
        })
        print("Test 0a_1_2_3 : get_dict: with dict")
Пример #5
0
    def test_0a_1_2_1_get_dict(self):
        product = Product(name="Cheese",
                          price=50.4,
                          quantity=7.89,
                          code=789456611)

        class tst(object):
            def __init__(self):
                self.Id = 41
                self.paSSword = "******"
                self.username = "******"
                self.bool1 = True
                self.bool2 = False
                self.nr = NotReceived()
                self.unsupported1 = {}
                self.unsupported2 = product

        validation_obj = tst()
        the_dict = get_dict(validation_obj)
        self.assertEqual(the_dict, {
            "username": "******",
            "bool1": True,
            "bool2": False
        })
        the_dict = get_dict(validation_obj, id=True, dangerous=True)
        self.assertEqual(
            the_dict, {
                "username": "******",
                "bool1": True,
                "bool2": False,
                "paSSword": "******",
                "Id": 41
            })
        print("Test 0a_1_2_1 : get_dict: with object")
Пример #6
0
 def test_0a_1_2_2_get_dict(self):
     user = User(username="******", password="******")
     the_dict = get_dict(user, id=True, dangerous=True)
     user.insert()
     the_dict = get_dict(user, id=True, dangerous=True)
     self.assertEqual(the_dict, {
         "username": "******",
         "password": "******",
         "id": 1
     })
     user.delete()
     print("Test 0a_1_2_2 : get_dict: with object")
Пример #7
0
 def test_0a_1_2_2_get_dict(self):
     product = Product(name="Cheese",
                       price=50.4,
                       quantity=7.89,
                       code=789456611)
     the_dict = get_dict(product, id=True, dangerous=True)
     product.insert()
     the_dict = get_dict(product, id=True, dangerous=True)
     self.assertEqual(
         the_dict, {
             "name": "Cheese",
             "price": 50.4,
             "id": 1,
             "quantity": 7.89,
             "code": 789456611
         })
     product.delete()
     print("Test 0a_1_2_2 : get_dict: with object")
Пример #8
0
 def test_0a_1_4_1_MyModel(self):
     # Testing update
     # Creating the user
     user_to_del = User(username="******", password="******")
     user_to_del.insert()
     user_dict = get_dict(user_to_del, id=True, dangerous=True)
     self.assertEqual(user_dict, {
         "id": 1,
         "username": "******",
         "password": "******"
     })
     user_to_del.update(id=14, username="******", password="******")
     user_dict = get_dict(user_to_del, id=True, dangerous=True)
     self.assertEqual(user_dict, {
         "id": 1,
         "username": "******",
         "password": "******"
     })
     user_to_del.delete()
     print("Test 0a_1_4_1 : MyModel: update")