def test_selective_product_sync(self): user = self.user expected_xml = self.generate_product_fixture_xml(user) product_list = Product.by_domain(user.domain) self._initialize_product_names(len(product_list)) fixture_original = product_fixture_generator(user, V1) generate_restore_payload(self.domain_obj, user) self.assertXmlEqual( expected_xml, ElementTree.tostring(fixture_original[0]) ) first_sync = sorted(SyncLog.view( "phone/sync_logs_by_user", include_docs=True, reduce=False ).all(), key=lambda x: x.date)[-1] # make sure the time stamp on this first sync is # not on the same second that the products were created first_sync.date += datetime.timedelta(seconds=1) # second sync is before any changes are made, so there should # be no products synced fixture_pre_change = product_fixture_generator(user, V1, last_sync=first_sync) generate_restore_payload(self.domain_obj, user) self.assertEqual( [], fixture_pre_change, "Fixture was not empty on second sync" ) second_sync = sorted(SyncLog.view( "phone/sync_logs_by_user", include_docs=True, reduce=False ).all(), key=lambda x: x.date)[-1] self.assertTrue(first_sync._id != second_sync._id) # save should make the product more recently updated than the # last sync for product in product_list: product.save() # now that we've updated a product, we should get # product data in sync again fixture_post_change = product_fixture_generator(user, V1, last_sync=second_sync) # regenerate the fixture xml to make sure it is still legit self.assertXmlEqual( expected_xml, ElementTree.tostring(fixture_post_change[0]) )
def test_selective_product_sync(self): user = bootstrap_user(self, phone_number="1234567890") expected_xml = self.generate_product_fixture_xml(user) product_list = Product.by_domain(user.domain) self._initialize_product_names(len(product_list)) fixture_original = product_fixture_generator(user, V1) generate_restore_payload(user.to_casexml_user()) self.assertXmlEqual( expected_xml, ElementTree.tostring(fixture_original[0]) ) first_sync = sorted(SyncLog.view( "phone/sync_logs_by_user", include_docs=True, reduce=False ).all(), key=lambda x: x.date)[-1] # make sure the time stamp on this first sync is # not on the same second that the products were created first_sync.date += datetime.timedelta(seconds=1) # second sync is before any changes are made, so there should # be no products synced fixture_pre_change = product_fixture_generator(user, V1, last_sync=first_sync) generate_restore_payload(user.to_casexml_user()) self.assertEqual( [], fixture_pre_change, "Fixture was not empty on second sync" ) second_sync = sorted(SyncLog.view( "phone/sync_logs_by_user", include_docs=True, reduce=False ).all(), key=lambda x: x.date)[-1] self.assertTrue(first_sync._id != second_sync._id) # save should make the product more recently updated than the # last sync for product in product_list: product.save() # now that we've updated a product, we should get # product data in sync again fixture_post_change = product_fixture_generator(user, V1, last_sync=second_sync) # regenerate the fixture xml to make sure it is still legit self.assertXmlEqual( expected_xml, ElementTree.tostring(fixture_post_change[0]) )
def test_product_fixture(self): user = bootstrap_user(self, phone_number="1234567890") xml = self.generate_product_fixture_xml(user) fixture = product_fixture_generator(user, V1) self.assertXmlEqual( xml, ElementTree.tostring(fixture[0]) )
def test_product_fixture(self): user = self.user xml = self.generate_product_fixture_xml(user) fixture = product_fixture_generator(user, V1) self.assertXmlEqual( xml, ElementTree.tostring(fixture[0]) )
def test_product_fixture(self): user = bootstrap_user(self, phone_number="1234567890") xml = self.generate_product_fixture_xml(user) fixture = product_fixture_generator(user, V1) self.assertXmlEqual(xml, ElementTree.tostring(fixture[0]))
def test_product_fixture(self): user = create_restore_user(self.domain.name) xml = self.generate_product_fixture_xml(user) fixture = product_fixture_generator(user, V1) self.assertXmlEqual(xml, ElementTree.tostring(fixture[0]))
def test_product_fixture(self): user = create_restore_user(self.domain.name) xml = self.generate_product_fixture_xml(user) fixture = product_fixture_generator(user, V1) self.assertXmlEqual(xml, ElementTree.tostring(fixture[0]))