Esempio n. 1
0
 def test_search_not_found(self):
     """ Should not returns esults """
     client = Client()
     SaleFactory(internal_id="ABC-123")
     SaleFactory(internal_id="ABC")
     response = client.get('/sales/?q=ABCd:w')
     self.assertEqual(len(response.context['table'].data), 0)
Esempio n. 2
0
 def test_search_found_and_redirect(self):
     """ Should return one result and redirect """
     client = Client()
     SaleFactory(internal_id="123")
     SaleFactory(internal_id="ABC-123")
     response = client.get('/sales/?q=ABC-123')
     self.assertEqual(response.status_code, 302)
     self.assertIsNone(response.context)
Esempio n. 3
0
    def test_counter_pendings_payments_invoices(self):
        """ Should return counter for pending invoices and payment sales"""

        customer = CustomerFactory()
        SaleFactory(customer=customer)
        sale = SaleFactory(customer=customer)
        InvoiceFactory(sale=sale, total_value=sale.total_value)

        self.assertEqual(customer.count_sales_payments_pending, 2)
        self.assertEqual(customer.count_sales_invoices_pending, 1)
Esempio n. 4
0
 def test_total_invoices(self):
     """ Should return total_values for invoices customer"""
     customer = CustomerFactory()
     sale = SaleFactory(customer=customer)
     InvoiceFactory(sale=sale, total_value=102)
     InvoiceFactory(sale=sale, total_value=103)
     self.assertEqual(customer.total_invoices, 205)
Esempio n. 5
0
 def test_total_payments(self):
     """ Should return total_values for payments for customer"""
     customer = CustomerFactory()
     sale = SaleFactory(customer=customer)
     PaymentFactory(sale=sale, total_value=100)
     PaymentFactory(sale=sale, total_value=101)
     self.assertEqual(customer.total_payments, 201)
Esempio n. 6
0
    def test_export(self):
        SaleFactory(total_value=1000)
        client = Client()

        response = client.get('/sales/?export')
        self.assertEqual(response['Content-Type'], 'text/csv')
        self.assertEqual(response.status_code, 200)
Esempio n. 7
0
 def test_add_sale_for_add_payment(self):
     """ should return a 200 OK for add new payment to sale"""
     sale = SaleFactory()
     client = Client()
     url = reverse_lazy('payment_to_sale', kwargs={'sale_id': sale.id})
     response = client.get(url)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.context['sale'], sale)
     self.assertEqual(response.context['obj'], None)
Esempio n. 8
0
    def test_pending_invoice_table(self):
        """ should return invoice table"""
        SaleFactory(total_value=193456, notes="This note is for sale")

        client = Client()
        url = reverse_lazy('sale_list_pending_invoice')
        response = client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, '193456')
Esempio n. 9
0
 def test_to_csv(self):
     """ Should return value sale in export sales"""
     sale = SaleFactory(total_value=12347)
     self.assertIn('12347',  sale.to_csv())
Esempio n. 10
0
 def test_sales_pending_with_invoice_for_most_all_value(self):
     """ Should return not sale if has invoices for all total_value"""
     sale = SaleFactory(total_value=1000)
     InvoiceFactory(sale=sale, total_value=1500)
     InvoiceFactory(sale=sale, total_value=500)
     self.assertEqual(Invoice.sales_pending().count(), 0)
Esempio n. 11
0
 def test_to_csv(self):
     """ Should return dict with values for sales"""
     sale = SaleFactory(total_value=1000)
     self.assertEqual(sale.to_csv().split(',')[2], '1000')
Esempio n. 12
0
 def test_sales_pending_without_payment(self):
     """ Should return this sale if not have Payment to cover"""
     sale = SaleFactory(total_value=100)
     self.assertCountEqual(Payment.sales_pending().all(), [sale])
Esempio n. 13
0
 def test_sales_pending_with_payment_for_most_all_value(self):
     """ Should return not sale if has payments for all total_value"""
     sale = SaleFactory(total_value=1000)
     PaymentFactory(sale=sale, total_value=1500)
     PaymentFactory(sale=sale, total_value=500)
     self.assertEqual(Payment.sales_pending().count(), 0)
Esempio n. 14
0
 def test_sales_pending_with_payment_not_all_value(self):
     """ Should return this sale if has payments for not all total_value"""
     sale = SaleFactory(total_value=1000)
     PaymentFactory(sale=sale, total_value=50)
     PaymentFactory(sale=sale, total_value=50)
     self.assertCountEqual(Payment.sales_pending().all(), [sale])
Esempio n. 15
0
 def test_sales_pending_without_invoice(self):
     """ Should return this sale if not have Invoice to cover"""
     sale = SaleFactory(total_value=100)
     self.assertCountEqual(Invoice.sales_pending().all(), [sale])
Esempio n. 16
0
 def test_total_payments(self):
     """ Should return total value for payments of sale"""
     sale = SaleFactory(total_value=1000)
     PaymentFactory(sale=sale, total_value=50)
     PaymentFactory(sale=sale, total_value=50)
     self.assertEqual(sale.total_payments, 100)
Esempio n. 17
0
 def test_total_invoices(self):
     """ Should return total value for invoices of sale"""
     sale = SaleFactory(total_value=1000)
     InvoiceFactory(sale=sale, total_value=50)
     InvoiceFactory(sale=sale, total_value=500)
     self.assertEqual(sale.total_invoices, 550)
Esempio n. 18
0
 def test_total_sales(self):
     """ Should return total_values for sales for customer"""
     customer = CustomerFactory()
     SaleFactory(customer=customer, total_value=1)
     SaleFactory(customer=customer, total_value=11)
     self.assertEqual(customer.total_sales, 12)
Esempio n. 19
0
 def test_total_payments_in_cero(self):
     """ Should return cero for sales without payments"""
     sale = SaleFactory(total_value=100)
     self.assertEqual(sale.total_payments, 0)
Esempio n. 20
0
 def test_sales_pending_with_invoice_not_all_value(self):
     """ Should return this sale if has invoices for not all total_value"""
     sale = SaleFactory(total_value=1000)
     InvoiceFactory(sale=sale, total_value=50)
     InvoiceFactory(sale=sale, total_value=50)
     self.assertCountEqual(Invoice.sales_pending().all(), [sale])