def verify_added_command(self, name, callback, checks=None):
     if checks is None:
         verify(self.discord_client).add_command(
             arg_that(lambda command: command.name == name and command.callback == callback))
     else:
         verify(self.discord_client).add_command(
             arg_that(lambda command:
                      command.name == name and command.callback == callback and command.checks == checks))
Exemplo n.º 2
0
    with description(shredgen._shred_in_scale):
        with it('generates a random array of notes from the given scale of the given length'
                ):
            note_a = mock(shredgen.Note)
            note_b = mock(shredgen.Note)
            note_c = mock(shredgen.Note)
            scale = mock({'notes': [note_a, note_b, note_c]},
                         spec=shredgen.Scale)

            when(builtins).print(...)
            when(random).randrange(...).thenReturn(2, 1, 0, 1, 2)
            shredgen._shred_in_scale(scale, 5)

            verify(builtins).print(
                arg_that(lambda arg: arg.notes ==
                         [note_c, note_b, note_a, note_b, note_c]))

    with description(shredgen._get_scale_by_name):
        with before.each:
            self.scale_a = mock({'aliases': ['a', 'aa', 'aaa']},
                                spec=shredgen.Scale)
            self.scale_b = mock({'aliases': ['b', 'bb', 'bbb']},
                                spec=shredgen.Scale)
            self.scale_c = mock({'aliases': ['c', 'cc', 'ccc']},
                                spec=shredgen.Scale)

            when(shredgen)._get_all_scales().thenReturn(
                [self.scale_a, self.scale_b, self.scale_c])

        with it('returns the first scale whose aliases contains the given name'
                ):
Exemplo n.º 3
0
 def testShouldNotSatisfyIfPredicateReturnsFalse(self):
     self.assertFalse(arg_that(lambda arg: arg > 5).matches(1))
Exemplo n.º 4
0
 def testShouldSatisfyIfPredicateReturnsTrue(self):
     self.assertTrue(arg_that(lambda arg: arg > 5).matches(10))