def test_company_sample(): filename = "company_contact_sample.xlsx" activate("en") shop = get_default_shop() path = os.path.join(os.path.dirname(__file__), "data", "contact", filename) transformed_data = transform_file(filename.split(".")[1], path) importer = CompanyContactImporter(transformed_data, shop, "en") importer.process_data() assert len(importer.unmatched_fields) == 0 importer.do_import(ImportMode.CREATE_UPDATE) contacts = importer.new_objects assert len(contacts) == 2 assert MutableAddress.objects.count() == 2 first_contact = contacts[0] second_contact = contacts[1] first_address = MutableAddress.objects.first() second_address = MutableAddress.objects.last() first_row = { "name": "Test Company", "name_ext": "Packaging Section", "tax_number": "1234567-888", "email": "*****@*****.**", "street": "TestStreet", "city": "Los Angeles", "postal_code": "90000", "country": "US", "region_code": "CA", "phone": "1123555111" } second_row = { "name": "Test Company 2", "name_ext": "", "tax_number": "12333-2232", "email": "*****@*****.**", "street": "Test Company Street", "city": "Los Angeles", "postal_code": "90001", "country": "US", "region_code": "CA", "phone": "1235678900" } assert_contact_address(first_contact, first_address, first_row) assert_contact_address(second_contact, second_address, second_row)
def test_company_sample(rf): filename = "company_contact_sample.xlsx" activate("en") shop = get_default_shop() path = os.path.join(os.path.dirname(__file__), "data", "contact", filename) transformed_data = transform_file(filename.split(".")[1], path) importer = CompanyContactImporter( transformed_data, CompanyContactImporter.get_importer_context(rf.get("/"), shop=shop, language="en")) importer.process_data() assert len(importer.unmatched_fields) == 0 importer.do_import(ImportMode.CREATE_UPDATE) contacts = importer.new_objects assert len(contacts) == 2 assert MutableAddress.objects.count() == 2 first_contact = contacts[0] second_contact = contacts[1] first_address = MutableAddress.objects.first() second_address = MutableAddress.objects.last() first_row = { "name": "Test Company", "name_ext": "Packaging Section", "tax_number": "1234567-888", "email": "*****@*****.**", "street": "TestStreet", "city": "Los Angeles", "postal_code": "90000", "country": "US", "region_code": "CA", "phone": "1123555111" } second_row = { "name": "Test Company 2", "name_ext": "", "tax_number": "12333-2232", "email": "*****@*****.**", "street": "Test Company Street", "city": "Los Angeles", "postal_code": "90001", "country": "US", "region_code": "CA", "phone": "1235678900" } assert_contact_address(first_contact, first_address, first_row) assert_contact_address(second_contact, second_address, second_row)