コード例 #1
0
    def test_create_config_false_load_configs(self):

        os.environ['CONFIG_PATH'] = ""
        os.environ['SMTP_HOST'] = 'b'
        os.environ['SMTP_PORT'] = 'b'
        os.environ['SMTP_USERNAME'] = '******'
        os.environ['SMTP_PASSWORD'] = '******'

        os.environ['DATE_RESTRICT_FLAG'] = 'b'
        os.environ['DATE_RESTRICT_WEEKDAY'] = 'b'
        os.environ['DATE_RESTRICT_HOUR'] = 'b'

        os.environ['SENDMAIL_FLAG'] = 'b'
        os.environ['TOGGL_TOKEN'] = 'b'
        os.environ['TOGGL_USER_AGENT'] = 'b'
        os.environ['TOGGL_WORKSPACE_ID'] = 'b'

        os.environ['ADMIN_EMAIL'] = '["b"]'

        os.environ['STAFF_EMAIL_ROLE_STAFF_RESOURCE'] = 'b'
        os.environ['STAFF_EMAIL_ROLE_GROUP_LEADS'] = 'b'
        os.environ['STAFF_FROM_EMAIL'] = 'b'

        argsv = []
        argsv.append("name")

        loadup = Loadup(argsv)
        configs = loadup.create_config(argsv)

        self.assertEqual('b', configs['smtp']['host'])
コード例 #2
0
    def test_generate_config_from_environment_invalid_env(self):
        os.environ['CONFIG_PATH'] = ""
        os.environ['SMTP_HOST'] = 'b'
        os.environ['SMTP_PORT'] = 'b'
        os.environ['SMTP_USERNAME'] = '******'
        os.environ['SMTP_PASSWORD'] = '******'

        os.environ['DATE_RESTRICT_FLAG'] = 'b'
        os.environ['DATE_RESTRICT_WEEKDAY'] = 'b'
        os.environ['DATE_RESTRICT_HOUR'] = 'b'

        os.environ['SENDMAIL_FLAG'] = 'b'
        os.environ['TOGGL_USER_AGENT'] = 'b'
        os.environ['TOGGL_WORKSPACE_ID'] = 'b'

        os.environ['ADMIN_EMAIL'] = '["b"]'

        os.environ['STAFF_EMAIL_ROLE_STAFF_RESOURCE'] = 'b'
        os.environ['STAFF_EMAIL_ROLE_GROUP_LEADS'] = 'b'
        os.environ['STAFF_FROM_EMAIL'] = 'b'

        argsv = []
        argsv.append("name")
        argsv.append("tests/test_config.yml")

        loadup = Loadup(argsv)
        system_exit = False
        try:
            configs = loadup.generate_config_from_environment()
        except SystemExit:
            system_exit = True

        self.assertTrue(system_exit)
コード例 #3
0
    def test_create_config_false_load_configs(self):

        os.environ['CONFIG_PATH'] = ""
        os.environ['SMTP_HOST'] = 'b'
        os.environ['SMTP_PORT'] = 'b'
        os.environ['SMTP_USERNAME'] = '******'
        os.environ['SMTP_PASSWORD'] = '******'

        os.environ['DATE_RESTRICT_FLAG'] = 'b'
        os.environ['DATE_RESTRICT_WEEKDAY'] = 'b'
        os.environ['DATE_RESTRICT_HOUR'] = 'b'

        os.environ['SENDMAIL_FLAG'] = 'b'
        os.environ['TOGGL_TOKEN'] = 'b'
        os.environ['TOGGL_USER_AGENT'] = 'b'
        os.environ['TOGGL_WORKSPACE_ID'] = 'b'


        os.environ['ADMIN_EMAIL_1'] = 'b'
        os.environ['ADMIN_EMAIL_2'] = 'b'

        os.environ['STAFF_EMAIL_ROLE_STAFF_RESOURCE'] = 'b'
        os.environ['STAFF_EMAIL_ROLE_GROUP_LEADS'] = 'b'
        os.environ['STAFF_FROM_EMAIL'] = 'b'

        argsv = []
        argsv.append("name")

        loadup = Loadup(argsv)
        configs = loadup.create_config(argsv)

        self.assertEqual('b', configs['smtp']['host'])
コード例 #4
0
    def test_generate_config_from_environment_invalid_env(self):
        os.environ['CONFIG_PATH'] = ""
        os.environ['SMTP_HOST'] = 'b'
        os.environ['SMTP_PORT'] = 'b'
        os.environ['SMTP_USERNAME'] = '******'
        os.environ['SMTP_PASSWORD'] = '******'

        os.environ['DATE_RESTRICT_FLAG'] = 'b'
        os.environ['DATE_RESTRICT_WEEKDAY'] = 'b'
        os.environ['DATE_RESTRICT_HOUR'] = 'b'

        os.environ['SENDMAIL_FLAG'] = 'b'
        os.environ['TOGGL_USER_AGENT'] = 'b'
        os.environ['TOGGL_WORKSPACE_ID'] = 'b'


        os.environ['ADMIN_EMAIL_1'] = 'b'
        os.environ['ADMIN_EMAIL_2'] = 'b'

        os.environ['STAFF_EMAIL_ROLE_STAFF_RESOURCE'] = 'b'
        os.environ['STAFF_EMAIL_ROLE_GROUP_LEADS'] = 'b'
        os.environ['STAFF_FROM_EMAIL'] = 'b'

        argsv = []
        argsv.append("name")
        argsv.append("tests/test_config.yml")

        loadup = Loadup(argsv)
        system_exit = False
        try:
            configs = loadup.generate_config_from_environment()
        except SystemExit:
            system_exit = True

        self.assertTrue(system_exit)
