Ejemplo n.º 1
0
 def step1_setupConfigTest(self):
     '''
     Make a copy of the sc.json file to save user configs
     '''
     sc = SC()
     # store smtp information for later testing
     self.username = sc.smtp_username
     self.password = sc.smtp_password
     sc.make_backup()
Ejemplo n.º 2
0
def main():
    sc = SC()
    port = int(SMTP_PORT)
    print(f'Starting mock SMTP server on port {SMTP_PORT}')

    server = TestSmtpServer(('127.0.0.0', port), None)
    asyncore.loop()
Ejemplo n.º 3
0
 def stop():
     # Send the http request to shutdown the server
     sc = SC()
     try:
         urllib2.urlopen('http://localhost:{}/shutdown'.format(
             sc.dict['web_port']))
     except Exception:
         # web server is not running
         pass
Ejemplo n.º 4
0
 def step3_SCConfigSet(self):
     '''
     Set the smtp username and password
     '''
     sc_conf_path = os.path.join(sc_dir(), 'app', 'sc_config.py')
     test_user = '******'
     test_pass = '******'
     os.system('python {} --smtpu {} --smtpp {}'.format(
         sc_conf_path, test_user, test_pass))
     sc = SC()
     self.assertEqual(sc.smtp_username, test_user)
     self.assertEqual(sc.smtp_password, test_pass)
Ejemplo n.º 5
0
 def step2_SCConfigClear(self):
     '''
     Clear the smtp username and password
     '''
     sc_conf_path = os.path.join(sc_dir(), 'app', 'sc_config.py')
     test_user = '******'
     test_pass = '******'
     os.system('python {} --smtpu {} --smtpp {}'.format(
         sc_conf_path, test_user, test_pass))
     sc = SC()
     self.assertEqual(sc.smtp_username, test_user)
     self.assertEqual(sc.smtp_password, test_pass)
Ejemplo n.º 6
0
def main():
    sc = SC()
    port = sc.dict['SMTP']['port']
    server = TestSmtpServer(('', port), None)
    asyncore.loop()
Ejemplo n.º 7
0
path = os.path.dirname(os.path.abspath(__file__))
path = path.split(os.sep)
del path[-1]
del path[-1]
path += ['shakecast']

app_dir = os.path.normpath(os.sep.join(path))
if app_dir not in sys.path:
    sys.path += [app_dir]

from shakecast.app.server import Server
from shakecast.ui import UI
from shakecast.app.util import SC

path += ['logs', 'sc-service.log']
sc = SC()
if sc.dict['Logging']['level'] == 'info':
    log_level = logging.INFO
elif sc.dict['Logging']['level'] == 'debug':
    log_level = logging.DEBUG

logging.basicConfig(
    filename=os.path.normpath(os.sep.join(path)),
    level=log_level,
    format='%(asctime)s: [ShakeCast Server] %(levelname)-7.7s %(message)s')


class ShakecastServer(win32serviceutil.ServiceFramework):
    _svc_name_ = "sc_server"
    _svc_display_name_ = "ShakeCast Server"
Ejemplo n.º 8
0
    def step5_SCRevert(self):
        sc = SC()
        sc.revert()

        self.assertEqual(sc.smtp_username, self.username)
        self.assertEqual(sc.smtp_password, self.password)
Ejemplo n.º 9
0
 def step4_SCSave(self):
     sc = SC()
     if sc.validate(sc.json) is True:
         sc.save(sc.json)
Ejemplo n.º 10
0
 def test_initSC(self):
     sc = SC()