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
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'")
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)
def test_endswith(self): assert_endswith("foobar", "bar")
def assert_endswith(self, text, prefix): warnings.warn("Use django_tools.unittest_utils.assertments.assert_endswith!", DeprecationWarning) assertments.assert_endswith(text, prefix)
def test_manage_bin(self): assert_endswith(text=self.manage_bin, suffix="/bin/manage")
def test_for_runners_path(self): assert_endswith(text=self.for_runners_bin, suffix="/bin/for_runners")