コード例 #5
0
    def test_load_configs_no_flag_invalid_config_path(self):

        os.environ['CONFIG_PATH'] = "This is an invalid path"
        argsv = []

        loadup = Loadup(argsv)
        configs_yml_stream = loadup.load_configs(argsv)

        self.assertEqual(False, configs_yml_stream)
コード例 #6
0
    def test_load_configs_no_flag_invalid_config_path(self):

        os.environ['CONFIG_PATH'] = "This is an invalid path"
        argsv = []

        loadup = Loadup(argsv)
        configs_yml_stream = loadup.load_configs(argsv)

        self.assertEqual(False, configs_yml_stream)
コード例 #7
0
    def test_load_configs_no_flag_valid_config_path(self):

        os.environ['CONFIG_PATH'] = 'tests/test_config.yml'
        argsv = []

        loadup = Loadup(argsv)
        configs_yml_stream = loadup.load_configs(argsv)
        result = yaml.load(configs_yml_stream)

        self.assertEqual('a', result['smtp']['host'])
コード例 #8
0
    def test_load_configs_no_flag_valid_config_path(self):

        os.environ['CONFIG_PATH'] = 'tests/test_config.yml'
        argsv = []

        loadup = Loadup(argsv)
        configs_yml_stream = loadup.load_configs(argsv)
        result = yaml.load(configs_yml_stream)

        self.assertEqual('a', result['smtp']['host'])
コード例 #9
0
    def test_load_configs_invalid_flag_no_config_path(self):

        os.environ['CONFIG_PATH'] = ""

        argsv = []
        argsv.append("name")
        argsv.append("tests/thisfiledoesn'texist.yml")

        loadup = Loadup(argsv)
        configs_yml_stream = loadup.load_configs(argsv)

        self.assertEqual(False, configs_yml_stream)
コード例 #10
0
    def test_load_configs_invalid_flag_no_config_path(self):

        os.environ['CONFIG_PATH'] = ""

        argsv = []
        argsv.append("name")
        argsv.append("tests/thisfiledoesn'texist.yml")

        loadup = Loadup(argsv)
        configs_yml_stream = loadup.load_configs(argsv)

        self.assertEqual(False, configs_yml_stream)
コード例 #11
0
    def test_load_configs_valid_flag_no_config_path(self):

        os.environ['CONFIG_PATH'] = ""

        argsv = []
        argsv.append("name")
        argsv.append("tests/test_config.yml")

        loadup = Loadup(argsv)
        configs_yml_stream = loadup.load_configs(argsv)
        result = yaml.load(configs_yml_stream)

        self.assertEqual('a', result['smtp']['host'])
コード例 #12
0
    def test_load_configs_valid_flag_no_config_path(self):

        os.environ['CONFIG_PATH'] = ""

        argsv = []
        argsv.append("name")
        argsv.append("tests/test_config.yml")

        loadup = Loadup(argsv)
        configs_yml_stream = loadup.load_configs(argsv)
        result = yaml.load(configs_yml_stream)

        self.assertEqual('a', result['smtp']['host'])
コード例 #13
0
ファイル: check.py プロジェクト: Muserk/alma-time-monitor
import logging

from toggle_client_api.api_client import TogglClientApi
from libs.invoke_workdays.workday import WorkDay
from libs.invoke_users.invoke_users import User
from libs.invoke_loadup.invoke_loadup import Loadup
from libs.date_functions import get_day_previous_week, convert_milliseconds_to_hours

# log_level = logging.DEBUG
log_level = logging.WARN
logging.basicConfig(level=log_level)

# Load Configs
import yaml

loadup = Loadup(sys.argv)
loadup.initialize_configs()
configs = loadup.get_config()
logging.debug(configs)
loadup.date_restriction(configs)

# Toggl API Config
settings = {
    'token': configs['togglAPI']['token'],
    'user_agent': configs['togglAPI']['user_agent'],
    "workspace_id": configs['togglAPI']['workspace_id']
}
api = TogglClientApi(settings)

user_list_response = api.get_workspace_members(settings['workspace_id'])
last_monday = get_day_previous_week()
コード例 #14
0
import logging

from toggle_client_api.api_client import TogglClientApi
from libs.invoke_workdays.workday import WorkDay
from libs.invoke_users.invoke_users import User
from libs.invoke_loadup.invoke_loadup import Loadup
from libs.date_functions import get_day_previous_week, convert_milliseconds_to_hours

# log_level = logging.DEBUG
log_level = logging.WARN
logging.basicConfig(level=log_level)

# Load Configs
import yaml

loadup = Loadup(sys.argv)
loadup.initialize_configs()
configs = loadup.get_config()
logging.debug(configs)
loadup.date_restriction(configs)

# Toggl API Config
settings = {
    'token': configs['togglAPI']['token'],
    'user_agent': configs['togglAPI']['user_agent'],
    "workspace_id": configs['togglAPI']['workspace_id']
}
api = TogglClientApi(settings)

user_list_response = api.get_workspace_members(settings['workspace_id'])
last_monday = get_day_previous_week()