コード例 #1
0
ファイル: tests.py プロジェクト: charliephairoj/backend
    def setUp(self):
        """
        Sets up environment for tests
        """
        super(TestItemResource, self).setUp()

        self.create_user()

        self.client.login(username='******', password='******')

        #Create supplier, customer and addrss
        self.customer = Customer(**base_customer)
        self.customer.save()
        self.supplier = Supplier(**base_supplier)
        self.supplier.save()
        self.address = Address(address1="Jiggle", contact=self.customer)
        self.address.save()

        #Create a product to add
        self.product = Product.create(self.user, **base_product)
        self.product.save()
        self.fabric = Fabric.create(**base_fabric)
        f_data = base_fabric.copy()
        f_data["pattern"] = "Stripe"
        self.fabric2 = Fabric.create(**f_data)

        #Create acknowledgement
        ack_data = base_ack.copy()
        del ack_data['customer']
        del ack_data['items']
        del ack_data['employee']
        del ack_data['project']
        self.ack = Estimate(**ack_data)
        self.ack.customer = self.customer
        self.ack.employee = self.user
        self.ack.save()

        #Create an item
        self.item_data = {
            'id': 1,
            'quantity': 1,
            'is_custom_size': True,
            'width': 1500,
            "fabric": {
                "id": 1
            }
        }
        self.item = Item.create(acknowledgement=self.ack, **self.item_data)
コード例 #2
0
 def setUp(self):
     """
     Sets up environment for tests
     """
     super(TestItemResource, self).setUp()
     
     self.create_user()
     
     self.client.login(username='******', password='******')
     
     #Create supplier, customer and addrss
     self.customer = Customer(**base_customer)
     self.customer.save()
     self.supplier = Supplier(**base_supplier)
     self.supplier.save()
     self.address = Address(address1="Jiggle", contact=self.customer)
     self.address.save()
     
     #Create a product to add
     self.product = Product.create(self.user, **base_product)
     self.product.save()
     self.fabric = Fabric.create(**base_fabric)
     f_data = base_fabric.copy()
     f_data["pattern"] = "Stripe"
     self.fabric2 = Fabric.create(**f_data)
     
     #Create acknowledgement
     ack_data = base_ack.copy()
     del ack_data['customer']
     del ack_data['items']
     del ack_data['employee']
     del ack_data['project']
     self.ack = Estimate(**ack_data)
     self.ack.customer = self.customer
     self.ack.employee = self.user
     self.ack.save()
     
     #Create an item
     self.item_data = {'id': 1,
                  'quantity': 1,
                  'is_custom_size': True,
                  'width': 1500,
                  "fabric": {"id":1}}
     self.item = Item.create(acknowledgement=self.ack, **self.item_data)
コード例 #3
0
    def setUp(self):
        """
        Set up for the Acknowledgement Test

        Objects created:
        -User
        -Customer
        -Supplier
        -Address
        -product
        -2 fabrics

        After Creating all the needed objects for the Acknowledgement, 
        test that all the objects have been made.
        """
        super(ShippingResourceTest, self).setUp()

        self.ct = ContentType(app_label="shipping")
        self.ct.save()

        #Create the user
        self.username = '******'
        self.password = '******'
        self.user = User.objects.create_user(self.username, '*****@*****.**',
                                             self.password)
        self.user.save()

        p = Permission(content_type=self.ct, codename="change_shipping")
        p.save()
        p2 = Permission(content_type=self.ct, codename="add_shipping")
        p2.save()
        self.user.user_permissions.add(p)
        self.user.user_permissions.add(p2)

        self.user.save()

        self.setup_client()

        #Create supplier, customer and addrss
        self.customer = Customer(**base_customer)
        self.customer.save()
        self.supplier = Supplier(**base_supplier)
        self.supplier.save()
        self.address = Address(address1="Jiggle", contact=self.customer)
        self.address.save()

        #Create project
        self.project = Project.objects.create(codename="Ladawan")

        #Create phase
        self.phase = Phase.objects.create(description="Phase 1/6",
                                          project=self.project)

        #Create a product to add
        self.product = Product.create(self.user, **base_product)
        self.product.save()
        self.fabric = Fabric.create(**base_fabric)
        f_data = base_fabric.copy()
        f_data["pattern"] = "Stripe"
        self.fabric2 = Fabric.create(**f_data)

        #Create acknowledgement
        ack_data = base_ack.copy()
        del ack_data['customer']
        del ack_data['items']
        del ack_data['employee']
        self.ack = Acknowledgement(**ack_data)
        self.ack.customer = self.customer
        self.ack.employee = self.user
        self.ack.save()

        #Create an item
        item_data = {
            'id': 1,
            'quantity': 1,
            'is_custom_size': True,
            'width': 1500,
            "fabric": {
                "id": 1
            }
        }
        self.item = AckItem.create(acknowledgement=self.ack, **item_data)

        #Create an item
        item_data = {
            'id': 1,
            'quantity': 2,
            'is_custom_size': True,
            'width': 1500,
            "fabric": {
                "id": 1
            }
        }
        self.item2 = AckItem.create(acknowledgement=self.ack, **item_data)
