Esempio n. 1
0
class PointsaleTest(BaseTestCase):

    def set_up(self):
        self.pointsale_suite = PointSaleSuite(self.client, self.application)

    def testUniqMainPointsale(self):
        response = self.pointsale_suite.create_pointsale_rest(name=u"Точка1", address=u"Адрес1", is_central=True)
        self.assertEqual(response.status_code, 200)
        id = self._deserialize(response.data)['id']

        response = self.pointsale_suite.create_pointsale_rest(name=u"Точка2", address=u"Адрес2", is_central=True)
        self.assertEqual(response.status_code, 400)
        response = self.pointsale_suite.create_pointsale_rest(name=u"Точка2", address=u"Адрес2", is_central=False)
        self.assertEqual(response.status_code, 200)
        id_2 = self._deserialize(response.data)['id']
        response = self.pointsale_suite.update_pointsale_rest(id_2, is_central=True)
        self.assertEqual(response.status_code, 400)

        response = self.pointsale_suite.update_pointsale_rest(id, is_central=False)
        self.assertEqual(response.status_code, 200)
Esempio n. 2
0
    def set_up(self):
        self.pointsale_suite = PointSaleSuite(self.client, self.application)
        self.inventory_suite = InventorySuite(self.client, self.application)
        self.application_suite = ApplicationSuite(self.client, self.application)

        with self.application.app_context():
            self.number_1 = Generator.generate_int()
            self.number_2 = Generator.generate_int()
            self.pointsale_id = self.pointsale_suite.create_test_pointsale("", "").id
            self.good_id_1 = self.application_suite.good(u"ЛТД", '1', '101', 8, 5.5)
            self.good_id_2 = self.application_suite.good(u"Вечерние Челны", '4', '402', 12.0, 9.7)
            self.good_id_3 = self.application_suite.good(u"WinX", '25', '107', 147.0, 123.0)
            self.good_id_4 = self.application_suite.good(u"Трансформеры", '4', '7', 120.0, 97.0)
Esempio n. 3
0
class WayBillTest(BaseTestCase):
    def set_up(self):
        self.receiver_suite = ReceiverSuite(self.client, self.application)
        self.pointsale_suite = PointSaleSuite(self.client, self.application)
        self.waybill_suite = WayBillTestSuite(self.client, self.application)

    def init_relation_models(self):
        self.receiver = self.receiver_suite.create_test_receiver()
        self.receiver_id = self.receiver.id
        self.point_1 = self.pointsale_suite.create_test_pointsale(name=u"ШШК", address=u"наб. Челны", is_central=True)
        self.point_1_id = self.point_1.id
        self.point_2 = self.pointsale_suite.create_test_pointsale(
            name=u"Одиссей", address=u"Наб. Челны, ул. Беляева, 75"
        )
        self.point_2_id = self.point_2.id
        self.point_3 = self.pointsale_suite.create_test_pointsale(
            name=u"Форт Диалог", address=u"Наб. Челны, Московский пр., 15"
        )
        self.point_3_id = self.point_3.id

        self.application_suite = ApplicationSuite(self.client, self.application)
        self.good_id = self.application_suite.good(u"XXL", "77", "114", 105.0, 86.0)
        self.good_2_id = self.application_suite.good(u"Машинка", None, None, 24.0, 21.0)
        self.good_3_id = self.application_suite.good(u"ЗОЖ", "4", "105", None, 9.5)
        self.good_4_id = self.application_suite.good(u"Мельница", None, None, 15.0, None)

        self.COUNT_GOOD_1 = 10
        self.COUNT_GOOD_4 = 5
        self.COUNT_GOOD_2 = 7

        self.items = [
            {GOOD_ATTR: self.good_id, COUNT_ATTR: self.COUNT_GOOD_1},
            {GOOD_ATTR: self.good_4_id, COUNT_ATTR: self.COUNT_GOOD_4},
        ]

        self.items_2 = [{GOOD_ATTR: self.good_2_id, COUNT_ATTR: self.COUNT_GOOD_2}]
