def setUp(self):
     self.domain = 'dummy-project'
     self.project = Domain(name=self.domain)
     self.project.save()
     delete_all_cases()
     delete_all_sync_logs()
     delete_all_users()
 def setUp(self):
     self.domain = 'dummy-project'
     self.project = Domain(name=self.domain)
     self.project.save()
     delete_all_cases()
     delete_all_sync_logs()
     delete_all_users()
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()

        # this creates the initial blank sync token in the database
        self.device = MockDevice(self.project, self.user)
        self.device.sync(version=V1)
 def tearDown(self):
     delete_all_xforms()
     delete_all_cases()
     delete_all_sync_logs()
     restore_config = RestoreConfig(project=self.project,
                                    restore_user=self.restore_user)
     restore_config.cache.delete(restore_config._initial_cache_key)
     super(BaseOtaRestoreTest, self).tearDown()
Beispiel #5
0
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()

        # this creates the initial blank sync token in the database
        generate_restore_payload(self.project, self.user)
        self.sync_log = get_exactly_one_wrapped_sync_log()
 def setUpClass(cls):
     super(BaseAsyncRestoreTest, cls).setUpClass()
     delete_all_cases()
     delete_all_sync_logs()
     delete_all_users()
     cls.domain = 'dummy-project'
     cls.project = Domain(name=cls.domain)
     cls.project.save()
     cls.user = create_restore_user(domain=cls.domain)
Beispiel #7
0
    def setUp(self):
        super(StateHashTest, self).setUp()
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()

        # this creates the initial blank sync token in the database
        self.device = MockDevice(self.project, self.user)
        self.device.sync(version=V1)
Beispiel #8
0
 def tearDown(self):
     SQLLocation.objects.all().delete()
     self.backend_mapping.delete()
     self.backend.delete()
     delete_all_xforms()
     delete_all_cases()
     delete_all_sync_logs()
     delete_all_users()
     self.domain.delete()  # domain delete cascades to everything else
 def setUpClass(cls):
     super(BaseAsyncRestoreTest, cls).setUpClass()
     delete_all_cases()
     delete_all_sync_logs()
     delete_all_users()
     cls.domain = 'dummy-project'
     cls.project = Domain(name=cls.domain)
     cls.project.save()
     cls.user = create_restore_user(domain=cls.domain)
Beispiel #10
0
 def tearDown(self):
     SQLLocation.objects.all().delete()
     self.backend_mapping.delete()
     self.backend.delete()
     delete_all_xforms()
     delete_all_cases()
     delete_all_sync_logs()
     delete_all_users()
     self.domain.delete()  # domain delete cascades to everything else
     super(CommTrackTest, self).tearDown()
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()

        self.user = User(user_id=USER_ID, username="******", 
                         password="******", date_joined=datetime(2011, 6, 9)) 
        # this creates the initial blank sync token in the database
        restore_config = RestoreConfig(self.user)
        self.sync_log = synclog_from_restore_payload(restore_config.get_payload())
Beispiel #12
0
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()
        self.project = Domain(name='state-hash-tests-project')
        self.user = User(user_id="state_hash", username="******",
                         password="******", date_joined=datetime(2011, 6, 9))

        # this creates the initial blank sync token in the database
        generate_restore_payload(self.project, self.user)
        self.sync_log = get_exactly_one_wrapped_sync_log()
Beispiel #13
0
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()
        delete_all_users()
        self.project = Domain(name='state-hash-tests-project')
        self.project.save()
        self.user = create_restore_user(domain=self.project.name)

        # this creates the initial blank sync token in the database
        generate_restore_payload(self.project, self.user)
        self.sync_log = get_exactly_one_wrapped_sync_log()
Beispiel #14
0
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()

        self.user = User(user_id="state_hash", username="******",
                         password="******", date_joined=datetime(2011, 6, 9)) 
        
        # this creates the initial blank sync token in the database
        generate_restore_payload(self.user)
        [sync_log] = SyncLog.view("phone/sync_logs_by_user", include_docs=True, reduce=False).all()
        self.sync_log = sync_log
Beispiel #15
0
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()
        delete_all_users()
        self.project = Domain(name='state-hash-tests-project')
        self.project.save()
        self.user = create_restore_user(domain=self.project.name)

        # this creates the initial blank sync token in the database
        generate_restore_payload(self.project, self.user)
        self.sync_log = get_exactly_one_wrapped_sync_log()
Beispiel #16
0
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()

        self.user = User(user_id=USER_ID,
                         username="******",
                         password="******",
                         date_joined=datetime(2011, 6, 9))
        # this creates the initial blank sync token in the database
        restore_config = RestoreConfig(self.user)
        self.sync_log = synclog_from_restore_payload(
            restore_config.get_payload())
