Beispiel #1
0
    def test_log_sqlite_db(self):
        self._mock_sqlite_connection()

        with patch('os.path.isfile', return_value=True) as isfile_mock:
            self.collector._log_sqlite_db(
                '/Users/test/sqlite/db/panama_papers')

        isfile_mock.assert_called_once_with(
            '/Users/test/sqlite/db/panama_papers')
        self.connect_mock.assert_called_once_with(
            '/Users/test/sqlite/db/panama_papers')
        T.assert_truthy(self.conn_mock.cursor.called)

        expected_execute_calls = [
            call('SELECT * from sqlite_master WHERE type = "table"'),
            call('SELECT * from fruits'),
            call('SELECT * from veggies'),
        ]
        T.assert_equals(
            expected_execute_calls, self.cursor_mock.execute.call_args_list)

        expected_log_dict_calls = [
            call({
                'name': 'apple',
                'color': 'green',
            }),
            call({
                'name': 'banana',
                'color': 'yellow',
            }),
            call({
                'name': 'cherry',
                'color': 'red',
            }),
            call({
                'name': 'carrot',
                'color': 'orange',
            }),
            call({
                'name': 'radish',
                'color': 'red',
            }),
        ]
        T.assert_equals(
            expected_log_dict_calls, self.mock_log_dict.call_args_list)
Beispiel #2
0
 def test_normalize_buffer_to_unicode(self):
     b = buffer("this is buffer")
     val = osxcollector._normalize_val(b)
     T.assert_truthy(isinstance(val, unicode))
Beispiel #3
0
 def test_assert_truthy_with_msg(self):
     with assertions.assert_raises_exactly(AssertionError, 'my_msg'):
         assert_truthy(0, message='my_msg')
Beispiel #4
0
 def test_normalize_unicode(self):
     u = '\u20AC'
     val = osxcollector._normalize_val(u)
     T.assert_truthy(isinstance(val, unicode))
Beispiel #5
0
 def test_assert_truthy_two_args_raises(self):
     with assertions.assert_raises(TypeError):
         assert_truthy('foo', 'bar')
Beispiel #6
0
 def test_assert_truthy_garbage_kwarg_raises(self):
     with assertions.assert_raises(TypeError):
         assert_truthy('foo', bar='baz')
Beispiel #7
0
 def test_assert_truthy(self):
     assert_truthy(1)
     assert_truthy('False')
     assert_truthy([0])
     assert_truthy([''])
     assert_truthy(('', ))
     assert_truthy({'a': 0})
Beispiel #8
0
 def test_assert_truthy_with_msg(self):
     with assertions.assert_raises_exactly(AssertionError, 'my_msg'):
         assert_truthy(0, message='my_msg')
Beispiel #9
0
 def test_assert_truthy_garbage_kwarg_raises(self):
     with assertions.assert_raises(TypeError):
         assert_truthy('foo', bar='baz')
Beispiel #10
0
 def test_assert_truthy_two_args_raises(self):
     with assertions.assert_raises(TypeError):
         assert_truthy('foo', 'bar')
Beispiel #11
0
 def test_assert_truthy(self):
     assert_truthy(1)
     assert_truthy('False')
     assert_truthy([0])
     assert_truthy([''])
     assert_truthy(('',))
     assert_truthy({'a': 0})