コード例 #1
0
 def test_create_payload(self):
     pass_ = Pass()
     member_name = ua.Field(
         name='Member Name',
         value='Max Del Giudice'
     )
     member_id = ua.Field(
         name='Member ID',
         value=12345678
     )
     points = ua.Field(
         name='Points',
         value=5555
     )
     pass_.add_fields(member_name, member_id, points)
     pass_.add_headers(barcode_value='99999999')
     self.assertEqual(
         pass_._create_payload(),
         {
             'fields': {
                 'Member Name': {'value': 'Max Del Giudice'},
                 'Member ID': {'value': 12345678},
                 'Points': {'value': 5555}
             },
             'headers': {
                 'barcode_value': {
                     'fieldType': 'barcode',
                     'formatType': 'String',
                     'value': '99999999'
                 }
             }
         }
     )
コード例 #2
0
    def test_field_json(self):
        view_json = {
            "Program Points": {
                "label": "UPDATED_LABEL",
                "value": "UPDATED_VALUE"
            },
            "Program Details": {
                "label": "UPDATED_LABEL",
                "value": "UPDATED_VALUE"
            },
            "Tier": {
                "label": "UPDATED_LABEL",
                "value": "UPDATED_VALUE"
            },
            "Merchant Website": {
                "label": "UPDATED_LABEL",
                "value": "UPDATED_VALUE"
            },
            "Loyalty Program Name": {
                "label": "UPDATED_LABEL",
                "value": "UPDATED_VALUE"
            }
        }

        program_points = ua.Field(name='Program Points', label='UPDATED_LABEL', value='UPDATED_VALUE')
        program_details = ua.Field(name='Program Details', label='UPDATED_LABEL', value='UPDATED_VALUE')
        tier = ua.Field(name='Tier', label='UPDATED_LABEL', value='UPDATED_VALUE')
        merchant_website = ua.Field(name='Merchant Website', label='UPDATED_LABEL', value='UPDATED_VALUE')
        program_name = ua.Field(name='Loyalty Program Name', label='UPDATED_LABEL', value='UPDATED_VALUE')
        self.pass_.set_fields(
            program_points, program_details, tier, merchant_website, program_name
        )

        self.assertEquals(self.pass_._create_payload()['fields'], view_json)
        self.assertEquals(self.pass_.view()['fields'], view_json)
コード例 #3
0
 def test_remove_fields(self):
     member_name = ua.Field(name='Member Name',
                            label='Member Name',
                            value='First Last',
                            fieldType=ua.AppleFieldType.PRIMARY)
     merchant_website = ua.Field(name='Merchant Website',
                                 label='Merchant Website',
                                 value='http://test.com',
                                 fieldType=ua.AppleFieldType.BACK)
     self.template.add_fields(member_name, merchant_website)
     self.assertNotEqual(self.template.fields, defaultdict(dict))
     self.template.remove_fields('Member Name', 'Merchant Website')
     self.assertEqual(self.template.fields, defaultdict(dict))
コード例 #4
0
 def test_add_fields(self):
     member_name = ua.Field(name='Member Name',
                            label='Member Name',
                            value='First Last',
                            fieldType=ua.AppleFieldType.PRIMARY)
     merchant_website = ua.Field(name='Merchant Website',
                                 label='Merchant Website',
                                 value='http://test.com',
                                 fieldType=ua.AppleFieldType.BACK)
     self.template.add_fields(member_name, merchant_website)
     self.assertEqual(self.template.fields['Member Name'], member_name)
     self.assertEqual(self.template.fields['Merchant Website'],
                      merchant_website)
コード例 #5
0
 def setUp(self):
     pass_ = Pass()
     member_name = ua.Field(
         name='Member Name',
         value='First Last'
     )
     pass_.add_fields(member_name)
     self.pass_ = pass_
     self.client = ua.Reach('fake', 'creds')
コード例 #6
0
 def test_set_fields(self):
     member_name = ua.Field(name='Member Name',
                            label='Member Name',
                            value='First Last',
                            fieldType=ua.AppleFieldType.PRIMARY)
     merchant_website = ua.Field(name='Merchant Website',
                                 label='Merchant Website',
                                 value='http://test.com',
                                 fieldType=ua.AppleFieldType.BACK)
     self.template.add_fields(member_name, merchant_website)
     self.assertNotEqual(self.template.fields, defaultdict(dict))
     points = ua.Field(name='Reward Points',
                       label='Reward Points',
                       value=1234.0,
                       fieldType=ua.AppleFieldType.SECONDARY)
     self.template.set_fields(points)
     self.assertEqual(len(self.template.fields), 1)
     self.assertEqual(self.template.fields['Reward Points'], points)
コード例 #7
0
    def test_process_module_data(self):
        temp = ua.GoogleTemplate()
        module_data = {
            'Program Points': {
                'balance': 250,
                'label': 'Program Points',
                'hideEmpty': False,
                'formatType': 'Number',
                'fieldType': 'loyaltyPoints',
                'order': 1
            },
            'Tier': {
                'balance': '2.0',
                'label': 'Tier',
                'hideEmpty': False,
                'formatType': 'Number',
                'fieldType': 'pointsModule',
                'order': 2
            }
        }

        program_points = ua.Field(name='Program Points',
                                  label='Program Points',
                                  value=250,
                                  hideEmpty=False,
                                  formatType='Number',
                                  fieldType=ua.GoogleFieldType.POINTS_MODULE,
                                  order=1)

        tier = ua.Field(name='Tier',
                        label='Tier',
                        value='2.0',
                        hideEmpty=False,
                        formatType='Number',
                        fieldType=ua.GoogleFieldType.POINTS_MODULE,
                        order=2)

        temp._process_module_data(ua.GoogleFieldType.POINTS_MODULE,
                                  module_data)
        self.assertTrue(temp.fields['Program Points'] == program_points)
        self.assertTrue(temp.fields['Tier'] == tier)
