예제 #1
0
    def test_EntryDelete_no_login(self):

        entry_to_delete = EntryF.create(category=self.category,
                                        version=self.version)
        response = self.client.post(
            reverse('entry-delete', kwargs={'pk': entry_to_delete.id}))
        self.assertEqual(response.status_code, 302)
예제 #2
0
    def setUp(self):
        """
        Setup before each test

        We force the locale to en otherwise it will use
        the locale of the host running the tests and we
        will get unpredictable results / 404s
        """

        self.client = Client()
        self.client.post('/set_language/', data={'language': 'en'})
        logging.disable(logging.CRITICAL)
        self.project = ProjectF.create(name='testproject')
        self.version = VersionF.create(project=self.project, name='1.0.1')
        self.category = CategoryF.create(project=self.project,
                                         name='testcategory')
        self.entry = EntryF.create(category=self.category,
                                   version=self.version,
                                   title='testentry',
                                   approved=True)
        self.user = UserF.create(**{
            'username': '******',
            'password': '******',
            'is_staff': True
        })
예제 #3
0
    def setUp(self):
        """
        Setup before each test

        We force the locale to en otherwise it will use
        the locale of the host running the tests and we
        will get unpredictable results / 404s
        """

        self.client = Client()
        self.client.post(
                '/set_language/', data={'language': 'en'})
        logging.disable(logging.CRITICAL)
        self.project = ProjectF.create(
                name='testproject')
        self.version = VersionF.create(
                project=self.project,
                name='1.0.1')
        self.category = CategoryF.create(
                project=self.project,
                name='testcategory')
        self.entry = EntryF.create(
            category=self.category,
            version=self.version,
            title='testentry',
            approved=True)
        self.user = UserF.create(**{
            'username': '******',
            'password': '******',
            'is_staff': True
        })
예제 #4
0
    def test_Entry_read(self):
        """
        Tests Entry model read
        """
        model = EntryF.create(title=u'Custom Entry')

        self.assertTrue(model.title == 'Custom Entry')
        self.assertTrue(model.slug == 'custom-entry')
예제 #5
0
    def test_EntryDelete_no_login(self):

        entry_to_delete = EntryF.create(
            category=self.category,
            version=self.version)
        response = self.client.post(reverse('entry-delete', kwargs={
            'pk': entry_to_delete.id
        }))
        self.assertEqual(response.status_code, 302)
예제 #6
0
    def test_Entry_read(self):
        """
        Tests Entry model read
        """
        my_model = EntryF.create(
            title=u'Custom Entry'
        )

        self.assertTrue(my_model.title == 'Custom Entry')
        self.assertTrue(my_model.slug == 'custom-entry')
예제 #7
0
    def test_Entry_delete(self):
        """
        Tests Entry model delete
        """
        my_model = EntryF.create()

        my_model.delete()

        #check if deleted
        self.assertTrue(my_model.pk is None)
예제 #8
0
    def test_Entry_delete(self):
        """
        Tests Entry model delete
        """
        model = EntryF.create()

        model.delete()

        # check if deleted
        self.assertTrue(model.pk is None)
예제 #9
0
    def test_Entry_create(self):
        """
        Tests Entry model creation
        """
        my_model = EntryF.create()

        #check if PK exists
        self.assertTrue(my_model.pk is not None)

        #check if name exists
        self.assertTrue(my_model.title is not None)
예제 #10
0
    def test_Entry_create(self):
        """
        Tests Entry model creation
        """
        model = EntryF.create()

        # check if PK exists
        self.assertTrue(model.pk is not None)

        # check if name exists
        self.assertTrue(model.title is not None)
예제 #11
0
 def test_EntryDelete_no_login(self):
     my_client = Client()
     entry_to_delete = EntryF.create(
         category=self.my_category,
         version=self.my_version)
     my_response = my_client.post(reverse('entry-delete', kwargs={
         'slug': entry_to_delete.slug,
         'project_slug': self.my_version.project.slug,
         'version_slug': self.my_version.slug
     }))
     self.assertEqual(my_response.status_code, 302)
예제 #12
0
    def test_EntryDelete_with_login(self):

        entry_to_delete = EntryF.create(
            category=self.category,
            version=self.version)
        self.client.login(username='******', password='******')
        response = self.client.post(reverse('entry-delete', kwargs={
            'pk': entry_to_delete.id
        }), {})
        self.assertRedirects(response, reverse('entry-list', kwargs={
            'project_slug': self.project.slug,
            'version_slug': self.version.slug
        }))
예제 #13
0
    def test_EntryDelete_with_login(self):

        entry_to_delete = EntryF.create(category=self.category,
                                        version=self.version)
        self.client.login(username='******', password='******')
        response = self.client.post(
            reverse('entry-delete', kwargs={'pk': entry_to_delete.id}), {})
        self.assertRedirects(
            response,
            reverse('entry-list',
                    kwargs={
                        'project_slug': self.project.slug,
                        'version_slug': self.version.slug
                    }))
예제 #14
0
 def setUp(self):
     """
     Setup before each test
     """
     logging.disable(logging.CRITICAL)
     self.my_project = ProjectF.create()
     self.my_version = VersionF.create(project=self.my_project)
     self.my_category = CategoryF.create(project=self.my_project)
     self.my_entry = EntryF.create(
         category=self.my_category,
         version=self.my_version)
     self.my_user = UserF.create(**{
         'username': '******',
         'password': '******',
         'is_staff': True
     })
예제 #15
0
    def test_Entry_update(self):
        """
        Tests Entry model update
        """
        my_model = EntryF.create()
        new_model_data = {
            'name': u'New Entry Name',
            'description': u'New description',
            'approved': False,
            'private': True,
        }
        my_model.__dict__.update(new_model_data)
        my_model.save()

        #check if updated
        for key, val in new_model_data.items():
            self.assertEqual(my_model.__dict__.get(key), val)
예제 #16
0
    def test_Entry_update(self):
        """
        Tests Entry model update
        """
        model = EntryF.create()
        new_model_data = {
            'name': u'New Entry Name',
            'description': u'New description',
            'approved': False,
            'private': True,
        }
        model.__dict__.update(new_model_data)
        model.save()

        # check if updated
        for key, val in new_model_data.items():
            self.assertEqual(model.__dict__.get(key), val)