コード例 #4
0
ファイル: tests.py プロジェクト: charliephairoj/backend
    def setUp(self):
        """
        Set up for the Estimate Test

        Objects created:
        -User
        -Customer
        -Supplier
        -Address
        -product
        -2 fabrics

        After Creating all the needed objects for the Estimate, 
        test that all the objects have been made.
        """
        super(EstimateResourceTest, self).setUp()

        # Set Base URL
        self.base_url = '{0}'.format('/api/v1/estimate/')

        self.ct = ContentType(app_label="estimates")
        self.ct.save()
        #Create the user
        self.username = '******'
        self.password = '******'
        self.user = User.objects.create_user(self.username, '*****@*****.**',
                                             self.password)
        p = Permission(content_type=self.ct, codename="change_estimate")
        p.save()
        p2 = Permission(content_type=self.ct, codename="add_estimate")
        p2.save()
        self.user.user_permissions.add(p)
        self.user.user_permissions.add(p2)

        self.user.save()

        self.setup_client()

        #Create supplier, customer and addrss
        customer = copy.deepcopy(base_customer)
        del customer['id']
        self.customer = Customer(**customer)
        self.customer.save()
        self.supplier = Supplier(**base_supplier)
        self.supplier.save()
        self.address = Address(address1="Jiggle", contact=self.customer)
        self.address.save()

        #Create a product to add
        self.product = Product.create(self.user, **base_product)
        self.product.save()

        #Create custom product
        self.custom_product = Product()
        self.custom_product.id = 10436
        self.custom_product.save()

        self.fabric = Fabric.create(**base_fabric)
        self.fabric.quantity = 26
        self.fabric.save()

        f_data = base_fabric.copy()
        f_data["pattern"] = "Stripe"
        self.fabric2 = Fabric.create(**f_data)

        #Create custom product
        self.custom_product = Product.create(self.user,
                                             description="Custom Custom",
                                             id=10436,
                                             width=0,
                                             depth=0,
                                             height=0,
                                             price=0,
                                             wholesale_price=0,
                                             retail_price=0)
        self.custom_product.id = 10436
        self.custom_product.save()

        self.image = S3Object(key='test', bucket='test')
        self.image.save()

        #Create acknowledgement
        ack_data = base_ack.copy()
        del ack_data['customer']
        del ack_data['items']
        del ack_data['employee']
        del ack_data['project']
        self.ack = Estimate(**ack_data)
        self.ack.customer = self.customer
        self.ack.employee = self.user
        self.ack.save()

        #Create an item
        item_data = {
            'id': 1,
            'quantity': 1,
            'is_custom_size': True,
            'width': 1500,
            "fabric": {
                "id": 1
            }
        }
        self.item = Item.create(estimate=self.ack, **item_data)
        item_data = {
            'is_custom': True,
            'description': 'F-04 Sofa',
            'quantity': 3
        }
        self.item2 = Item.create(estimate=self.ack, **item_data)

        #Create fake S3Objects to test files attached to acknowledgements
        self.file1 = S3Object(key='test1', bucket='test')
        self.file2 = S3Object(key='test2', bucket='test')
        self.file1.save()
        self.file2.save()