コード例 #8
0
def build_google_pass():
    pass_ = ua.GooglePass()
    pass_.metadata = {
        'id': '18971172',
        'templateId': '51234',
        'status': 'not_been_installed',
        'tags': []
    }
    pass_.add_headers(barcode_encoding='iso-8859-1')

    points = ua.Field(name='Points',
                      fieldType=ua.GoogleFieldType.POINTS_MODULE,
                      value=33.0)

    pass_.add_fields(points)
    return pass_
コード例 #9
0
def build_apple_pass():
    pass_ = ua.ApplePass()
    pass_.metadata = {
        'id': '18971172',
        'templateId': '51234',
        'status': 'not_been_installed',
        'tags': []
    }
    pass_.add_headers(barcode_encoding='iso-8859-1')

    points = ua.Field(name='Points',
                      fieldType='primary',
                      numberStyle='numberStyleDecimal',
                      value=33.0)

    pass_.add_fields(points)
    return pass_
コード例 #10
0
def build_google_loyalty():
    template = ua.GoogleTemplate()

    template.add_metadata(name='Loyalty Copy',
                          description='Loyalty description',
                          type_=ua.Type.LOYALTY)

    template.add_headers(barcodeAltText='123456789',
                         barcode_encoding='iso-8859-1',
                         barcode_type=ua.BarcodeType.PDF_417,
                         barcode_value='123456789')

    # Account Module fields
    member_id = ua.Field(name='Member ID',
                         fieldType=ua.GoogleFieldType.ACCOUNT_MODULE,
                         value='123456789',
                         label='Member ID',
                         order=2)
    member_name = ua.Field(name='Member Name',
                           fieldType=ua.GoogleFieldType.ACCOUNT_MODULE,
                           value='First Last',
                           label='Member Name',
                           order=1)

    # Links module
    merchant_website = ua.Field(name='Merchant Website',
                                label='Merchant Website',
                                fieldType=ua.GoogleFieldType.LINKS_MODULE,
                                value='http://www.test.com',
                                order=1)

    # Points module
    program_points = ua.Field(name='Program Points',
                              label='Program Points',
                              fieldType=ua.GoogleFieldType.POINTS_MODULE,
                              value='250',
                              order=1)

    tier = ua.Field(name='Tier',
                    label='Tier',
                    fieldType=ua.GoogleFieldType.POINTS_MODULE,
                    value='2.0',
                    order=2)

    # Text module
    program_details = ua.Field(
        name='Program Details',
        label='Program Details',
        fieldType=ua.GoogleFieldType.TEXT_MODULE,
        value='Some information about how the loyalty program works.',
        order=1)

    # Title module
    loyalty_program = ua.Field(name='Loyalty Program Name',
                               label='Bleep',
                               fieldType=ua.GoogleFieldType.TITLE_MODULE,
                               value='Loyalty Program Name',
                               order=1)

    template.add_fields(member_id, member_name, merchant_website,
                        program_points, tier, program_details, loyalty_program)

    template.set_logo_image(
        'https://s3.amazonaws.com/passtools_prod/1/images/default-loyalty-logo.png'
    )

    return template
コード例 #11
0
def build_apple_loyalty():
    template = ua.AppleTemplate()
    template.add_metadata(
        name='Loyalty Copy 7',
        description='With textAlignment, formatType, numberStyle, '
        'fixed location, and order',
        project_type='memberCard',
        template_type='Store Card')
    template.add_headers(
        suppress_strip_shine='true',
        barcode_value='123456789',
        icon_image=
        'https://s3.amazonaws.com/passtools_prod/1/images/default-pass-icon.png',
        barcode_type=ua.BarcodeType.PDF_417,
        logo_image=
        'https://s3.amazonaws.com/passtools_prod/1/images/default-pass-logo.png',
        background_color=ua.rgb(49, 159, 196),
        barcode_encoding='iso-8859-1',
        logo_color=ua.rgb(24, 86, 148),
        barcodeAltText='123456789',
        foreground_color=ua.rgb(255, 255, 255),
        logo_text='Logo Text')

    program_name = ua.Field(
        name='Program Name',
        label='Bleep',
        value='Program Name',
        fieldType=ua.AppleFieldType.PRIMARY,
    )

    points = ua.Field(
        name='Points',
        label='Points',
        value=1234.0,
        fieldType=ua.AppleFieldType.HEADER,
    )

    program_details = ua.Field(
        name='Program Details',
        label='Program Details',
        value='Some info about how the loyalty program works and its benefits',
        fieldType=ua.AppleFieldType.BACK,
        order=1)

    tier = ua.Field(name='Tier',
                    label='Tier',
                    value=2.0,
                    fieldType=ua.AppleFieldType.SECONDARY,
                    order=1)

    merchant_website = ua.Field(name='Merchant Website',
                                label='Merchant Website',
                                value='http://www.test.com',
                                fieldType=ua.AppleFieldType.BACK,
                                formatType='URL',
                                order=2)

    tier_name = ua.Field(name='Tier Name',
                         label='Tier Name',
                         value='Silver',
                         fieldType=ua.AppleFieldType.SECONDARY,
                         order=2)

    member_name = ua.Field(name='Member Name',
                           label='Member Name',
                           value='First Last',
                           fieldType=ua.AppleFieldType.SECONDARY,
                           order=3)

    template.add_fields(program_name, points, program_details, tier,
                        merchant_website, tier_name, member_name)

    template.add_beacon('3526dee6-4ea8-11e6-beb8-9e71128cae77',
                        relevant_text='Look where you are!',
                        major=123,
                        minor=456)

    return template