Exemple #1
0
 def test_invalid_apply_pattern(self):
   with self.assertRaisesRegexp(ValueError, r'The supplied apply_pattern is not a string'):
     Skip(None)
   with self.assertRaisesRegexp(ValueError, r'The supplied apply_pattern is not a string'):
     Duplicate(None, Duplicate.SKIP)
   with self.assertRaisesRegexp(ValueError, r'The supplied apply_pattern: \) is not a valid'):
     Skip(r')')
   with self.assertRaisesRegexp(ValueError, r'The supplied apply_pattern: \) is not a valid'):
     Duplicate(r')', Duplicate.SKIP)
Exemple #2
0
 def test_invalid_apply_pattern(self):
     with self.assertRaisesRegex(ValueError, r"The supplied apply_pattern is not a str"):
         Skip(None)
     with self.assertRaisesRegex(ValueError, r"The supplied apply_pattern is not a str"):
         Duplicate(None, Duplicate.SKIP)
     with self.assertRaisesRegex(ValueError, r"The supplied apply_pattern: \) is not a valid"):
         Skip(r")")
     with self.assertRaisesRegex(ValueError, r"The supplied apply_pattern: \) is not a valid"):
         Duplicate(r")", Duplicate.SKIP)
Exemple #3
0
    def test_jar_rules_field(self):
        field1 = FingerprintedField(
            JarRules(rules=[Duplicate('foo', Duplicate.SKIP)]))
        field1_same = FingerprintedField(
            JarRules(rules=[Duplicate('foo', Duplicate.SKIP)]))
        field2 = FingerprintedField(
            JarRules(rules=[Duplicate('foo', Duplicate.CONCAT)]))
        field3 = FingerprintedField(
            JarRules(rules=[Duplicate('bar', Duplicate.SKIP)]))
        field4 = FingerprintedField(
            JarRules(rules=[
                Duplicate('foo', Duplicate.SKIP),
                Duplicate('bar', Duplicate.SKIP)
            ]))
        field5 = FingerprintedField(
            JarRules(rules=[Duplicate('foo', Duplicate.SKIP),
                            Skip('foo')]))
        field6 = FingerprintedField(
            JarRules(rules=[Duplicate('foo', Duplicate.SKIP)],
                     default_dup_action=Duplicate.FAIL))
        field6_same = FingerprintedField(
            JarRules(rules=[Duplicate('foo', Duplicate.SKIP)],
                     default_dup_action=Duplicate.FAIL))
        field7 = FingerprintedField(JarRules(rules=[Skip('foo')]))
        field8 = FingerprintedField(JarRules(rules=[Skip('bar')]))
        field8_same = FingerprintedField(JarRules(rules=[Skip('bar')]))

        self.assertEquals(field1.fingerprint(), field1_same.fingerprint())
        self.assertEquals(field6.fingerprint(), field6_same.fingerprint())
        self.assertEquals(field8.fingerprint(), field8_same.fingerprint())
        self._assert_fingerprints_not_equal(
            [field1, field2, field3, field4, field5, field6, field7])
Exemple #4
0
 def test_deploy_jar_rules(self):
   target = self.make_target(':foo',
                             JvmBinary,
                             main='com.example.Foo',
                             deploy_jar_rules=JarRules([Duplicate('foo', Duplicate.SKIP)],
                                                       default_dup_action=Duplicate.FAIL))
   jar_rules = target.deploy_jar_rules
   self.assertEquals(1, len(jar_rules.rules))
   self.assertEquals('foo', jar_rules.rules[0].apply_pattern.pattern)
   self.assertEquals(repr(Duplicate.SKIP),
                     repr(jar_rules.rules[0].action))  # <object object at 0x...>
   self.assertEquals(Duplicate.FAIL, jar_rules.default_dup_action)
Exemple #5
0
 def test_duplicate_error(self):
     with self.assertRaisesRegexp(
             Duplicate.Error, r'Duplicate entry encountered for path foo'):
         raise Duplicate.Error('foo')
Exemple #6
0
 def test_bad_action(self):
     with self.assertRaisesRegexp(ValueError,
                                  r'The supplied action must be one of'):
         Duplicate('foo', None)
Exemple #7
0
 def test_jar_rule(self):
     dup_rule = Duplicate('foo', Duplicate.REPLACE)
     self.assertEquals('Duplicate(apply_pattern=foo, action=REPLACE)',
                       repr(dup_rule))
     skip_rule = Skip('foo')
     self.assertEquals('Skip(apply_pattern=foo)', repr(skip_rule))
Exemple #8
0
 def test_duplicate_error(self):
     with self.assertRaisesRegex(
             Duplicate.Error, r"Duplicate entry encountered for path foo"):
         raise Duplicate.Error("foo")
Exemple #9
0
 def test_bad_action(self):
     with self.assertRaisesRegex(ValueError,
                                 r"The supplied action must be one of"):
         Duplicate("foo", None)
Exemple #10
0
 def test_jar_rule(self):
     dup_rule = Duplicate("foo", Duplicate.REPLACE)
     self.assertEqual("Duplicate(apply_pattern=foo, action=REPLACE)",
                      repr(dup_rule))
     skip_rule = Skip("foo")
     self.assertEqual("Skip(apply_pattern=foo)", repr(skip_rule))