Esempio n. 1
0
    def setUp(self):
        self.user = User.objects.create_user('user', '*****@*****.**')
        self.user.is_staff = False
        self.user.is_superuser = False
        self.user.first_name = 'Elmer'
        self.user.last_name = 'Stevens'
        self.user.save()

        self.owner = User.objects.create_user('owner', '*****@*****.**')
        self.owner.is_staff = False
        self.owner.is_superuser = False
        self.owner.first_name = 'Eric'
        self.owner.last_name = 'Brown'
        self.owner.save()

        self.category = create_category()
        self.model = create_model(category=self.category)
        self.asset = create_asset(
            sn='1111-1111-1111-1111',
            model=self.model,
            user=self.user,
            owner=self.owner,
            barcode='br-666',
            niw='niw=666',
        )

        self.software_category = SoftwareCategory(
            name='soft-cat1', asset_type=models_assets.AssetType.DC)
        self.software_category.save()

        self.manufacturer = AssetManufacturer(name='test_manufacturer')
        self.manufacturer.save()

        self.licence_type = LicenceType(name='test_licence_type')
        self.licence_type.save()

        self.property_of = AssetOwner(name="test_property")
        self.property_of.save()

        self.licence1 = Licence(
            licence_type=self.licence_type,
            software_category=self.software_category,
            manufacturer=self.manufacturer,
            property_of=self.property_of,
            number_bought=10,
            sn="test-sn",
            niw="niw-666",
            invoice_date=datetime.date(2014, 4, 28),
            invoice_no="666-999-666",
            price=1000.0,
            provider="test_provider",
            asset_type=models_assets.AssetType.DC,
        )
        self.licence1.save()
Esempio n. 2
0
    def setUp(self):
        self.user = User.objects.create_user('user', '*****@*****.**')
        self.user.is_staff = False
        self.user.is_superuser = False
        self.user.first_name = 'Elmer'
        self.user.last_name = 'Stevens'
        self.user.save()

        self.owner = User.objects.create_user('owner', '*****@*****.**')
        self.owner.is_staff = False
        self.owner.is_superuser = False
        self.owner.first_name = 'Eric'
        self.owner.last_name = 'Brown'
        self.owner.save()

        self.category = create_category()
        self.model = create_model(category=self.category)
        self.asset = create_asset(
            sn='1111-1111-1111-1111',
            model=self.model,
            user=self.user,
            owner=self.owner,
            barcode='br-666',
            niw='niw=666',
        )

        self.software_category = SoftwareCategory(
            name='soft-cat1', asset_type=AssetType.DC
        )
        self.software_category.save()

        self.manufacturer = AssetManufacturer(name='test_manufacturer')
        self.manufacturer.save()

        self.licence_type = LicenceType(name='test_licence_type')
        self.licence_type.save()

        self.property_of = AssetOwner(name="test_property")
        self.property_of.save()

        self.licence1 = Licence(
            licence_type=self.licence_type,
            software_category=self.software_category,
            manufacturer=self.manufacturer,
            property_of=self.property_of,
            number_bought=10,
            sn="test-sn",
            niw="niw-666",
            invoice_date=datetime.date(2014, 4, 28),
            invoice_no="666-999-666",
            price=1000.0,
            provider="test_provider",
            asset_type=AssetType.DC,
        )
        self.licence1.save()