コード例 #5
0
ファイル: tests.py プロジェクト: charliephairoj/backend
    def setUp(self):        
        """
        Set up for the Acknowledgement Test

        Objects created:
        -User
        -Customer
        -Supplier
        -Address
        -product
        -2 fabrics

        After Creating all the needed objects for the Acknowledgement, 
        test that all the objects have been made.
        """
        super(ShippingResourceTest, self).setUp()
        
        self.ct = ContentType(app_label="shipping")
        self.ct.save()

        #Create the user
        self.username = '******'
        self.password = '******'
        self.user = User.objects.create_user(self.username, '*****@*****.**', self.password)
        self.user.save()
        
        p = Permission(content_type=self.ct, codename="change_shipping")
        p.save()
        p2 = Permission(content_type=self.ct, codename="add_shipping")
        p2.save()
        self.user.user_permissions.add(p)
        self.user.user_permissions.add(p2)
        
        self.user.save()

        self.setup_client()

        
        #Create supplier, customer and addrss
        self.customer = Customer(**base_customer)
        self.customer.save()
        self.supplier = Supplier(**base_supplier)
        self.supplier.save()
        self.address = Address(address1="Jiggle", contact=self.customer)
        self.address.save()
        
        #Create project
        self.project = Project.objects.create(codename="Ladawan")
        
        #Create phase
        self.phase = Phase.objects.create(description="Phase 1/6", project=self.project)
        
        #Create a product to add
        self.product = Product.create(self.user, **base_product)
        self.product.save()
        self.fabric = Fabric.create(**base_fabric)
        f_data = base_fabric.copy()
        f_data["pattern"] = "Stripe"
        self.fabric2 = Fabric.create(**f_data)
        
        #Create acknowledgement
        ack_data = base_ack.copy()
        del ack_data['customer']
        del ack_data['items']
        del ack_data['employee']
        self.ack = Acknowledgement(**ack_data)
        self.ack.customer = self.customer
        self.ack.employee = self.user
        self.ack.save()
        
        #Create an item
        item_data = {'id': 1,
                     'quantity': 1,
                     'is_custom_size': True,
                     'width': 1500,
                     "fabric": {"id":1}}
        self.item = AckItem.create(acknowledgement=self.ack, **item_data)
        
        #Create an item
        item_data = {'id': 1,
                     'quantity': 2,
                     'is_custom_size': True,
                     'width': 1500,
                     "fabric": {"id":1}}
        self.item2 = AckItem.create(acknowledgement=self.ack, **item_data)
コード例 #6
0
    def setUp(self):
        """
        Set up for the Estimate Test

        Objects created:
        -User
        -Customer
        -Supplier
        -Address
        -product
        -2 fabrics

        After Creating all the needed objects for the Estimate, 
        test that all the objects have been made.
        """
        super(EstimateResourceTest, self).setUp()

        self.ct = ContentType(app_label="estimates")
        self.ct.save()
        #Create the user
        self.username = '******'
        self.password = '******'
        self.user = User.objects.create_user(self.username, '*****@*****.**', self.password)
        p = Permission(content_type=self.ct, codename="change_estimate")
        p.save()
        p2 = Permission(content_type=self.ct, codename="add_estimate")
        p2.save()
        self.user.user_permissions.add(p)
        self.user.user_permissions.add(p2)
        
        self.user.save()
        
        #Create supplier, customer and addrss
        customer = copy.deepcopy(base_customer)
        del customer['id']
        self.customer = Customer(**customer)
        self.customer.save()
        self.supplier = Supplier(**base_supplier)
        self.supplier.save()
        self.address = Address(address1="Jiggle", contact=self.customer)
        self.address.save()
        
        #Create a product to add
        self.product = Product.create(self.user, **base_product)
        self.product.save()
        
        #Create custom product
        self.custom_product = Product()
        self.custom_product.id = 10436
        self.custom_product.save()
        
        self.fabric = Fabric.create(**base_fabric)
        self.fabric.quantity = 26
        self.fabric.save()
        
        f_data = base_fabric.copy()
        f_data["pattern"] = "Stripe"
        self.fabric2 = Fabric.create(**f_data)
        
        #Create custom product
        self.custom_product = Product.create(self.user, description="Custom Custom", id=10436,
                                             width=0, depth=0, height=0,
                                             price=0, wholesale_price=0, retail_price=0)
        self.custom_product.id = 10436
        self.custom_product.save()
        
        self.image = S3Object(key='test', bucket='test')
        self.image.save()
        
        #Create acknowledgement
        ack_data = base_ack.copy()
        del ack_data['customer']
        del ack_data['items']
        del ack_data['employee']
        del ack_data['project']
        self.ack = Estimate(**ack_data)
        self.ack.customer = self.customer
        self.ack.employee = self.user
        self.ack.save()
        
        #Create an item
        item_data = {'id': 1,
                     'quantity': 1,
                     'is_custom_size': True,
                     'width': 1500,
                     "fabric": {"id":1}}
        self.item = Item.create(estimate=self.ack, **item_data)
        item_data = {'is_custom': True,
                     'description': 'F-04 Sofa',
                     'quantity': 3}
        self.item2 = Item.create(estimate=self.ack, **item_data)
        self.client.login(username="******", password="******")
        
        #Create fake S3Objects to test files attached to acknowledgements
        self.file1 = S3Object(key='test1', bucket='test')
        self.file2 = S3Object(key='test2', bucket='test')
        self.file1.save()
        self.file2.save()