def test_pause(self): xform = self.get_xml('form') set_migration_started(self.domain) with self.assertRaisesRegexp(LocalSubmissionError, 'status code 503'): submit_form_locally(xform, self.domain) _run_timezone_migration_for_domain(self.domain) set_migration_complete(self.domain) # no issue submit_form_locally(xform, self.domain)
def save(self, **params): self.last_modified = datetime.utcnow() if not self._rev: # mark any new domain as timezone migration complete set_migration_complete(self.name) super(Domain, self).save(**params) from corehq.apps.domain.signals import commcare_domain_post_save results = commcare_domain_post_save.send_robust(sender='domain', domain=self) for result in results: # Second argument is None if there was no error if result[1]: notify_exception( None, message="Error occured during domain post_save %s: %s" % (self.name, str(result[1])) )
def handle(self, domain, **options): if should_use_sql_backend(domain): raise CommandError( 'This command only works for couch-based domains.') filepath = get_planning_db_filepath(domain) self.stdout.write('Using file {}\n'.format(filepath)) if options['BEGIN']: self.require_only_option('BEGIN', options) set_migration_started(domain) if options['ABORT']: self.require_only_option('ABORT', options) set_migration_not_started(domain) if options['blow_away']: delete_planning_db(domain) self.stdout.write('Removed file {}\n'.format(filepath)) if options['prepare']: self.planning_db = prepare_planning_db(domain) self.stdout.write('Created and loaded file {}\n'.format(filepath)) else: self.planning_db = get_planning_db(domain) if options['COMMIT']: self.require_only_option('COMMIT', options) assert get_migration_status( domain, strict=True) == MigrationStatus.IN_PROGRESS commit_plan(domain, self.planning_db) set_migration_complete(domain) if options['prepare_case_json']: prepare_case_json(self.planning_db) if options['stats']: self.valiate_forms_and_cases(domain) if options['show_diffs']: self.show_diffs() if options['play']: from corehq.apps.tzmigration.planning import * session = self.planning_db.Session() # noqa try: import ipdb as pdb except ImportError: import pdb pdb.set_trace()
def test_complete(self): set_migration_complete('green') self.assertEqual(get_migration_status('green'), MigrationStatus.COMPLETE) self.assertTrue(get_migration_complete('green'))
def run_timezone_migration_for_domain(domain): set_migration_started(domain) _run_timezone_migration_for_domain(domain) set_migration_complete(domain)