Esempio n. 3
0
class TestExportRelations(TestCase):
    def setUp(self):
        self.user = User.objects.create_user('user', '*****@*****.**')
        self.user.is_staff = False
        self.user.is_superuser = False
        self.user.first_name = 'Elmer'
        self.user.last_name = 'Stevens'
        self.user.save()

        self.owner = User.objects.create_user('owner', '*****@*****.**')
        self.owner.is_staff = False
        self.owner.is_superuser = False
        self.owner.first_name = 'Eric'
        self.owner.last_name = 'Brown'
        self.owner.save()

        self.category = create_category()
        self.model = create_model(category=self.category)
        self.asset = create_asset(
            sn='1111-1111-1111-1111',
            model=self.model,
            user=self.user,
            owner=self.owner,
            barcode='br-666',
            niw='niw=666',
        )

        self.software_category = SoftwareCategory(
            name='soft-cat1', asset_type=AssetType.DC
        )
        self.software_category.save()

        self.manufacturer = AssetManufacturer(name='test_manufacturer')
        self.manufacturer.save()

        self.licence_type = LicenceType(name='test_licence_type')
        self.licence_type.save()

        self.property_of = AssetOwner(name="test_property")
        self.property_of.save()

        self.licence1 = Licence(
            licence_type=self.licence_type,
            software_category=self.software_category,
            manufacturer=self.manufacturer,
            property_of=self.property_of,
            number_bought=10,
            sn="test-sn",
            niw="niw-666",
            invoice_date=datetime.date(2014, 4, 28),
            invoice_no="666-999-666",
            price=1000.0,
            provider="test_provider",
            asset_type=AssetType.DC,
        )
        self.licence1.save()

    def test_assets_rows(self):
        rows = [item for item in get_assets_rows()]

        self.assertEqual(
            rows,
            [
                [
                    'id', 'niw', 'barcode', 'sn', 'model__category__name',
                    'model__manufacturer__name', 'model__name',
                    'user__username', 'user__first_name', 'user__last_name',
                    'owner__username', 'owner__first_name',
                    'owner__last_name', 'status', 'service_name__name',
                    'property_of', 'warehouse__name',
                ],
                [
                    1, 'niw=666', 'br-666', '1111-1111-1111-1111',
                    'Subcategory', 'Manufacturer1', 'Model1', 'user',
                    'Elmer', 'Stevens', 'owner', 'Eric', 'Brown', 1, None,
                    None, 'Warehouse',
                ],
            ]
        )

    def test_licences_rows(self):
        self.licence1.assets.add(self.asset)
        self.licence1.users.add(self.user)
        self.licence1.users.add(self.owner)
        rows = [item for item in get_licences_rows()]

        self.assertEqual(
            rows,
            [
                [
                    'niw', 'software_category', 'number_bought', 'price',
                    'invoice_date', 'invoice_no', 'id', 'barcode', 'niw',
                    'user__username', 'user__first_name', 'user__last_name',
                    'owner__username', 'owner__first_name',
                    'owner__last_name', 'username', 'first_name',
                    'last_name', 'single_cost',
                ],
                [
                    'niw-666', 'soft-cat1', '10', '1000', '2014-04-28',
                    '666-999-666', '', '', '', '', '', '', '', '', '', '', '',
                    '',
                ],
                [
                    'niw-666', 'soft-cat1', '10', '1000', '2014-04-28',
                    '666-999-666', '1', 'br-666', 'niw=666', 'user', 'Elmer',
                    'Stevens', 'owner', 'Eric', 'Brown', '', '', '', '', '',
                    '', '', '', '', '', '', '',
                ],
                [
                    'niw-666', 'soft-cat1', '10', '1000', '2014-04-28',
                    '666-999-666', '', '', '', '', '', '', '', '', '', 'user',
                    'Elmer', 'Stevens', '100',
                ],
                [
                    'niw-666', 'soft-cat1', '10', '1000', '2014-04-28',
                    '666-999-666', '', '', '', '', '', '', '', '', '', 'owner',
                    'Eric', 'Brown', '100',
                ],
            ]
        )

    def test_licences_rows_only_assigned(self):
        self.licence1.assets.add(self.asset)
        self.licence1.users.add(self.user)
        self.licence1.users.add(self.owner)
        rows = [item for item in get_licences_rows(only_assigned=True)]

        self.assertEqual(
            rows,
            [
                [
                    'niw', 'software_category', 'number_bought', 'price',
                    'invoice_date', 'invoice_no', 'id', 'barcode', 'niw',
                    'user__username', 'user__first_name', 'user__last_name',
                    'owner__username', 'owner__first_name',
                    'owner__last_name', 'username', 'first_name',
                    'last_name', 'single_cost',
                ],
                [
                    'niw-666', 'soft-cat1', '10', '1000', '2014-04-28',
                    '666-999-666', '1', 'br-666', 'niw=666', 'user', 'Elmer',
                    'Stevens', 'owner', 'Eric', 'Brown', '', '', '', '', '',
                    '', '', '', '', '', '', '',
                ],
                [
                    'niw-666', 'soft-cat1', '10', '1000', '2014-04-28',
                    '666-999-666', '', '', '', '', '', '', '', '', '',
                    'user', 'Elmer', 'Stevens', '100',
                ],
                [
                    'niw-666', 'soft-cat1', '10', '1000', '2014-04-28',
                    '666-999-666', '', '', '', '', '', '', '', '', '',
                    'owner', 'Eric', 'Brown', '100',
                ],
            ]
        )
