Example #1
0
    def test_mulitvalues_behaviour(self):
        """
        - get add license request data d1

        - add licence with duplicated inv. nb. in data
        - assert error occured

        - edit licence with duplicated sn in data
        - assert licence was added
        """
        request_data = self.get_license_form_data()
        request_data.update(dict(
            # required, irrelevant data here
            parent='',
            sn=','.join([LicenceFactory.build().niw] * 3),
        ))
        url = reverse('add_licence')

        request_data['niw'] = ','.join([LicenceFactory.build().niw] * 3)
        response = self.client.post(url, request_data)
        self.assertFormError(
            response, 'form', 'niw', 'There are duplicates in field.',
        )
        request_data.update(dict(
            niw=','.join([LicenceFactory.build().niw for idx in xrange(3)]),
        ))
        response = self.client.post(url, request_data)
        self.assertEqual(response.status_code, 302)
Example #2
0
 def get_license_form_data(self):
     license = LicenceFactory()
     url = reverse('edit_licence', kwargs={
         'licence_id': license.id,
     })
     form_data = self.get_object_form_data(url, 'form')
     license.delete()
     return form_data
Example #3
0
class TestModelLicences(TestCase):
    def setUp(self):
        self.licence = LicenceFactory()

    def test_remarks(self):
        """Remarks field is in model?"""
        self.licence.remarks = 'a' * 512
        self.licence.save()

        self.assertEqual(self.licence.remarks, 'a' * 512)

    def test_service_name(self):
        old_service = self.licence.service_name
        self.licence.service_name = ServiceFactory()
        self.licence.save()

        self.assertNotEqual(old_service, self.licence.service_name)
Example #4
0
class TestModelLicences(TestCase):
    def setUp(self):
        self.licence = LicenceFactory()

    def test_remarks(self):
        """Remarks field is in model?"""
        self.licence.remarks = 'a' * 512
        self.licence.save()

        self.assertEqual(self.licence.remarks, 'a' * 512)

    def test_service_name(self):
        old_service = self.licence.service_name
        self.licence.service_name = ServiceFactory()
        self.licence.save()

        self.assertNotEqual(old_service, self.licence.service_name)
Example #5
0
 def test_bulk_edit_max_items_at_once(self):
     """Scenario:
      - user selected more than MAX_BULK_EDIT_SIZE
      - user should see message error
     """
     number_of_selected_items = settings.MAX_BULK_EDIT_SIZE + 1
     licences = [LicenceFactory() for _ in range(number_of_selected_items)]
     url = reverse('licence_bulkedit')
     url += '?' + '&'.join(['select={}'.format(obj.pk) for obj in licences])
     response = self.client.get(url)
     self.assertEqual(response.status_code, 302)
Example #6
0
    def test_asset(self):
        asset = AssetFactory(pk=123)
        history = asset.get_history()
        self.assertEqual(0, history.count())

        asset.sn = '123'
        asset.save()
        self.assertEqual(1, history.count())

        asset.sn = '1233'
        asset.save()
        self.assertEqual(2, history.count())

        licence = LicenceFactory()
        history = licence.get_history()
        licence.save()
        licence.save()
        self.assertEqual(0, history.count())

        for i in xrange(5):
            asset = AssetFactory()
            licence.assets.add(asset)
            self.assertEqual(i + 1, history.count())
Example #7
0
 def setUp(self):
     self.licence = LicenceFactory()
Example #8
0
 def setUp(self):
     self.licence = LicenceFactory()
Example #9
0
 def _create_licences(self, custom_values={}):
     [LicenceFactory(**custom_values) for _ in xrange(4)]
Example #10
0
 def _assign_licence_to_assets(self):
     for asset in self.assets:
         asset.licence_set.add(LicenceFactory())