Esempio n. 1
0
    def test_equal(self):
        pet1 = Pet(name="test name", photo_urls=["string"])
        pet1.id = 1
        pet1.status = "available"
        cate1 = category.Category()
        cate1.id = 1
        cate1.name = "dog"
        tag1 = tag.Tag()
        tag1.id = 1
        pet1.tags = [tag1]

        pet2 = Pet(name="test name", photo_urls=["string"])
        pet2.id = 1
        pet2.status = "available"
        cate2 = category.Category()
        cate2.id = 1
        cate2.name = "dog"
        tag2 = tag.Tag()
        tag2.id = 1
        pet2.tags = [tag2]

        self.assertTrue(pet1 == pet2)

        # reset pet1 tags to empty array so that object comparison returns false
        pet1.tags = []
        self.assertFalse(pet1 == pet2)
 def setUpModels(self):
     from petstore_api.model import category, tag
     self.category = category.Category()
     self.category.id = id_gen()
     self.category.name = "dog"
     self.tag = tag.Tag()
     self.tag.id = id_gen()
     self.tag.name = "python-pet-tag"
     self.pet = pet.Pet(name="hello kity", photo_urls=["http://foo.bar.com/1", "http://foo.bar.com/2"])
     self.pet.id = id_gen()
     self.pet.status = "sold"
     self.pet.category = self.category
     self.pet.tags = [self.tag]
 def setUpModels(cls):
     cls.category = category.Category()
     cls.category.id = id_gen()
     cls.category.name = "dog"
     cls.tag = tag.Tag()
     cls.tag.id = id_gen()
     cls.tag.name = "python-pet-tag"
     cls.pet = pet.Pet(
         name="hello kity",
         photo_urls=["http://foo.bar.com/1", "http://foo.bar.com/2"])
     cls.pet.id = id_gen()
     cls.pet.status = "sold"
     cls.pet.category = cls.category
     cls.pet.tags = [cls.tag]
Esempio n. 4
0
    def test_to_str(self):
        pet = Pet(name="test name", photo_urls=["string"])
        pet.id = 1
        pet.status = "available"
        cate = category.Category()
        cate.id = 1
        cate.name = "dog"
        pet.category = cate
        tag1 = tag.Tag()
        tag1.id = 1
        pet.tags = [tag1]

        data = ("{'category': {'id': 1, 'name': 'dog'},\n"
                " 'id': 1,\n"
                " 'name': 'test name',\n"
                " 'photo_urls': ['string'],\n"
                " 'status': 'available',\n"
                " 'tags': [{'id': 1}]}")
        self.assertEqual(data, pet.to_str())