Beispiel #17
0
    def setUp(self):
        super(CommTrackTest, self).setUp()
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()
        delete_all_sync_logs()

        StockReport.objects.all().delete()
        StockTransaction.objects.all().delete()

        self.backend, self.backend_mapping = setup_default_sms_test_backend()

        self.domain = bootstrap_domain(TEST_DOMAIN)
        bootstrap_location_types(self.domain.name)
        bootstrap_products(self.domain.name)
        self.ct_settings = CommtrackConfig.for_domain(self.domain.name)
        self.ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
            min_periods=0,
        )
        # todo: remove?
        if self.requisitions_enabled:
            self.ct_settings.requisition_config = get_default_requisition_config(
            )

        self.ct_settings.save()

        self.domain = Domain.get(self.domain._id)

        self.loc = make_loc('loc1')
        self.sp = self.loc.linked_supply_point()
        self.users = [
            bootstrap_user(self, **user_def)
            for user_def in self.user_definitions
        ]

        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN,
                           name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group._id = self.sp.owner_id
        self.group.save()
        self.products = sorted(Product.by_domain(self.domain.name),
                               key=lambda p: p._id)
        self.assertEqual(3, len(self.products))
Beispiel #18
0
    def setUp(self):
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()
        delete_all_sync_logs()

        StockReport.objects.all().delete()
        StockTransaction.objects.all().delete()

        self.backend = test.bootstrap(TEST_BACKEND, to_console=True)
        self.domain = bootstrap_domain()
        bootstrap_location_types(self.domain.name)
        bootstrap_products(self.domain.name)
        self.ct_settings = CommtrackConfig.for_domain(self.domain.name)
        self.ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
            min_periods=0,
        )
        if self.requisitions_enabled:
            self.ct_settings.requisition_config = get_default_requisition_config()

        self.ct_settings.save()

        self.domain = Domain.get(self.domain._id)

        self.loc = make_loc('loc1')
        self.sp = make_supply_point(self.domain.name, self.loc)
        self.users = [bootstrap_user(self, **user_def) for user_def in self.user_definitions]

        if False:
            # bootstrap additional users for requisitions
            # needs to get reinserted for requisition stuff later
            self.approver = bootstrap_user(self, **APPROVER_USER)
            self.packer = bootstrap_user(self, **PACKER_USER)
            self.users += [self.approver, self.packer]

        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group.save()
        self.sp.owner_id = self.group._id
        self.sp.save()
        self.products = sorted(Product.by_domain(self.domain.name), key=lambda p: p._id)
        self.assertEqual(3, len(self.products))
Beispiel #19
0
    def setUp(self):
        super(CommTrackTest, self).setUp()
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()
        delete_all_sync_logs()

        StockReport.objects.all().delete()
        StockTransaction.objects.all().delete()

        self.backend, self.backend_mapping = setup_default_sms_test_backend()

        self.domain = bootstrap_domain(TEST_DOMAIN)
        bootstrap_location_types(self.domain.name)
        bootstrap_products(self.domain.name)
        self.ct_settings = CommtrackConfig.for_domain(self.domain.name)
        self.ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
            min_periods=0,
        )
        # todo: remove?
        if self.requisitions_enabled:
            self.ct_settings.requisition_config = get_default_requisition_config()

        self.ct_settings.save()

        self.domain = Domain.get(self.domain._id)

        self.loc = make_loc('loc1')
        self.sp = self.loc.linked_supply_point()
        self.users = [bootstrap_user(self, **user_def) for user_def in self.user_definitions]

        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group._id = self.sp.owner_id
        self.group.save()
        self.products = sorted(Product.by_domain(self.domain.name), key=lambda p: p._id)
        self.assertEqual(3, len(self.products))
Beispiel #20
0
 def setUpClass(cls):
     domain = "synclog_test"
     super(DBAccessorsTest, cls).setUpClass()
     delete_all_sync_logs()
     cls.user_id = 'lkasdhfadsloi'
     cls.sync_logs = [
         SyncLog(domain=domain,
                 user_id=cls.user_id,
                 date=datetime.datetime(2015, 7, 1, 0, 0)),
         SimplifiedSyncLog(domain=domain,
                           user_id=cls.user_id,
                           date=datetime.datetime(2015, 3, 1, 0, 0)),
         SyncLog(domain=domain,
                 user_id=cls.user_id,
                 date=datetime.datetime(2015, 1, 1, 0, 0))
     ]
     sync_logs_other = [SyncLog(domain=domain, user_id='other')]
     cls.docs = cls.sync_logs + sync_logs_other
     for doc in cls.docs:
         doc.save()
