예제 #1
0
def main():
    global _host, _port, _port2
    parser = OptionParser()
    parser.add_option("-d", "--debug", action="store_true", dest="debug", default=False,
                      help="logging level DEBUG")

    parser.add_option("--host", dest="host", default="localhost")
    parser.add_option("--port", dest="port", default=17890, type="int")
    parser.add_option("--port2", dest="port2", default=17891, type="int")

    opts, args = parser.parse_args()

    if opts.debug:
        logging.basicConfig(level=logging.DEBUG)
    logging.basicConfig(level=logging.INFO)

    _host = opts.host
    _port = opts.port
    _port2 = opts.port2

    unittest_main()
예제 #2
0
# -*- coding: utf-8 -*-
############################################################################
#
# Copyright © 2015 OnlineGroups.net and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
############################################################################
from __future__ import absolute_import, unicode_literals
from unittest import TestSuite, main as unittest_main
from gs.profile.email.base.tests.emailaddress import TestCheckAddress

testCases = (TestCheckAddress, )


def load_tests(loader, tests, pattern):
    suite = TestSuite()
    for testClass in testCases:
        tests = loader.loadTestsFromTestCase(testClass)
        suite.addTests(tests)
    return suite

if __name__ == '__main__':
    unittest_main()
예제 #3
0
        self.ssh_client = establish_connect(self.master_ip, 'hduser', '',
                                   MASTER_SSH_PORT)
    def tearDown(self):
        self.ssh_client.close();
        os.system('rm ' + FILE_RUN_PI)

    def run_pi(self, pi_map, pi_sec):
        '''Runs a pi job'''
        #hduser_pass = get_hduser_pass()
        logging.log(REPORT, ' Running pi job')
        command = '/usr/local/hadoop/bin/hadoop jar' \
                  ' /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar pi ' + \
                  str(pi_map)+' '+str(pi_sec)
        exec_command(self.ssh_client, command)
        line = check_string(FILE_RUN_PI, "Estimated value of Pi is")
        return float(line[25:])


    def test_run_pi_2_10000(self):
        expected = 3.14280000000000000000;
        returned = self.run_pi(2, 10000);
        self.assertEqual(returned, expected);

    def test_run_pi_10_1000000(self):
        expected = 3.14158440000000000000;
        returned = self.run_pi(10, 1000000);
        self.assertEqual(returned, expected);

if __name__ == "__main__":
    unittest_main();
예제 #4
0
        self.assertIn(b'Led Zeppelin III', result.data)

    @mock.patch('pymongo.collection.Collection.insert_one')
    def test_submit_album(self, mock_insert):
        """Test submitting a new album."""
        result = self.client.post('/albums', data=sample_form_data)

        self.assertEqual(result.status, '302 FOUND')
        mock_insert.assert_called_with(sample_album)

    @mock.patch('pymongo.collection.Collection.update_one')
    def test_update_album(self, mock_update):
        result = self.client.post(f'/albums/{sample_album_id}',
                                  data=sample_form_data)

        self.assertEqual(result.status, '302 FOUND')
        mock_update.assert_called_with({'_id': sample_album_id},
                                       {'$set': sample_album})

    @mock.patch('pymongo.collection.Collection.delete_one')
    def test_delete_album(self, mock_delete):
        form_data = {'_method': 'DELETE'}
        result = self.client.post(f'/albums/{sample_album_id}/delete',
                                  data=form_data)
        self.assertEqual(result.status, '302 FOUND')
        mock_delete.assert_called_with({'_id': sample_album_id})


if __name__ == '__main__':
    unittest_main()