# Path: antioch/core/code.py
# def is_frame_access_allowed():
# def massage_verb_code(code):
# def parse_deployment(source):
# def r_eval(caller, src, environment={}, filename='<string>', runtype="eval"):
#     def _writer(s, is_error=False):
# def r_exec(caller, src, environment={}, filename='<string>', runtype="exec"):
#     def _writer(s, is_error=False):
# def restricted_import(name, gdict, ldict, fromlist, level=-1):
# def get_protected_attribute(obj, name, g=getattr):
# def set_protected_attribute(obj, name, value, s=setattr):
# def inplace_var_modification(operator, a, b):
# def get_restricted_environment(writer, p=None):
#         def _call_print(self, s):
#         def __init__(self, obj):
#         def __setattr__(self, name, value):
#         def __setitem__(self, key, value):
# def run_system_verb(exchange, verb_name, *args, **kwargs):
# def api(func):
#     def _api(p):
#         def __api(*args, **kwargs):
# def task(p, delay, origin, verb_name, *args, **kwargs):
# def execute(p, code):
# def evaluate(p, code):
# def tasks(p):
# def write(p, user, text, is_error=False, escape_html=True):
# def log(p, text, is_error=False):
# def broadcast(p, text, escape_html=True):
# def observe(p, user, observations):
# def count_named(p, key):
# def get_object(p, key, return_list=False):
# def create_object(p, name, unique_name=False):
# def get_last_client_ip(p, player):
#     class _print_(object):
#     class _write_(object):


from django.test import TestCase
from django.test.utils import captured_output
from antioch.core.code import argparser, parse_deployment
# antioch
# Copyright (c) 1999-2019 Phil Christensen
#
# See LICENSE for details



class DeploymentsTestCase(TestCase):
    def test_simple_case(self):
        test_args = '#!antioch verb example "author class" --owner "wizard"'
        d = parse_deployment(test_args)
        self.assertEqual(d.type, 'verb')
        self.assertEqual(d.owner, 'wizard')
        self.assertEqual(d.origin, 'author class')
    
    def test_multiline_case(self):
        test_args = '#!antioch verb example\\ \n# "author class" \\ \n# --owner "wizard"'
        d = parse_deployment(test_args)
        self.assertEqual(d.type, 'verb')
        self.assertEqual(d.owner, 'wizard')
        self.assertEqual(d.origin, 'author class')
    
    def test_failure_case(self):
        test_args = '#!antioch verb example'
        
        with captured_output('stderr') as stdout:
            with self.assertRaises(SystemExit):

# Path: antioch/core/code.py
# def is_frame_access_allowed():
# def massage_verb_code(code):
# def parse_deployment(source):
# def r_eval(caller, src, environment={}, filename='<string>', runtype="eval"):
#     def _writer(s, is_error=False):
# def r_exec(caller, src, environment={}, filename='<string>', runtype="exec"):
#     def _writer(s, is_error=False):
# def restricted_import(name, gdict, ldict, fromlist, level=-1):
# def get_protected_attribute(obj, name, g=getattr):
# def set_protected_attribute(obj, name, value, s=setattr):
# def inplace_var_modification(operator, a, b):
# def get_restricted_environment(writer, p=None):
#         def _call_print(self, s):
#         def __init__(self, obj):
#         def __setattr__(self, name, value):
#         def __setitem__(self, key, value):
# def run_system_verb(exchange, verb_name, *args, **kwargs):
# def api(func):
#     def _api(p):
#         def __api(*args, **kwargs):
# def task(p, delay, origin, verb_name, *args, **kwargs):
# def execute(p, code):
# def evaluate(p, code):
# def tasks(p):
# def write(p, user, text, is_error=False, escape_html=True):
# def log(p, text, is_error=False):
# def broadcast(p, text, escape_html=True):
# def observe(p, user, observations):
# def count_named(p, key):
# def get_object(p, key, return_list=False):
# def create_object(p, name, unique_name=False):
# def get_last_client_ip(p, player):
#     class _print_(object):
#     class _write_(object):


# Path: antioch/test/test_deployments.py
from django.test import TestCase
from django.test.utils import captured_output
from antioch.core.code import argparser, parse_deployment

# antioch
# Copyright (c) 1999-2019 Phil Christensen
#
# See LICENSE for details



class DeploymentsTestCase(TestCase):
    def test_simple_case(self):
        test_args = '#!antioch verb example "author class" --owner "wizard"'
        d = parse_deployment(test_args)
        self.assertEqual(d.type, 'verb')
        self.assertEqual(d.owner, 'wizard')
        self.assertEqual(d.origin, 'author class')
    
    def test_multiline_case(self):
        test_args = '#!antioch verb example\\ \n# "author class" \\ \n# --owner "wizard"'
        d = parse_deployment(test_args)
        self.assertEqual(d.type, 'verb')
        self.assertEqual(d.owner, 'wizard')
        self.assertEqual(d.origin, 'author class')
    
    def test_failure_case(self):
        test_args = '#!antioch verb example'
        
        with captured_output('stderr') as stdout:
            with self.assertRaises(SystemExit):

                d = parse_deployment(test_args)