def enroll(self, user, course_id):
        spec_data = University2035Block().can_enroll(user, course_id)
        try:
            require(spec_data['can_enroll'])
        except:
            return False

        block = University2035Block()
        unti2035_id = block.get_user_id(user)
        course_unti2035_id = block.get_course_id(course_id)

        data = {
            'unti_id': unti2035_id,
            'external_course_id': course_unti2035_id,
            'platform_id': settings.SOCIAL_AUTH_UNIVERSITY2035_KEY,
            'enrol_ticket': spec_data['enroll_ticket']
        }

        resp = requests.post(
            u'{}/cat-enroll/api/v1/course/enroll/'.format(
                settings.API_UNTI_URL),
            data=data,
            headers={
                'Authorization':
                'Token {}'.format(settings.SOCIAL_AUTH_UNIVERSITY2035_API_KEY)
            })

        _read_status_code(resp.status_code)
Exemple #2
0
from require import require, set_entry_file, getabspath
import traceback
import sys

try:
    set_entry_file(__file__)

    path, parent, fname = getabspath("/root", "home/../name")
    print(path, parent, fname)
    assert "/root/name" == path

    require("1")
    require("a")
    require("i1")
    require("r1")
    require("testimport")
    require("test-require-all")
    require("test-force")

    t1 = require("tween")
    t2 = require("dup/tween")
    print(t1)
    print(t2)
    assert t1.name == "outside"
    assert t2.name == "inside"

    print("\n" * 3)
    print("all tests passed!")
except Exception as e:
    # ex_type, ex, tb = sys.exc_info()
    print("\n" * 3)
Exemple #3
0
import sys
import require
from fullscreen import maximize_console
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

maximize_console()
if not require.require(['selenium']):
    x = input()
    sys.exit()


def get_driver(url):
    driver = webdriver.Chrome()
    driver.get(url)
    print(driver)
    try:
        element = WebDriverWait(driver, 20).until(
            EC.element_to_be_clickable(
                (By.XPATH, "/html/body/main/form/footer/button[1]")))
    except:
        print('element not found')
    return driver


def selector(choice, driver):
    elements = []
    try:
        for x in range(1, 999):
Exemple #4
0
from require import require
import traceback
import sys

try:
    require("1")
    require("a")
    require("i1")
    require("r1")
    require("testimport")
    require("test-require-all")
    require("test-force")
    
    print("\n"*3)
    print("all tests passed!")
except Exception as e:
    ex_type, ex, tb = sys.exc_info()
    print(ex)
    traceback.print_tb(tb)
    
    print("\n"*3)
    print("tests failed!")
Exemple #5
0
import json
import unittest
from glob import glob
import re
from require import require
import os
attack = require("../functions/attack.py")


class AttackTest(unittest.TestCase):
    def test_attack(self):
        pokemon = []
        os.chdir("../input")
        for f_name in glob("[A-Z]*.json"):
            if re.match("list_of_pokemon.json", f_name):
                continue
            else:
                pokemon.append(f_name)
        for i in pokemon:
            print(i + " is being run by the attack test case")
            self.assertGreater(attack.read_attack(i), 0)
Exemple #6
0
import json
import unittest
from glob import glob
import re
from require import require
import os
defense = require("../functions/defense.py")


class Defense_Test(unittest.TestCase):
    def test_defense(self):
        pokemon = []
        os.chdir("../input")
        for f_name in glob("[A-Z]*.json"):
            if re.match("list_of_pokemon.json", f_name):
                continue
            else:
                pokemon.append(f_name)
        print("\n")
        for i in pokemon:
            print(i + " is being run by the defense test case")
            self.assertGreater(defense.read_defense(i), 0)
def test_require_not_conflict_site_py():
    """Ensure require does not clobber pre-loaded builtins."""
    re2 = require.require('re')
    assert '.pymodules' not in repr(re2)
def test_require_not_conflict_with_import():
    """Ensure that using require does not interfere with normal imports."""
    setuptools = require.require('setuptools')
    import setuptools as setuptools2
    assert setuptools2 is not setuptools
def test_require_uses_module_cache():
    """Check if modules are cached when working with pymodules."""
    t2_import_test = require.require('import_test')
    t3_import_test = require.require('import_test')
    assert t2_import_test is t3_import_test
def test_require_gets_local():
    """Check if require finds the local pymodule."""
    t1_import_test = require.require('import_test')
    assert '.pymodules' in repr(t1_import_test)
Exemple #11
0
 def require(self, spec, options={'language':'javascript'} ):
     "%s" % require.DocString
     return require.require( spec, options )
Exemple #12
0
import unittest
from glob import glob
import re
import os
from require import require
moves = require("../functions/moves.py")


class MoveTest(unittest.TestCase):
    def test_moves(self):
        pokemon = []
        os.chdir("../input")
        for f_name in glob("[A-Z]*.json"):
            if re.match("list_of_pokemon.json", f_name):
                continue
            else:
                pokemon.append(f_name)
        print("\n")
        for i in pokemon:
            print(i + " is being run by the move test case")
            self.assertGreater(moves.read_moves(i), 0)
import json
import unittest
from glob import glob
import re
import os
from require import require
speed = require("../functions/speed.py")


class Speed_Test(unittest.TestCase):
    def test_speed(self):
        pokemon = []
        os.chdir("../input")
        for f_name in glob("[A-Z]*.json"):
            if re.match("list_of_pokemon.json", f_name):
                continue
            else:
                pokemon.append(f_name)
        print("\n")
        for i in pokemon:
            print(i + " is being run by the speed test case")
            self.assertGreater(speed.read_speed(i), 0)
Exemple #14
0
import json
import unittest
from glob import glob
import re
from require import require
import os
hp = require("../functions/hp.py")


class HPTest(unittest.TestCase):
    def test_hp(self):
        pokemon = []
        os.chdir("../input")
        for f_name in glob("[A-Z]*.json"):
            if re.match("list_of_pokemon.json", f_name):
                continue
            else:
                pokemon.append(f_name)
        print("\n")
        for i in pokemon:
            print(i + " is being run by the hp test case")
            self.assertGreater(hp.read_hp(i), 0)