コード例 #1
0
ファイル: test_misc.py プロジェクト: Inboxen/Inboxen
    def test_index_page(self):
        response = self.client.get(urlresolvers.reverse("index"))
        self.assertEqual(response.status_code, 200)
        self.assertIn("Join", response.content)

        with override_settings(ENABLE_REGISTRATION=False):
            response = self.client.get(urlresolvers.reverse("index"))
            self.assertEqual(response.status_code, 200)
            self.assertNotIn("Join", response.content)
コード例 #2
0
ファイル: test_misc.py プロジェクト: Inboxen/Inboxen
    def test_index_page_logged_in(self):
        user = factories.UserFactory()
        assert self.client.login(username=user.username, password="******")
        response = self.client.get(urlresolvers.reverse("index"))
        self.assertEqual(response.status_code, 200)
        self.assertNotIn("Join", response.content)

        with override_settings(ENABLE_REGISTRATION=False):
            response = self.client.get(urlresolvers.reverse("index"))
            self.assertEqual(response.status_code, 200)
            self.assertNotIn("Join", response.content)
コード例 #3
0
    def test_liberate(self):
        """Run through all combinations of compressions and mailbox formats"""
        with override_settings(LIBERATION_PATH=self.tmp_dir):
            for storage, compression in itertools.product(LiberationForm.STORAGE_TYPES, LiberationForm.COMPRESSION_TYPES):
                form_data = {"storage_type": str(storage[0]), "compression_type": str(compression[0])}
                form = LiberationForm(self.user, data=form_data)
                self.assertTrue(form.is_valid())
                form.save()

                # delete liberation now we're done with it and refetch user
                models.Liberation.objects.all().delete()
                self.user = get_user_model().objects.get(id=self.user.id)
コード例 #4
0
    def test_sendfile(self):
        with override_settings(LIBERATION_PATH=self.tmp_dir):
            self.user.liberation.path = "test.txt"
            self.user.liberation.save()

            self.assertEqual(os.path.join(self.tmp_dir, "test.txt"), self.user.liberation.path)

            file_obj = open(self.user.liberation.path, "wb")
            file_obj.write("hello\n")
            file_obj.close()

            response = self.client.get(reverse("user-liberate-get"))
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response.content, "")
            self.assertEqual(response["Content-Type"], "application/x-gzip")
            self.assertEqual(response["Content-Disposition"], 'attachment; filename="liberated_data.tar.gz"')
            self.assertEqual(response["X-Sendfile"], os.path.join(self.tmp_dir, "test.txt"))
コード例 #5
0
 def test_liberate(self):
     with override_settings(LIBERATION_PATH=self.tmp_dir):
         form = LiberationForm(self.user, data={"storage_type": 0, "compression_type": 0})
         self.assertTrue(form.is_valid())
         form.save()