def test_get_abs_location_returns_rel_loc_if_static_root_not_none(self): static_root = factory.getRandomString() self.patch(settings, 'STATIC_ROOT', static_root) rel_location = os.path.join( factory.getRandomString(), factory.getRandomString()) expected_location = os.path.join(static_root, rel_location) self.assertEqual( expected_location, get_absolute_location(location=rel_location))
def test_get_abs_location_returns_rel_loc_if_in_dev_environment(self): rel_location = os.path.join(factory.make_string(), factory.make_string()) rel_location_base = os.path.join( os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'static') expected_location = os.path.join(rel_location_base, rel_location) self.assertEqual(expected_location, get_absolute_location(location=rel_location))
def test_get_abs_location_returns_rel_loc_if_not_in_dev_environment(self): self.useFixture(ImportErrorFixture('maastesting', 'root')) static_root = factory.make_string() self.patch(settings, 'STATIC_ROOT', static_root) rel_location = os.path.join(factory.make_string(), factory.make_string()) expected_location = os.path.join(static_root, rel_location) observed = get_absolute_location(location=rel_location) self.assertEqual(expected_location, observed)
def test_get_abs_location_returns_rel_loc_if_static_root_is_none(self): self.patch(settings, 'STATIC_ROOT', None) rel_location = os.path.join( factory.getRandomString(), factory.getRandomString()) rel_location_base = os.path.join( os.path.dirname(os.path.dirname(__file__)), 'static') expected_location = os.path.join(rel_location_base, rel_location) self.assertEqual( expected_location, get_absolute_location(location=rel_location))
def test_get_abs_location_returns_absolute_location_if_not_None(self): abs_location = '%s%s' % (os.path.sep, factory.make_string()) self.assertEqual(abs_location, get_absolute_location(location=abs_location))
def test_get_abs_location_returns_absolute_location_if_not_None(self): abs_location = '%s%s' % (os.path.sep, factory.getRandomString()) self.assertEqual( abs_location, get_absolute_location(location=abs_location))