Beispiel #21
0
    def setUpClass(cls):
        super(TestDbAccessors, cls).setUpClass()
        delete_all_sync_logs()

        # Needed because other tests do not always clean up their users or applications.
        delete_all_users()
        hard_delete_deleted_users()
        delete_all_apps()

        cls.g1 = Group(domain=cls.domain, name='group')
        cls.g1.save()

        cls.g2 = Group(domain=cls.domain, name='group')
        cls.g2.soft_delete()

        cls.domain_obj = Domain(
            name=cls.domain,
            is_active=True,
        )
        cls.domain_obj.save()

        cls.web_user = WebUser.create(cls.domain, 'web-user', '***')
        cls.commcare_user = CommCareUser.create(cls.domain, 'cc-user', '***')
        cls.commcare_user.retire()
        cls.synclog = SimplifiedSyncLog(
            domain=cls.domain,
            build_id='1234',
            user_id='5678',
            date=datetime.utcnow(),
        )
        cls.synclog.save()
        cls.test_app = Application(domain=cls.domain, name='test-app')
        cls.test_app.save()
        cls.deleted_app = Application(domain=cls.domain,
                                      name='deleted-app',
                                      doc_type='Application-Deleted')
        cls.deleted_app.save()
        cls.linked_app = LinkedApplication(domain=cls.domain,
                                           name='linked-app',
                                           doc_type='Application-Deleted')
        cls.linked_app.save()
 def setUpClass(cls):
     super(BaseOtaRestoreTest, cls).setUpClass()
     delete_all_cases()
     delete_all_sync_logs()
     cls.project = Domain(name='ota-restore-tests')
     cls.project.save()
 def tearDownClass(cls):
     delete_all_sync_logs()
     cls.ccuser.delete()
     cls.domain.delete()
     super(SyncLogPillowTest, cls).tearDownClass()
Beispiel #24
0
 def setUpClass(cls):
     super(BaseOtaRestoreTest, cls).setUpClass()
     delete_all_cases()
     delete_all_sync_logs()
     cls.project = Domain(name='ota-restore-tests')
     cls.project.save()
Beispiel #25
0
 def tearDown(self):
     delete_all_xforms()
     delete_all_cases()
     delete_all_sync_logs()
     get_redis_default_cache().clear()
     super(BaseOtaRestoreTest, self).tearDown()
 def setUp(self):
     self.domain = 'dummy-project'
     delete_all_cases()
     delete_all_sync_logs()
 def setUpClass(cls):
     delete_all_cases()
     delete_all_sync_logs()
Beispiel #28
0
 def tearDown(self):
     delete_all_cases()
     delete_all_sync_logs()
     restore_config = RestoreConfig(project=self.project, user=dummy_user())
     restore_config.cache.delete(restore_config._initial_cache_key())
Beispiel #29
0
 def setUpClass(cls):
     delete_all_cases()
     delete_all_sync_logs()
     cls.project = Domain(name='ota-restore-tests')
 def setUp(self):
     delete_all_sync_logs()
 def setUp(self):
     self.domain = 'dummy-project'
     delete_all_cases()
     delete_all_sync_logs()
Beispiel #32
0
 def setUpClass(cls):
     cls.domain = "synclog_test"
     cls.user_id = 'sadsadsa'
     cls.docs = []
     super(SyncLogPruneTest, cls).setUpClass()
     delete_all_sync_logs()
 def setUp(self):
     delete_all_cases()
     delete_all_sync_logs()
 def tearDownClass(cls):
     delete_all_sync_logs()
     cls.ccuser.delete()
     cls.domain.delete()
     super(SyncLogPillowTest, cls).tearDownClass()
 def tearDownClass(cls):
     cls.project.delete()
     delete_all_cases()
     delete_all_sync_logs()
     delete_all_users()
     super(BaseAsyncRestoreTest, cls).tearDownClass()
 def tearDown(self):
     delete_all_cases()
     delete_all_sync_logs()
 def tearDownClass(cls):
     cls.project.delete()
     delete_all_cases()
     delete_all_sync_logs()
     delete_all_users()
     super(BaseAsyncRestoreTest, cls).tearDownClass()
Beispiel #38
0
 def tearDown(self):
     delete_all_xforms()
     delete_all_cases()
     delete_all_sync_logs()
     get_redis_default_cache().clear()
     super(BaseOtaRestoreTest, self).tearDown()