Exemplo n.º 1
0
def test_concern_level():
	concern = Concern(CRITICAL, "This is a sample catastrophic failure.")
	assert concern.level == CRITICAL
	assert unicode(concern) == "This is a sample catastrophic failure."
	assert repr(concern) == 'Concern(CRITICAL, "This is a sample catastrophic failure.")'
	
	concern = Concern(WARNING, "This is a sample warning.")
	assert concern.level == WARNING
	assert unicode(concern) == "This is a sample warning."
	assert repr(concern) == 'Concern(WARNING, "This is a sample warning.")'
Exemplo n.º 2
0
	def test_deprecated_access(self):
		inst = self.Sample.from_mongo({'field': 'foo'})
		
		with warnings.catch_warnings(record=True) as w:
			warnings.simplefilter('always')
			
			assert inst.deprecated == 'foo'
			
			assert len(w) == 1
			assert issubclass(w[-1].category, DeprecationWarning)
			assert 'via deprecated' in unicode(w[-1].message)
			assert 'xyzzy' in unicode(w[-1].message)
Exemplo n.º 3
0
    def test_deprecated_access(self):
        inst = self.Sample.from_mongo({'field': 'foo'})

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')

            assert inst.deprecated == 'foo'

            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert 'via deprecated' in unicode(w[-1].message)
            assert 'xyzzy' in unicode(w[-1].message)
Exemplo n.º 4
0
def test_concern_level():
    concern = Concern(CRITICAL, "This is a sample catastrophic failure.")
    assert concern.level == CRITICAL
    assert unicode(concern) == "This is a sample catastrophic failure."
    assert repr(
        concern
    ) == 'Concern(CRITICAL, "This is a sample catastrophic failure.")'

    concern = Concern(WARNING, "This is a sample warning.")
    assert concern.level == WARNING
    assert unicode(concern) == "This is a sample warning."
    assert repr(concern) == 'Concern(WARNING, "This is a sample warning.")'
Exemplo n.º 5
0
    def test_deprecated_assignment(self):
        inst = self.Sample()

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')

            inst.deprecated = 'bar'

            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert 'via deprecated' in unicode(w[-1].message)
            assert 'xyzzy' in unicode(w[-1].message)

        assert inst.__data__ == {'field': 'bar'}
Exemplo n.º 6
0
	def test_deprecated_assignment(self):
		inst = self.Sample()
		
		with warnings.catch_warnings(record=True) as w:
			warnings.simplefilter('always')
			
			inst.deprecated = 'bar'
			
			assert len(w) == 1
			assert issubclass(w[-1].category, DeprecationWarning)
			assert 'via deprecated' in unicode(w[-1].message)
			assert 'xyzzy' in unicode(w[-1].message)
		
		assert inst.__data__ == {'field': 'bar'}
Exemplo n.º 7
0
 def test_raises(self):
     try:
         self.raises.validate(None)
     except Concern as e:
         assert unicode(e) == "Oh my no."
     else:
         assert False, "Failed to raise a Concern."
Exemplo n.º 8
0
	def test_raises(self):
		try:
			self.raises.validate(None)
		except Concern as e:
			assert unicode(e) == "Oh my no."
		else:
			assert False, "Failed to raise a Concern."
Exemplo n.º 9
0
	def _do(self, validator):
		assert validator.validate([1, 27, 42]) == [1, 27, 42]
		
		try:
			validator.validate([1, 2, 3])
		except Concern as e:
			assert unicode(e).startswith("Value does not contain: ")
		else:
			assert False, "Failed to raise a Concern."
Exemplo n.º 10
0
    def _do(self, validator):
        assert validator.validate([1, 27, 42]) == [1, 27, 42]

        try:
            validator.validate([1, 2, 3])
        except Concern as e:
            assert unicode(e).startswith("Value does not contain: ")
        else:
            assert False, "Failed to raise a Concern."
Exemplo n.º 11
0
def do_deprecation(value):
	cls, dst = value
	
	with warnings.catch_warnings(record=True) as w:
		warnings.simplefilter('always')
		
		cls()
		
		assert len(w) == 1, "Only one warning should be raised."
		assert issubclass(w[-1].category, DeprecationWarning), "Warning must be a DeprecationWarning."
		assert dst in unicode(w[-1].message), "Warning should mention correct class to use."