Esempio n. 4
0
class TestExportRelations(TestCase):
    def setUp(self):
        self.user = User.objects.create_user('user', '*****@*****.**')
        self.user.is_staff = False
        self.user.is_superuser = False
        self.user.first_name = 'Elmer'
        self.user.last_name = 'Stevens'
        self.user.save()

        self.owner = User.objects.create_user('owner', '*****@*****.**')
        self.owner.is_staff = False
        self.owner.is_superuser = False
        self.owner.first_name = 'Eric'
        self.owner.last_name = 'Brown'
        self.owner.save()

        self.category = create_category()
        self.model = create_model(category=self.category)
        self.asset = create_asset(
            sn='1111-1111-1111-1111',
            model=self.model,
            user=self.user,
            owner=self.owner,
            barcode='br-666',
            niw='niw=666',
        )

        self.software_category = SoftwareCategory(
            name='soft-cat1', asset_type=models_assets.AssetType.DC)
        self.software_category.save()

        self.manufacturer = AssetManufacturer(name='test_manufacturer')
        self.manufacturer.save()

        self.licence_type = LicenceType(name='test_licence_type')
        self.licence_type.save()

        self.property_of = AssetOwner(name="test_property")
        self.property_of.save()

        self.licence1 = Licence(
            licence_type=self.licence_type,
            software_category=self.software_category,
            manufacturer=self.manufacturer,
            property_of=self.property_of,
            number_bought=10,
            sn="test-sn",
            niw="niw-666",
            invoice_date=datetime.date(2014, 4, 28),
            invoice_no="666-999-666",
            price=1000.0,
            provider="test_provider",
            asset_type=models_assets.AssetType.DC,
        )
        self.licence1.save()

    def test_assets_rows(self):
        rows = [item for item in get_assets_rows()]

        self.assertEqual(rows, [
            [
                'id',
                'niw',
                'barcode',
                'sn',
                'model__category__name',
                'model__manufacturer__name',
                'model__name',
                'user__username',
                'user__first_name',
                'user__last_name',
                'owner__username',
                'owner__first_name',
                'owner__last_name',
                'status',
                'service_name__name',
                'property_of',
                'warehouse__name',
            ],
            [
                1,
                'niw=666',
                'br-666',
                '1111-1111-1111-1111',
                'Subcategory',
                'Manufacturer1',
                'Model1',
                'user',
                'Elmer',
                'Stevens',
                'owner',
                'Eric',
                'Brown',
                1,
                None,
                None,
                'Warehouse',
            ],
        ])

    def test_licences_rows(self):
        self.licence1.assets.add(self.asset)
        self.licence1.users.add(self.user)
        self.licence1.users.add(self.owner)
        rows = [item for item in get_licences_rows()]

        self.assertEqual(rows, [
            [
                'niw',
                'software_category',
                'number_bought',
                'price',
                'invoice_date',
                'invoice_no',
                'id',
                'barcode',
                'niw',
                'user__username',
                'user__first_name',
                'user__last_name',
                'owner__username',
                'owner__first_name',
                'owner__last_name',
                'username',
                'first_name',
                'last_name',
                'single_cost',
            ],
            [
                'niw-666',
                'soft-cat1',
                '10',
                '1000',
                '2014-04-28',
                '666-999-666',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
            ],
            [
                'niw-666',
                'soft-cat1',
                '10',
                '1000',
                '2014-04-28',
                '666-999-666',
                '1',
                'br-666',
                'niw=666',
                'user',
                'Elmer',
                'Stevens',
                'owner',
                'Eric',
                'Brown',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
            ],
            [
                'niw-666',
                'soft-cat1',
                '10',
                '1000',
                '2014-04-28',
                '666-999-666',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                'user',
                'Elmer',
                'Stevens',
                '100',
            ],
            [
                'niw-666',
                'soft-cat1',
                '10',
                '1000',
                '2014-04-28',
                '666-999-666',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                'owner',
                'Eric',
                'Brown',
                '100',
            ],
        ])

    def test_licences_rows_only_assigned(self):
        self.licence1.assets.add(self.asset)
        self.licence1.users.add(self.user)
        self.licence1.users.add(self.owner)
        rows = [item for item in get_licences_rows(only_assigned=True)]

        self.assertEqual(rows, [
            [
                'niw',
                'software_category',
                'number_bought',
                'price',
                'invoice_date',
                'invoice_no',
                'id',
                'barcode',
                'niw',
                'user__username',
                'user__first_name',
                'user__last_name',
                'owner__username',
                'owner__first_name',
                'owner__last_name',
                'username',
                'first_name',
                'last_name',
                'single_cost',
            ],
            [
                'niw-666',
                'soft-cat1',
                '10',
                '1000',
                '2014-04-28',
                '666-999-666',
                '1',
                'br-666',
                'niw=666',
                'user',
                'Elmer',
                'Stevens',
                'owner',
                'Eric',
                'Brown',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
            ],
            [
                'niw-666',
                'soft-cat1',
                '10',
                '1000',
                '2014-04-28',
                '666-999-666',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                'user',
                'Elmer',
                'Stevens',
                '100',
            ],
            [
                'niw-666',
                'soft-cat1',
                '10',
                '1000',
                '2014-04-28',
                '666-999-666',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                'owner',
                'Eric',
                'Brown',
                '100',
            ],
        ])