Skip to content

Commit

Permalink
mock workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
LarynQi committed Oct 30, 2023
1 parent 97e73cd commit aecc8b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client/protocols/grading.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def run(self, messages, env=None):


def grade(questions, messages, env=None, verbose=True, get_help=False, config=None):
print(questions,messages,env,verbose,get_help,config)
format.print_line('~')
print('Running tests')
print()
Expand Down Expand Up @@ -90,7 +91,7 @@ def grade(questions, messages, env=None, verbose=True, get_help=False, config=No
### Fa23 Helper Bot ###
HELP_KEY = 'jfv97pd8ogybhilq3;orfuwyhiulae'
config = config_utils._get_config(config)
if (failed > 0 or get_help) and (config['src'][0][:2] == 'hw'):
if (failed > 0 or get_help) and (config.get('src', [''])[0][:2] == 'hw'):
res = input("Would you like to receive 61A-bot feedback on your code (y/N)? ")
print()
if res == "y":
Expand Down
9 changes: 9 additions & 0 deletions client/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from client import exceptions as ex

import mock

CONFIG_DIRECTORY = os.path.join(os.path.expanduser('~'), '.config', 'ok')
REFRESH_FILE = os.path.join(CONFIG_DIRECTORY, "auth_refresh")
CERT_FILE = os.path.join(CONFIG_DIRECTORY, "cacert.pem")
Expand All @@ -17,6 +19,8 @@ def create_config_directory():
return CONFIG_DIRECTORY

def _get_config(config):
if isinstance(config, mock.Mock):
return {}
if config is None:
configs = glob.glob(CONFIG_EXTENSION)
if len(configs) > 1:
Expand All @@ -29,6 +33,11 @@ def _get_config(config):
elif not configs:
raise ex.LoadingException('No .ok configuration file found')
config = configs[0]
if config[-2:] != '.ok':
return {}
elif not os.path.isfile(config):
raise ex.LoadingException(
'Could not find config file: {}'.format(config))

try:
with open(config, 'r') as f:
Expand Down

0 comments on commit aecc8b7

Please sign in to comment.