Ejemplo n.º 1
0
    def test_status_field(self):
        self.assertEqual(AssetStatus.name_from_id(self.third_asset.status), "used")
        url = "/assets/dc/search?status=%s" % AssetStatus.used.id
        content = self.client.get(url)
        self.assertEqual(content.status_code, 200)

        rows_from_table = content.context_data["bob_page"].object_list
        self.assertEqual(len(rows_from_table), 1)

        # Test if search form find correct data
        self.assertItemsEqual([AssetStatus.name_from_id(asset.status) for asset in rows_from_table], ["used"])
        self.assertEqual(rows_from_table[0].sn, "1236-1236-1236-1236")
Ejemplo n.º 2
0
    def test_status_field(self):
        self.assertEqual(AssetStatus.name_from_id(self.third_asset.status),
                         'used')
        url = '/assets/dc/search?status=%s' % AssetStatus.used.id
        content = self.client.get(url)
        self.assertEqual(content.status_code, 200)

        rows_from_table = content.context_data['bob_page'].object_list
        self.assertEqual(len(rows_from_table), 1)

        # Test if search form find correct data
        self.assertItemsEqual([
            AssetStatus.name_from_id(asset.status, )
            for asset in rows_from_table
        ], ['used'])
        self.assertEqual(rows_from_table[0].sn, '1236-1236-1236-1236')
Ejemplo n.º 3
0
    def test_display_data_in_table(self):
        get_search_page = self.client.get('/assets/dc/search')
        self.assertEqual(get_search_page.status_code, 200)

        # Test if data from database are displayed in correct row.
        first_table_row = get_search_page.context_data['bob_page'][0]
        self.assertEqual(self.asset, first_table_row)
        self.assertItemsEqual(
            [
                first_table_row.barcode,
                first_table_row.invoice_no,
                first_table_row.order_no,
                unicode(first_table_row.invoice_date),
                first_table_row.sn,
                AssetType.name_from_id(first_table_row.type),
                AssetStatus.name_from_id(first_table_row.status),
                first_table_row.model.name,
                first_table_row.warehouse.name,
            ],
            [
                u'123456789',
                u'Invoice #1',
                u'Order #1',
                u'2001-01-01',
                u'0000-0000-0000-0000',
                u'Model1',
                'data_center',
                'new',
                'Warehouse',
            ]
        )
Ejemplo n.º 4
0
    def test_display_data_in_table(self):
        get_search_page = self.client.get('/assets/dc/search')
        self.assertEqual(get_search_page.status_code, 200)

        # Test if data from database are displayed in correct row.
        first_table_row = get_search_page.context_data['bob_page'][0]
        self.assertEqual(self.asset, first_table_row)
        self.assertItemsEqual([
            first_table_row.barcode,
            first_table_row.invoice_no,
            first_table_row.order_no,
            unicode(first_table_row.invoice_date),
            first_table_row.sn,
            AssetType.name_from_id(first_table_row.type),
            AssetStatus.name_from_id(first_table_row.status),
            first_table_row.model.name,
            first_table_row.warehouse.name,
        ], [
            u'123456789',
            u'Invoice #1',
            u'Order #1',
            u'2001-01-01',
            u'0000-0000-0000-0000',
            u'Model1',
            'data_center',
            'new',
            'Warehouse',
        ])