Exemplo n.º 12
0
def do_deprecation(value):
    cls, dst = value

    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter('always')

        cls()

        assert len(w) == 1, "Only one warning should be raised."
        assert issubclass(
            w[-1].category,
            DeprecationWarning), "Warning must be a DeprecationWarning."
        assert dst in unicode(
            w[-1].message), "Warning should mention correct class to use."
Exemplo n.º 13
0
def test_depreciated_validation_import():
	with warnings.catch_warnings(record=True) as w:
		warnings.simplefilter('always')
		
		import marrow.schema.validation
		import marrow.schema.validation.base
		import marrow.schema.validation.compound
		import marrow.schema.validation.date
		import marrow.schema.validation.geo
		import marrow.schema.validation.network
		import marrow.schema.validation.pattern
		import marrow.schema.validation.testing
		import marrow.schema.validation.util
		
		assert len(w) == 1, "Only one warning should be raised."
		assert issubclass(w[-1].category, DeprecationWarning), "Warning must be DeprecationWarning."
		assert 'marrow.schema.validate' in unicode(w[-1].message), "Warning should mention correct module to import."
Exemplo n.º 14
0
def test_depreciated_validation_import():
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter('always')

        import marrow.schema.validation
        import marrow.schema.validation.base
        import marrow.schema.validation.compound
        import marrow.schema.validation.date
        import marrow.schema.validation.geo
        import marrow.schema.validation.network
        import marrow.schema.validation.pattern
        import marrow.schema.validation.testing
        import marrow.schema.validation.util

        assert len(w) == 1, "Only one warning should be raised."
        assert issubclass(
            w[-1].category,
            DeprecationWarning), "Warning must be DeprecationWarning."
        assert 'marrow.schema.validate' in unicode(
            w[-1].message), "Warning should mention correct module to import."
Exemplo n.º 15
0
def test_basic_concern_text_replacement():
    concern = Concern("{who} has failed me for the {times} time.",
                      who="Bob Dole",
                      times="last")
    assert unicode(concern) == "Bob Dole has failed me for the last time."
Exemplo n.º 16
0
 def test_operator_invert(self):
     assert unicode(Sample.generic) == ~Sample.generic == 'generic'
Exemplo n.º 17
0
	def test_concern(self):
		try:
			self.transform('x')
		except Concern as e:
			assert self.direction in unicode(e)
			assert 'invalid literal' in unicode(e)
Exemplo n.º 18
0
	def test_native_conversion(self, Sample):
		inst = Sample.from_mongo({'field': '/foo'})
		value = inst.field
		assert isinstance(value, _Path)
		assert unicode(value) == '/foo'
Exemplo n.º 19
0
def test_basic_concern_text():
	concern = Concern("This is a sample failure.")
	assert unicode(concern) == "This is a sample failure."
Exemplo n.º 20
0
	def test_operator_invert(self):
		assert unicode(Sample.generic) == ~Sample.generic == 'generic'
Exemplo n.º 21
0
def test_basic_concern_positional_replacement():
	concern = Concern("{0} has failed me for the {1} time.", "Bob Dole", "last")
	assert unicode(concern) == "Bob Dole has failed me for the last time."
Exemplo n.º 22
0
	def test_s(self):
		assert unicode(Sample.array.S) == 'field_name.$'
Exemplo n.º 23
0
def test_basic_concern_text_replacement():
	concern = Concern("{who} has failed me for the {times} time.", who="Bob Dole", times="last")
	assert unicode(concern) == "Bob Dole has failed me for the last time."
Exemplo n.º 24
0
def test_basic_concern_text():
    concern = Concern("This is a sample failure.")
    assert unicode(concern) == "This is a sample failure."
Exemplo n.º 25
0
	def test_embedded(self):
		assert unicode(Sample.embed.name) == 'embed.name'
Exemplo n.º 26
0
 def test_embedded(self):
     assert unicode(Sample.embed.name) == 'embed.name'
Exemplo n.º 27
0
	def test_cast_string(self, Sample):
		inst = Sample('5832223f927cc6c1a10609f7')
		
		assert isinstance(inst.__data__['field'], oid)
		assert unicode(inst.field) == '5832223f927cc6c1a10609f7'
Exemplo n.º 28
0
def test_basic_concern_positional_replacement():
    concern = Concern("{0} has failed me for the {1} time.", "Bob Dole",
                      "last")
    assert unicode(concern) == "Bob Dole has failed me for the last time."
Exemplo n.º 29
0
 def test_s(self):
     assert unicode(Sample.array.S) == 'field_name.$'