def test_build_sync_agent(self, a, b): db_update.build_sync_agents() b.assert_called_with( 'question_sync_agent', query= '{\n "$and": [\n {\n "$comment": "{\\"criterionLabel\\":\\"A\\",\\"criter' 'iaPath\\":[\\"statement\\",\\"verb\\"]}",\n "statement.verb.id": {\n ' '"$in": [\n "http://id.tincanapi.com/verb/viewed"\n ]\n }\n ' ' },\n {\n "$comment": "{\\"criterionLabel\\":\\"B\\",\\"criteriaPath\\":[' '\\"statement\\",\\"object\\",\\"definition\\",\\"type\\"]}",\n "statement.obj' 'ect.definition.type": {\n "$in": [\n "http://activitystrea.ms/sche' 'ma/1.0/page"\n ]\n }\n }\n ]\n}')
def ready(self): """Perform sync agent checks, updates and creations when the server is started.""" if os.environ.get('RUN_MAIN'): from assistants import sync_agent import django.core.validators as validators from django.core.exceptions import ValidationError validator = validators.URLValidator(schemes=("http", "https")) try: validator(os.getenv("MOODLE_BASE_URL")) validator(os.getenv("MOODLE_BASE_IP")) validator(os.getenv("MOODLE_WEBSERVICE_URL")) validator(os.getenv("LL_URL")) except ValueError: raise ValidationError() try: sync_agent.build_sync_agents() except requests.ConnectionError: print(f'Connection to Learning Locker was refused! Is it running on {settings.LL_URL} and reachable?') quit()
def test_dont_build_sync_agent(self, a, b): db_update.build_sync_agents() self.assertFalse(b.called)
def check_sync_agent_forwarders(self): """Check if the statement forwarders for the sync agents are up to date.""" sync_agent.build_sync_agents() self.stdout.write('Sync_agent forwarders are up to date.')