Esempio n. 4
0
    def set_up(self):
        self.FILE_NAME = "20141020_2IAEW4.xlsx"

        self.acceptance_suite = AcceptanceSuite(self.client, self.application)

        self.pointsale_suite = PointSaleSuite(self.client, self.application)

        self.application_suite = ApplicationSuite(
            self.client, self.application)

        self.provider_suite = ProviderTestSuite(self.client, self.application)
        self.test_provider_id, _, _, _ = (
            self.provider_suite.create_test_provider())

        self.invoice_suite = MailInvoiceTestSuite(
            self.client, self.application)
        with self.application.app_context():
            pointsale = self.pointsale_suite.create_test_pointsale(
                name=u"ШШК", address=u"Наб. Челны")
            self.pointsale_id = pointsale.id
Esempio n. 5
0
class InventoryTest(BaseTestCase):

    def set_up(self):
        self.pointsale_suite = PointSaleSuite(self.client, self.application)
        self.inventory_suite = InventorySuite(self.client, self.application)
        self.application_suite = ApplicationSuite(self.client, self.application)

        with self.application.app_context():
            self.number_1 = Generator.generate_int()
            self.number_2 = Generator.generate_int()
            self.pointsale_id = self.pointsale_suite.create_test_pointsale("", "").id
            self.good_id_1 = self.application_suite.good(u"ЛТД", '1', '101', 8, 5.5)
            self.good_id_2 = self.application_suite.good(u"Вечерние Челны", '4', '402', 12.0, 9.7)
            self.good_id_3 = self.application_suite.good(u"WinX", '25', '107', 147.0, 123.0)
            self.good_id_4 = self.application_suite.good(u"Трансформеры", '4', '7', 120.0, 97.0)

    def get_pointsaleitem(self, pointsale_id, good_id):
        return PointSaleItem.query.filter(
            PointSaleItem.pointsale_id == pointsale_id,
            PointSaleItem.good_id == good_id).one()

    def get_inventoryitem(self, inventory_id, good_id):
        return InventoryItems.query.filter(
            InventoryItems.inventory_id == inventory_id,
            InventoryItems.good_id == good_id).one()

    def test_(self):
        #Кол-ва товара в накладную
        count_after_1 = 100
        count_after_2 = 67
        with self.application.app_context():
            response = self.inventory_suite.create_inventory(self.pointsale_id, self.number_1)

            self.assertEqual(response.status_code, 200)
            data = self._deserialize(response.data)
            inventory_id_1 = data['id']

            self.assertEqual(InventoryItems.query.filter(
                InventoryItems.inventory_id == inventory_id_1
            ).count(), 0)

            response = self.inventory_suite.inventory_status(inventory_id_1, IN_PROG)
            self.assertEqual(response.status_code, 200)

            self.assertEqual(InventoryItems.query.filter(
                InventoryItems.inventory_id == inventory_id_1
            ).count(), 0)

            items = [
                {COUNT_AFTER_ATTR: count_after_1, GOOD_ATTR: {GOOD_ID_ATTR: self.good_id_1}},
                {COUNT_AFTER_ATTR: count_after_2, GOOD_ATTR: {GOOD_ID_ATTR: self.good_id_2}}
            ]

            response = self.inventory_suite.update_inventory(inventory_id_1, items=items)
            self.assertEqual(response.status_code, 200)

            self.assertEqual(InventoryItems.query.filter(
                InventoryItems.inventory_id == inventory_id_1
            ).count(), 2)
            self.assertEqual(PointSaleItem.query.filter(
                PointSaleItem.pointsale_id == self.pointsale_id
            ).count(), 0)

            response = self.inventory_suite.inventory_status(inventory_id_1, VALIDATED)
            self.assertEqual(response.status_code, 200)

            self.assertEqual(InventoryItems.query.filter(
                InventoryItems.inventory_id == inventory_id_1
            ).count(), 2)
            self.assertEqual(PointSaleItem.query.filter(
                PointSaleItem.pointsale_id == self.pointsale_id
            ).count(), 2)
            pointsaleitem_1 = self.get_pointsaleitem(self.pointsale_id, self.good_id_1)
            pointsaleitem_2 = self.get_pointsaleitem(self.pointsale_id, self.good_id_2)
            self.assertEqual(pointsaleitem_1.count, count_after_1)
            self.assertEqual(pointsaleitem_2.count, count_after_2)


            response = self.inventory_suite.create_inventory(self.pointsale_id, self.number_2)
            self.assertEqual(response.status_code, 200)
            data = self._deserialize(response.data)
            inventory_id_2 = data['id']

            self.assertEqual(InventoryItems.query.filter(
                InventoryItems.inventory_id == inventory_id_2
            ).count(), 2)

            inventory_item_1 = self.get_inventoryitem(inventory_id_2, self.good_id_1)
            inventory_item_2 = self.get_inventoryitem(inventory_id_2, self.good_id_2)

            self.assertEqual(inventory_item_1.count_before, count_after_1)
            self.assertEqual(inventory_item_2.count_before, count_after_2)

            self.assertEqual(inventory_item_1.count_after, count_after_1)
            self.assertEqual(inventory_item_2.count_after, count_after_2)
