示例#1
0
文件: tests.py 项目: tovmeod/anaf
 def test_model_item_servicing(self):
     "Test item servicing model"
     obj = ItemServicing(name='test')
     obj.save()
     self.assertEquals('test', obj.name)
     self.assertNotEquals(obj.id, None)
     obj.delete()
示例#2
0
    def setUp(self):
        self.group, created = Group.objects.get_or_create(name='test')
        self.user, created = DjangoUser.objects.get_or_create(
            username=self.username)
        self.user.set_password(self.password)
        self.user.save()
        perspective, created = Perspective.objects.get_or_create(
            name='default')
        perspective.set_default_user()
        perspective.save()
        ModuleSetting.set('default_perspective', perspective.id)

        self.type = ItemType(name='test')
        self.type.set_default_user()
        self.type.save()

        self.status = ItemStatus(name='test')
        self.status.set_default_user()
        self.status.save()

        self.field = ItemField(name='test', label='test', field_type='text')
        self.field.set_default_user()
        self.field.save()

        self.item = Item(name='test', item_type=self.type, status=self.status)
        self.item.set_default_user()
        self.item.save()

        self.value = ItemValue(field=self.field, item=self.item)
        self.value.save()

        self.servicing = ItemServicing(name='test')
        self.servicing.set_default_user()
        self.servicing.save()
示例#3
0
def service_record_add(request, response_format='html'):
    "New service_record form"

    if not request.user.profile.is_admin('anaf.infrastructure'):
        return user_denied(
            request,
            message=
            "You don't have administrator access to the Infrastructure module")

    service_record = ItemServicing()

    if request.POST:
        if 'cancel' not in request.POST:
            form = ServiceRecordForm(request.user.profile, service_record,
                                     request.POST)
            if form.is_valid():
                record = form.save(request)
                return HttpResponseRedirect(
                    reverse('infrastructure_service_record_view',
                            args=[record.id]))
        else:
            return HttpResponseRedirect(
                reverse('infrastructure_service_record_index'))
    else:
        form = ServiceRecordForm(request.user.profile, service_record)

    context = _get_default_context(request)
    context.update({'service_record': service_record, 'form': form})

    return render_to_response('infrastructure/service_record_add',
                              context,
                              context_instance=RequestContext(request),
                              response_format=response_format)
示例#4
0
文件: tests.py 项目: tovmeod/anaf
    def setUp(self):
        self.group, created = Group.objects.get_or_create(name='test')
        self.user, created = DjangoUser.objects.get_or_create(username=self.username)
        self.user.set_password(self.password)
        self.user.save()
        perspective, created = Perspective.objects.get_or_create(name='default')
        perspective.set_default_user()
        perspective.save()
        ModuleSetting.set('default_perspective', perspective.id)

        self.type = ItemType(name='test')
        self.type.set_default_user()
        self.type.save()

        self.status = ItemStatus(name='test')
        self.status.set_default_user()
        self.status.save()

        self.field = ItemField(
            name='test', label='test', field_type='text')
        self.field.set_default_user()
        self.field.save()

        self.item = Item(
            name='test', item_type=self.type, status=self.status)
        self.item.set_default_user()
        self.item.save()

        self.value = ItemValue(field=self.field, item=self.item)
        self.value.save()

        self.servicing = ItemServicing(name='test')
        self.servicing.set_default_user()
        self.servicing.save()
示例#5
0
 def test_model_item_servicing(self):
     "Test item servicing model"
     obj = ItemServicing(name='test')
     obj.save()
     self.assertEquals('test', obj.name)
     self.assertNotEquals(obj.id, None)
     obj.delete()
