def setUp(self): """Setup""" self.rule = ValuePrimitiveType() self.rule.config['strict'] = False
def setUp(self): """Setup""" super(TestResourceValuePrimitiveType, self).setUp() self.collection.register(ValuePrimitiveType())
class TestResourceValuePrimitiveTypeNonStrict(BaseRuleTestCase): """Test Primitive Value Types""" def setUp(self): """Setup""" self.rule = ValuePrimitiveType() self.rule.config['strict'] = False def test_file_positive(self): """Test Positive""" # Test Booleans self.assertEqual( len(self.rule._value_check('True', ['test'], 'Boolean', False, {})), 0) self.assertEqual( len(self.rule._value_check('False', ['test'], 'Boolean', False, {})), 0) self.assertEqual( len(self.rule._value_check(1, ['test'], 'Boolean', False, {})), 1) # Test Strings self.assertEqual( len(self.rule._value_check(1, ['test'], 'String', False, {})), 0) self.assertEqual( len(self.rule._value_check(2, ['test'], 'String', False, {})), 0) self.assertEqual( len(self.rule._value_check(True, ['test'], 'String', False, {})), 0) # Test Integer self.assertEqual( len(self.rule._value_check('1', ['test'], 'Integer', False, {})), 0) self.assertEqual( len(self.rule._value_check('1.2', ['test'], 'Integer', False, {})), 1) self.assertEqual( len(self.rule._value_check(True, ['test'], 'Integer', False, {})), 1) self.assertEqual( len(self.rule._value_check('test', ['test'], 'Integer', False, {})), 1) # Test Double self.assertEqual( len(self.rule._value_check('1', ['test'], 'Double', False, {})), 0) self.assertEqual( len(self.rule._value_check('1.2', ['test'], 'Double', False, {})), 0) self.assertEqual( len(self.rule._value_check(1, ['test'], 'Double', False, {})), 0) self.assertEqual( len(self.rule._value_check(True, ['test'], 'Double', False, {})), 1) self.assertEqual( len(self.rule._value_check('test', ['test'], 'Double', False, {})), 1) # Test Long self.assertEqual( len( self.rule._value_check(str(65536 * 65536), ['test'], 'Long', False, {})), 0) self.assertEqual( len(self.rule._value_check('1', ['test'], 'Long', False, {})), 0) self.assertEqual( len(self.rule._value_check('1.2', ['test'], 'Long', False, {})), 1) self.assertEqual( len(self.rule._value_check(1.2, ['test'], 'Long', False, {})), 1) self.assertEqual( len( self.rule._value_check(65536 * 65536, ['test'], 'Long', False, {})), 0) self.assertEqual( len(self.rule._value_check(True, ['test'], 'Long', False, {})), 1) self.assertEqual( len(self.rule._value_check('test', ['test'], 'Long', False, {})), 1) # Test Unknown type doesn't return error self.assertEqual( len(self.rule._value_check(1, ['test'], 'Unknown', False, {})), 0) self.assertEqual( len(self.rule._value_check('1', ['test'], 'Unknown', False, {})), 0) self.assertEqual( len(self.rule._value_check(True, ['test'], 'Unknown', False, {})), 0)