Esempio n. 6
0
 def set_up(self):
     self.pointsale_suite = PointSaleSuite(self.client, self.application)
Esempio n. 7
0
class AcceptanceTest(BaseTestCase):
    def set_up(self):
        self.FILE_NAME = "20141020_2IAEW4.xlsx"

        self.acceptance_suite = AcceptanceSuite(self.client, self.application)

        self.pointsale_suite = PointSaleSuite(self.client, self.application)

        self.application_suite = ApplicationSuite(
            self.client, self.application)

        self.provider_suite = ProviderTestSuite(self.client, self.application)
        self.test_provider_id, _, _, _ = (
            self.provider_suite.create_test_provider())

        self.invoice_suite = MailInvoiceTestSuite(
            self.client, self.application)
        with self.application.app_context():
            pointsale = self.pointsale_suite.create_test_pointsale(
                name=u"ШШК", address=u"Наб. Челны")
            self.pointsale_id = pointsale.id

    def invoice_(self):
        """
        Принимаем накладную из файла FILE_NAME
        """
        self.invoice_suite.handle_invoice(
            datetime=datetime.now(), file_name=self.FILE_NAME, mail_id=1)
        return Invoice.query.first().id

    def price_to_good(self, good_id):
        return Good.query.filter(
            Good.id == good_id
        ).one().price

    def priceparish_to_good(self, good_id):
        good = Good.query.get(good_id)
        return PriceParish.query.filter(
            PriceParish.commodity_id == good.commodity_id,
            PriceParish.number_local_from == good.number_local,
            PriceParish.number_global_from == good.number_global
        )

    def invoice_count(self):
        return Invoice.query.count()

    def acceptance_count(self):
        return Acceptance.query.count()

    def acceptance_items(self, id):
        return AcceptanceItems.query.filter(
            AcceptanceItems.acceptance_id == id
        )

    def acceptance_item(self, id):
        return AcceptanceItems.query.filter(
            AcceptanceItems.id == id
        ).one()

    def pointsale_items(self, id):
        return PointSaleItem.query.filter(
            PointSaleItem.pointsale_id == id
        )

    def invoice_items(self, id):
        return InvoiceItem.query.filter(
            InvoiceItem.invoice_id == id
        )

    def success_stories_mail(self, date):
        invoice_id = self.invoice_()
        return invoice_id, self.acceptance_suite.create(
            date=date, type=MAIL, invoice_id=invoice_id,
            pointsale_id=self.pointsale_id)
Esempio n. 8
0
 def set_up(self):
     self.receiver_suite = ReceiverSuite(self.client, self.application)
     self.pointsale_suite = PointSaleSuite(self.client, self.application)
     self.waybill_suite = WayBillTestSuite(self.client, self.application)