コード例 #1
0
    def test_foobar_is_true(self):
        # setup
        foobar = Foobar()

        # exercise
        result = foobar.i_am_true()

        # verify
        self.assertTrue(result)
コード例 #2
0
    def test_is_unhappy(self, sys_mock):
        """This is mocking the complete library. Try that in Java."""
        # setup
        foobar = Foobar()

        # exercise
        foobar._i_am_happy(False)

        # Verify
        self.assertEqual(1, sys_mock.exit.call_count)
コード例 #3
0
    def test_is_happy(self):
        """This is testing a private method"""
        # setup
        foobar = Foobar()

        # exercise
        result = foobar._i_am_happy(True)

        # verify
        self.assertEqual("happy", result)
コード例 #4
0
    def test_list_buckets(self):
        """This is replacing a private member with a mock"""
        # setup
        foobar = Foobar()
        s3_mock = MagicMock()
        s3_mock.list_buckets.return_value = {'bucketa', 'bucketb'}
        foobar.s3 = s3_mock

        # exercise
        result = foobar._list_buckets()

        # verify
        self.assertIn('bucketa', result)
コード例 #5
0
ファイル: PyFoobar.py プロジェクト: renero/bridge
 def init(self):
     self = super(PyFoobar, self).init()
     self.py = Foobar()
     return self
コード例 #6
0
ファイル: PyFoobar.py プロジェクト: renero/bridge
class PyFoobar(NSObject):
    def init(self):
        self = super(PyFoobar, self).init()
        self.py = Foobar()
        return self

    @objc.signature('@@:')
    #-> index
    def index(self):
        return self.py.logfile

    @objc.signature('v@:')
    #-> dump
    def dump(self):
        print self.py.logfile
    
    @objc.signature('v@:')
    #-> printKeys
    def printKeys(self):
        print "%d elements" % (len(self.py.logfile))
        for i in self.py.logfile:
            print i

    @objc.signature('@@:i')
    #-> getCounters
    def getCounters_(self,row):
        print "Asking for array at %d position" % (row)
        counters = self.py.logfile[row]['value']
        print counters
        return counters


    #------------------------------------------------------------------------------------------------------
    # ObjC Protocol
    #------------------------------------------------------------------------------------------------------
    
    #@objc.signature('i@:')
    @objc.signature('i@:iB')
    #def count_SelectedElement_withFlag(self, selectedElement, isIndexTable):
    def count_withFlag_(self, selectedElement, isIndexTable):
        return self.py.count(selectedElement, isIndexTable)
    
    #
    # The number of underscores corresponds to the number of arguments
    # Refer to the PyObjC for more information on how to decrypt thist
    # f*ckin' convention.
    #
    # On the signature (NO DOCS)
    # void = v
    # Object = @
    # self = @:
    # integer = i
    # unsigned int = I
    # Boolean = B
    #
    @objc.signature('@@:@iiB')
    def stringAtColumn_andRow_selectedElement_withFlag_(self, column, row, selectedElement, isIndexTable):
        return self.py.object_at_columnrow(column, row, selectedElement, isIndexTable)
    
    @objc.signature('@@:i')
    def stringAtIndex_(self, index):
        return self.py.string_at_index(index)