示例#6
0
class InfrastructureViewsTest(TestCase):
    username = "******"
    password = "******"

    def setUp(self):
        self.group, created = Group.objects.get_or_create(name='test')
        self.user, created = DjangoUser.objects.get_or_create(
            username=self.username)
        self.user.set_password(self.password)
        self.user.save()
        perspective, created = Perspective.objects.get_or_create(
            name='default')
        perspective.set_default_user()
        perspective.save()
        ModuleSetting.set('default_perspective', perspective.id)

        self.type = ItemType(name='test')
        self.type.set_default_user()
        self.type.save()

        self.status = ItemStatus(name='test')
        self.status.set_default_user()
        self.status.save()

        self.field = ItemField(name='test', label='test', field_type='text')
        self.field.set_default_user()
        self.field.save()

        self.item = Item(name='test', item_type=self.type, status=self.status)
        self.item.set_default_user()
        self.item.save()

        self.value = ItemValue(field=self.field, item=self.item)
        self.value.save()

        self.servicing = ItemServicing(name='test')
        self.servicing.set_default_user()
        self.servicing.save()

    ######################################
    # Testing views when user is logged in
    ######################################
    def test_index_login(self):
        "Test index page with login at /infrastructure/"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure'))
        self.assertEquals(response.status_code, 200)

    def test_index_infrastructure_login(self):
        "Test index page with login at /infrastructure/index/"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure_index'))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_index_owned(self):
        "Test index page with login at /infrastructure/owned/"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure_index_owned'))
        self.assertEquals(response.status_code, 200)

    # Type
    def test_infrastructure_type_add(self):
        "Test index page with login at /infrastructure/type/add/"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure_type_add'))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_type_view(self):
        "Test index page with login at /infrastructure/type/view/<type_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_type_view', args=[self.type.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_type_edit(self):
        "Test index page with login at /infrastructure/type/edit/<type_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_type_edit', args=[self.type.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_type_delete(self):
        "Test index page with login at /infrastructure/type/delete/<type_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_type_delete', args=[self.type.id]))
        self.assertEquals(response.status_code, 200)

    # Field
    def test_infrastructure_field_add(self):
        "Test index page with login at /infrastructure/field/add/"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure_field_add'))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_field_view(self):
        "Test index page with login at /infrastructure/field/view/<field_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_field_view', args=[self.field.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_field_edit(self):
        "Test index page with login at /infrastructure/field/edit/<field_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_field_edit', args=[self.field.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_field_del(self):
        "Test index page with login at /infrastructure/field/delete/<field_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_field_delete', args=[self.field.id]))
        self.assertEquals(response.status_code, 200)

    # Status
    def test_infrastructure_status_add(self):
        "Test index page with login at /infrastructure/status/add/"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure_status_add'))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_status_view(self):
        "Test index page with login at /infrastructure/status/view/<status_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_status_view', args=[self.status.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_status_edit(self):
        "Test index page with login at /infrastructure/status/edit/<status_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_status_edit', args=[self.status.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_status_del(self):
        "Test index page with login at /infrastructure/status/delete/<status_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_status_delete', args=[self.status.id]))
        self.assertEquals(response.status_code, 200)

    # Item
    def test_infrastructure_item_add(self):
        "Test index page with login at /infrastructure/item/add/"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure_item_add'))
        self.assertEquals(response.status_code, 200)

    def test_infr_item_add_typed(self):
        "Test index page with login at /infrastructure/item/add/<type_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_item_add_typed', args=[self.type.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_item_view(self):
        "Test index page with login at /infrastructure/item/view/<item_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_item_view', args=[self.item.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_item_edit(self):
        "Test index page with login at /infrastructure/item/edit/<item_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_item_edit', args=[self.item.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_item_del(self):
        "Test index page with login at /infrastructure/item/delete/<item_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_item_delete', args=[self.item.id]))
        self.assertEquals(response.status_code, 200)

    # Service Record
    def test_infr_service_record_index(self):
        "Test index page with login at /infrastructure/service_record/index/"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_service_record_index'))
        self.assertEquals(response.status_code, 200)

    def test_infr_service_record_add(self):
        "Test index page with login at /infrastructure/service_record/add/"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_service_record_add'))
        self.assertEquals(response.status_code, 200)

    def test_infr_service_record_view(self):
        "Test index page with login at /infrastructure/service_record/view/<service_record_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_service_record_view',
                    args=[self.servicing.id]))
        self.assertEquals(response.status_code, 200)

    def test_infr_service_record_edit(self):
        "Test index page with login at /infrastructure/service_record/edit/<service_record_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_service_record_edit',
                    args=[self.servicing.id]))
        self.assertEquals(response.status_code, 200)

    def test_infr_service_record_delete(self):
        "Test index page with login at /infrastructure/service_record/delete/<service_record_id>"
        response = self.client.post('/accounts/login', {
            'username': self.username,
            'password': self.password
        })
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_service_record_delete',
                    args=[self.servicing.id]))
        self.assertEquals(response.status_code, 200)

    ######################################
    # Testing views when user is not logged in
    ######################################
    def test_index(self):
        "Testing /infrastructure/"
        response = self.client.get('/infrastructure/')
        # Redirects as unauthenticated
        self.assertRedirects(response, reverse('user_login'))

    def test_index_infrastructure_out(self):
        "Testing /infrastructure/index/"
        response = self.client.get(reverse('infrastructure_index'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_index_owned_out(self):
        "Testing /infrastructure/owned/"
        response = self.client.get(reverse('infrastructure_index_owned'))
        self.assertRedirects(response, reverse('user_login'))

    # Type
    def test_infrastructure_type_add_out(self):
        "Testing /infrastructure/type/add/"
        response = self.client.get(reverse('infrastructure_type_add'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_type_view_out(self):
        "Testing /infrastructure/type/view/<type_id>"
        response = self.client.get(
            reverse('infrastructure_type_view', args=[self.type.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_type_edit_out(self):
        "Testing /infrastructure/type/edit/<type_id>"
        response = self.client.get(
            reverse('infrastructure_type_edit', args=[self.type.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_type_delete_out(self):
        "Testing /infrastructure/type/delete/<type_id>"
        response = self.client.get(
            reverse('infrastructure_type_delete', args=[self.type.id]))
        self.assertRedirects(response, reverse('user_login'))

    # Field
    def test_infrastructure_field_add_out(self):
        "Testing /infrastructure/field/add/"
        response = self.client.get(reverse('infrastructure_field_add'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_field_view_out(self):
        "Testing /infrastructure/field/view/<field_id>"
        response = self.client.get(
            reverse('infrastructure_field_view', args=[self.field.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_field_edit_out(self):
        "Testing /infrastructure/field/edit/<field_id>"
        response = self.client.get(
            reverse('infrastructure_field_edit', args=[self.field.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_field_del_out(self):
        "Testing /infrastructure/field/delete/<field_id>"
        response = self.client.get(
            reverse('infrastructure_field_delete', args=[self.field.id]))
        self.assertRedirects(response, reverse('user_login'))

    # Status
    def test_infrastructure_status_add_out(self):
        "Testing /infrastructure/status/add/"
        response = self.client.get(reverse('infrastructure_status_add'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_status_view_out(self):
        "Testing /infrastructure/status/view/<status_id>"
        response = self.client.get(
            reverse('infrastructure_status_view', args=[self.status.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_status_edit_out(self):
        "Testing /infrastructure/status/edit/<status_id>"
        response = self.client.get(
            reverse('infrastructure_status_edit', args=[self.status.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_status_del_out(self):
        "Testing /infrastructure/status/delete/<status_id>"
        response = self.client.get(
            reverse('infrastructure_status_delete', args=[self.status.id]))
        self.assertRedirects(response, reverse('user_login'))

    # Item
    def test_infrastructure_item_add_out(self):
        "Testing /infrastructure/item/add/"
        response = self.client.get(reverse('infrastructure_item_add'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infr_item_add_typed_out(self):
        "Testing /infrastructure/item/add/<type_id>"
        response = self.client.get(
            reverse('infrastructure_item_add_typed', args=[self.type.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_item_view_out(self):
        "Testing /infrastructure/item/view/<item_id>"
        response = self.client.get(
            reverse('infrastructure_item_view', args=[self.item.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_item_edit_out(self):
        "Testing /infrastructure/item/edit/<item_id>"
        response = self.client.get(
            reverse('infrastructure_item_edit', args=[self.item.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_item_del_out(self):
        "Testing /infrastructure/item/delete/<item_id>"
        response = self.client.get(
            reverse('infrastructure_item_delete', args=[self.item.id]))
        self.assertRedirects(response, reverse('user_login'))

    # Service Record
    def test_infr_service_record_index_out(self):
        "Testing /infrastructure/service_record/index/"
        response = self.client.get(
            reverse('infrastructure_service_record_index'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infr_service_record_add_out(self):
        "Testing /infrastructure/service_record/add/"
        response = self.client.get(
            reverse('infrastructure_service_record_add'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infr_service_record_view_out(self):
        "Testing /infrastructure/service_record/view/<service_record_id>"
        response = self.client.get(
            reverse('infrastructure_service_record_view',
                    args=[self.servicing.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infr_service_record_edit_out(self):
        "Testing /infrastructure/service_record/edit/<service_record_id>"
        response = self.client.get(
            reverse('infrastructure_service_record_edit',
                    args=[self.servicing.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infr_service_record_delete_out(self):
        "Testing /infrastructure/service_record/delete/<service_record_id>"
        response = self.client.get(
            reverse('infrastructure_service_record_delete',
                    args=[self.servicing.id]))
        self.assertRedirects(response, reverse('user_login'))
示例#7
0
文件: tests.py 项目: tovmeod/anaf
class InfrastructureViewsTest(TestCase):
    username = "******"
    password = "******"

    def setUp(self):
        self.group, created = Group.objects.get_or_create(name='test')
        self.user, created = DjangoUser.objects.get_or_create(username=self.username)
        self.user.set_password(self.password)
        self.user.save()
        perspective, created = Perspective.objects.get_or_create(name='default')
        perspective.set_default_user()
        perspective.save()
        ModuleSetting.set('default_perspective', perspective.id)

        self.type = ItemType(name='test')
        self.type.set_default_user()
        self.type.save()

        self.status = ItemStatus(name='test')
        self.status.set_default_user()
        self.status.save()

        self.field = ItemField(
            name='test', label='test', field_type='text')
        self.field.set_default_user()
        self.field.save()

        self.item = Item(
            name='test', item_type=self.type, status=self.status)
        self.item.set_default_user()
        self.item.save()

        self.value = ItemValue(field=self.field, item=self.item)
        self.value.save()

        self.servicing = ItemServicing(name='test')
        self.servicing.set_default_user()
        self.servicing.save()

    ######################################
    # Testing views when user is logged in
    ######################################
    def test_index_login(self):
        "Test index page with login at /infrastructure/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure'))
        self.assertEquals(response.status_code, 200)

    def test_index_infrastructure_login(self):
        "Test index page with login at /infrastructure/index/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure_index'))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_index_owned(self):
        "Test index page with login at /infrastructure/owned/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure_index_owned'))
        self.assertEquals(response.status_code, 200)

    # Type
    def test_infrastructure_type_add(self):
        "Test index page with login at /infrastructure/type/add/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure_type_add'))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_type_view(self):
        "Test index page with login at /infrastructure/type/view/<type_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_type_view', args=[self.type.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_type_edit(self):
        "Test index page with login at /infrastructure/type/edit/<type_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_type_edit', args=[self.type.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_type_delete(self):
        "Test index page with login at /infrastructure/type/delete/<type_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_type_delete', args=[self.type.id]))
        self.assertEquals(response.status_code, 200)

    # Field
    def test_infrastructure_field_add(self):
        "Test index page with login at /infrastructure/field/add/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure_field_add'))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_field_view(self):
        "Test index page with login at /infrastructure/field/view/<field_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_field_view', args=[self.field.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_field_edit(self):
        "Test index page with login at /infrastructure/field/edit/<field_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_field_edit', args=[self.field.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_field_del(self):
        "Test index page with login at /infrastructure/field/delete/<field_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_field_delete', args=[self.field.id]))
        self.assertEquals(response.status_code, 200)

    # Status
    def test_infrastructure_status_add(self):
        "Test index page with login at /infrastructure/status/add/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure_status_add'))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_status_view(self):
        "Test index page with login at /infrastructure/status/view/<status_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_status_view', args=[self.status.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_status_edit(self):
        "Test index page with login at /infrastructure/status/edit/<status_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_status_edit', args=[self.status.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_status_del(self):
        "Test index page with login at /infrastructure/status/delete/<status_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_status_delete', args=[self.status.id]))
        self.assertEquals(response.status_code, 200)

    # Item
    def test_infrastructure_item_add(self):
        "Test index page with login at /infrastructure/item/add/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('infrastructure_item_add'))
        self.assertEquals(response.status_code, 200)

    def test_infr_item_add_typed(self):
        "Test index page with login at /infrastructure/item/add/<type_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_item_add_typed', args=[self.type.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_item_view(self):
        "Test index page with login at /infrastructure/item/view/<item_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_item_view', args=[self.item.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_item_edit(self):
        "Test index page with login at /infrastructure/item/edit/<item_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_item_edit', args=[self.item.id]))
        self.assertEquals(response.status_code, 200)

    def test_infrastructure_item_del(self):
        "Test index page with login at /infrastructure/item/delete/<item_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_item_delete', args=[self.item.id]))
        self.assertEquals(response.status_code, 200)

    # Service Record
    def test_infr_service_record_index(self):
        "Test index page with login at /infrastructure/service_record/index/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_service_record_index'))
        self.assertEquals(response.status_code, 200)

    def test_infr_service_record_add(self):
        "Test index page with login at /infrastructure/service_record/add/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_service_record_add'))
        self.assertEquals(response.status_code, 200)

    def test_infr_service_record_view(self):
        "Test index page with login at /infrastructure/service_record/view/<service_record_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_service_record_view', args=[self.servicing.id]))
        self.assertEquals(response.status_code, 200)

    def test_infr_service_record_edit(self):
        "Test index page with login at /infrastructure/service_record/edit/<service_record_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_service_record_edit', args=[self.servicing.id]))
        self.assertEquals(response.status_code, 200)

    def test_infr_service_record_delete(self):
        "Test index page with login at /infrastructure/service_record/delete/<service_record_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password})
        self.assertRedirects(response, '/')
        response = self.client.get(
            reverse('infrastructure_service_record_delete', args=[self.servicing.id]))
        self.assertEquals(response.status_code, 200)

    ######################################
    # Testing views when user is not logged in
    ######################################
    def test_index(self):
        "Testing /infrastructure/"
        response = self.client.get('/infrastructure/')
        # Redirects as unauthenticated
        self.assertRedirects(response, reverse('user_login'))

    def test_index_infrastructure_out(self):
        "Testing /infrastructure/index/"
        response = self.client.get(reverse('infrastructure_index'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_index_owned_out(self):
        "Testing /infrastructure/owned/"
        response = self.client.get(reverse('infrastructure_index_owned'))
        self.assertRedirects(response, reverse('user_login'))

    # Type
    def test_infrastructure_type_add_out(self):
        "Testing /infrastructure/type/add/"
        response = self.client.get(reverse('infrastructure_type_add'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_type_view_out(self):
        "Testing /infrastructure/type/view/<type_id>"
        response = self.client.get(
            reverse('infrastructure_type_view', args=[self.type.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_type_edit_out(self):
        "Testing /infrastructure/type/edit/<type_id>"
        response = self.client.get(
            reverse('infrastructure_type_edit', args=[self.type.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_type_delete_out(self):
        "Testing /infrastructure/type/delete/<type_id>"
        response = self.client.get(
            reverse('infrastructure_type_delete', args=[self.type.id]))
        self.assertRedirects(response, reverse('user_login'))

    # Field
    def test_infrastructure_field_add_out(self):
        "Testing /infrastructure/field/add/"
        response = self.client.get(reverse('infrastructure_field_add'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_field_view_out(self):
        "Testing /infrastructure/field/view/<field_id>"
        response = self.client.get(
            reverse('infrastructure_field_view', args=[self.field.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_field_edit_out(self):
        "Testing /infrastructure/field/edit/<field_id>"
        response = self.client.get(
            reverse('infrastructure_field_edit', args=[self.field.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_field_del_out(self):
        "Testing /infrastructure/field/delete/<field_id>"
        response = self.client.get(
            reverse('infrastructure_field_delete', args=[self.field.id]))
        self.assertRedirects(response, reverse('user_login'))

    # Status
    def test_infrastructure_status_add_out(self):
        "Testing /infrastructure/status/add/"
        response = self.client.get(reverse('infrastructure_status_add'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_status_view_out(self):
        "Testing /infrastructure/status/view/<status_id>"
        response = self.client.get(
            reverse('infrastructure_status_view', args=[self.status.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_status_edit_out(self):
        "Testing /infrastructure/status/edit/<status_id>"
        response = self.client.get(
            reverse('infrastructure_status_edit', args=[self.status.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_status_del_out(self):
        "Testing /infrastructure/status/delete/<status_id>"
        response = self.client.get(
            reverse('infrastructure_status_delete', args=[self.status.id]))
        self.assertRedirects(response, reverse('user_login'))

    # Item
    def test_infrastructure_item_add_out(self):
        "Testing /infrastructure/item/add/"
        response = self.client.get(reverse('infrastructure_item_add'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infr_item_add_typed_out(self):
        "Testing /infrastructure/item/add/<type_id>"
        response = self.client.get(
            reverse('infrastructure_item_add_typed', args=[self.type.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_item_view_out(self):
        "Testing /infrastructure/item/view/<item_id>"
        response = self.client.get(
            reverse('infrastructure_item_view', args=[self.item.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_item_edit_out(self):
        "Testing /infrastructure/item/edit/<item_id>"
        response = self.client.get(
            reverse('infrastructure_item_edit', args=[self.item.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infrastructure_item_del_out(self):
        "Testing /infrastructure/item/delete/<item_id>"
        response = self.client.get(
            reverse('infrastructure_item_delete', args=[self.item.id]))
        self.assertRedirects(response, reverse('user_login'))

    # Service Record
    def test_infr_service_record_index_out(self):
        "Testing /infrastructure/service_record/index/"
        response = self.client.get(
            reverse('infrastructure_service_record_index'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infr_service_record_add_out(self):
        "Testing /infrastructure/service_record/add/"
        response = self.client.get(
            reverse('infrastructure_service_record_add'))
        self.assertRedirects(response, reverse('user_login'))

    def test_infr_service_record_view_out(self):
        "Testing /infrastructure/service_record/view/<service_record_id>"
        response = self.client.get(
            reverse('infrastructure_service_record_view', args=[self.servicing.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infr_service_record_edit_out(self):
        "Testing /infrastructure/service_record/edit/<service_record_id>"
        response = self.client.get(
            reverse('infrastructure_service_record_edit', args=[self.servicing.id]))
        self.assertRedirects(response, reverse('user_login'))

    def test_infr_service_record_delete_out(self):
        "Testing /infrastructure/service_record/delete/<service_record_id>"
        response = self.client.get(
            reverse('infrastructure_service_record_delete', args=[self.servicing.id]))
        self.assertRedirects(response, reverse('user_login'))