コード例 #1
0
    def test_create_temp_filer_info_image(self):
        assert_endswith(
            settings.MEDIA_ROOT,
            "/django_tools_test_project/media"
        )
        user = self.login(usertype="normal")

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")  # trigger all warnings

            filer_info_image = ImageDummy(
                width=500, height=300, format="png"
            ).create_temp_filer_info_image(
                text="A test image", user=user
            )
            assert_pformat_equal(filer_info_image.width, 500)
            assert_pformat_equal(filer_info_image.height, 300)

            assert_pformat_equal(filer_info_image.size, 1791)
            self.assertIn(".png", filer_info_image.path)

            path = filer_info_image.path
            path = path.replace("-", "_")  # e.g.: /django-tools/ -> /django_tools/

            self.assertIn("/django_tools_test_project/media/filer_public/", path)

            assert_pformat_equal(len(w), 0)  # No warnings created
コード例 #2
0
    def test_not_endswith(self):

        with self.assertRaises(AssertionError) as cm:
            assert_endswith("foo", "bar")

        assert_pformat_equal(cm.exception.args[0],
                             "'foo' doesn't ends with 'bar'")
コード例 #3
0
ファイル: test_mockup.py プロジェクト: renren-25/django-tools
    def test_create_temp_filer_info_image(self):
        assert_endswith(settings.MEDIA_ROOT,
                        "/django_tools_test_project/media")
        user = self.login(usertype="normal")

        filer_info_image = ImageDummy(
            width=500, height=300,
            format="png").create_temp_filer_info_image(text="A test image",
                                                       user=user)
        assert_pformat_equal(filer_info_image.width, 500)
        assert_pformat_equal(filer_info_image.height, 300)

        assert_pformat_equal(filer_info_image.size, 1791)
        self.assertIn(".png", filer_info_image.path)

        path = filer_info_image.path
        path = path.replace("-", "_")  # e.g.: /django-tools/ -> /django_tools/

        self.assertIn("/django_tools_test_project/media/filer_public/", path)
コード例 #4
0
 def test_endswith(self):
     assert_endswith("foobar", "bar")
コード例 #5
0
 def assert_endswith(self, text, prefix):
     warnings.warn("Use django_tools.unittest_utils.assertments.assert_endswith!", DeprecationWarning)
     assertments.assert_endswith(text, prefix)
コード例 #6
0
 def test_manage_bin(self):
     assert_endswith(text=self.manage_bin, suffix="/bin/manage")
コード例 #7
0
 def test_for_runners_path(self):
     assert_endswith(text=self.for_runners_bin, suffix="/bin/for_runners")
コード例 #8
0
    def test_not_endswith(self):

        with self.assertRaises(AssertionError) as cm:
            assert_endswith("foo", "bar")

        assert_pformat_equal(cm.exception.args[0], "'foo' doesn't ends with 'bar'")
コード例 #9
0
 def test_endswith(self):
     assert_endswith("foobar", "bar")