Ejemplo n.º 1
0
class ContextTotalApi(object):

    # settings
    api_type = 'total'

    year = random_list_value(["14", "15", "16"])
    month = random_between_values(1, 12)
    day = random_between_values(1, 31)
    since = '20%s-%s-%s' % (year, month, day)
    payload = {'since': since}
    payload_auth = {'since': since, 'auth-id': auth_id}

    print('''Total v1 tests: since - %s''' % (since))

    icon_count = 100

    # Do Request and return response root
    response_root = request(api_type, payload, "v1", "xml")
    response_root_auth = request(api_type, payload_auth, "v1", "xml")

    # Action before class
    def setup_class(cls):
        print("\n>>> Class Setup")

    #  Action after class
    def teardown_class(cls):
        print("\n>>> Class Teardown")
Ejemplo n.º 2
0
class ContextSearchMinApi(object):

    #settings
    api_type = 'search'
    search_text = random_list_value(
        ['google', 'facebook', 'space', 'ball', 'car', 'word'])
    search_amount = '5'
    search_offset = '5'
    search_platform = random_list_value([""])
    search_language = ''
    payload = {
        'term': search_text,
        'amount': search_amount,
        'offset': search_offset,
        'platform': search_platform
    }

    payload_auth = {
        'term': search_text,
        'amount': search_amount,
        'offset': search_offset,
        'platform': search_platform,
        'auth-id': auth_id
    }

    print(
        '''Search min tests: term - %s, amount - %s , offset - %s, platform - %s'''
        % (search_text, search_amount, search_offset, search_platform))

    icon_count = 5

    # Do Request and return response root
    response_root = request(api_type, payload, "v1", "xml")
    response_root_auth = request(api_type, payload_auth, "v1", "xml")

    icons_current_count = 0
    x = True
    while x == True:
        try:
            icons_current_count += 1
            tag_attribs = all_tag_attrib(response_root, 'icon',
                                         str(icons_current_count))
            value_of_attrib = attrib_value(tag_attribs, 'id')
            assert word_count(value_of_attrib) >= 1
            assert icons_current_count <= icon_count
        except AttributeError:
            x = False
            icons_current_count -= 1

    # Choose random icon between min and max
    icon_number = str(random_between_values(1, icon_count))

    # Action before class
    def setup_class(cls):
        print("\n>>> Class Setup")

    #  Action after class
    def teardown_class(cls):
        print("\n>>> Class Teardown")
Ejemplo n.º 3
0
class ContextIconApiJson(object):

    # Settings
    # icon id what will be in request
    icon_id = random.choice([
        str(random_between_values(0, 7500)),
        str(random_between_values(9500, 20000))
    ])

    format = "json"
    files = "eps,svg"
    variants = "enabled"
    info = "enabled"

    print(
        '''Icon v2 Json tests: id - %s, files - %s, variants - %s, info - %s'''
        % (icon_id, files, variants, info))

    payload = {
        'id': icon_id,
        'format': format,
        'files': files,
        'variants': variants,
        'info': info
    }
    payload_auth = {
        'id': icon_id,
        'format': format,
        'files': files,
        'variants': variants,
        'info': info,
        'auth-id': auth_id
    }

    # Do Request and return response root
    response_root = request('icon', payload, "v2", "json")
    response_root_auth = request('icon', payload_auth, "v2", "json")

    # Action before class
    def setup_class(cls):
        print("\n>>> Class Setup")

    #  Action after class
    def teardown_class(cls):
        print("\n>>> Class Teardown")
Ejemplo n.º 4
0
class ContextLatestApi(object):

    # settings
    api_type = 'latest'

    amount = random_list_value(["", "5", "10", "15", "20"])

    offset = random_list_value(["", "5", "10", "15", "20"])

    search_platform = random_list_value([
        "win8", "ios7", "android", "gradient", "color", "win10", "office",
        "p1em", ""
    ])

    print(
        '''Latest v1 tests: amount - %s, offset - %s, offset - %s, platform - %s'''
        % (amount, offset, offset, search_platform))

    payload = {'amount': amount, 'offset': offset, 'platform': search_platform}
    payload_auth = {
        'amount': amount,
        'offset': offset,
        'platform': search_platform,
        'auth-id': auth_id
    }

    icon_count = 100

    # Do Request and return response root
    response_root = request(api_type, payload, "v1", "xml")
    response_root_auth = request(api_type, payload_auth, "v1", "xml")

    icons_current_count = 0
    x = True
    while x == True:
        try:
            icons_current_count += 1
            tag_attribs = all_tag_attrib(response_root, 'icon',
                                         str(icons_current_count))
            value_of_attrib = attrib_value(tag_attribs, 'id')
            assert word_count(value_of_attrib) >= 1
            assert icons_current_count <= icon_count
        except AttributeError:
            x = False
            icons_current_count -= 1
            assert icons_current_count > 0

    # Choose random icon between min and max
    icon_number = str(random_between_values(1, icons_current_count))

    # Action before class
    def setup_class(cls):
        print("\n>>> Class Setup")

    #  Action after class
    def teardown_class(cls):
        print("\n>>> Class Teardown")
Ejemplo n.º 5
0
class ContextSuggestApi(object):

    #settings
    api_type = 'suggest'
    term = random_list_value(['google', 'facebook', 'space', 'ball', 'car'])
    amount = random_list_value(["", "5", "10", "15", "20"])
    platform = random_list_value(
        ["win8", "ios7", "android", "androidL", "color", "win10", "office"])
    payload = {'term': term, 'amount': amount, 'platform': platform}
    payload_auth = {
        'term': term,
        'amount': amount,
        'platform': platform,
        'auth-id': auth_id
    }

    print('''Suggest v1 tests: term - %s, amount - %s, platform - %s''' %
          (term, amount, platform))

    term_count = 25

    # Do Request and return response root
    response_root = request(api_type, payload, "v1", "xml")
    response_root_auth = request(api_type, payload_auth, "v1", "xml")

    term_current_count = 0
    x = True
    while x == True:
        try:
            term_current_count += 1
            tag_attribs = all_tag_attrib(response_root, 'suggests/term',
                                         str(term_current_count))
            value_of_attrib = attrib_value(tag_attribs, 'count')
            assert word_count(value_of_attrib) >= 1
            assert term_current_count <= term_count
        except AttributeError:
            x = False
            term_current_count -= 1
            assert term_current_count > 0
    # Choose random icon between min and max
    if term_current_count == 1:
        term_number = term_current_count
    else:
        term_number = str(random_between_values(2, term_current_count))

    # Action before class
    def setup_class(cls):
        print("\n>>> Class Setup")

    #  Action after class
    def teardown_class(cls):
        print("\n>>> Class Teardown")
Ejemplo n.º 6
0
class ContextTotalApiJson(object):

    # icon id what will be in request
    year = random_list_value(["14", "15", "16"])
    month = random_between_values(1, 12)
    day = random_between_values(1, 31)
    since = '20%s-%s-%s' % (year, month, day)
    print('''Total v2 Json tests: since - %s''' % (since))
    payload = {'since': since}
    payload_auth = {'since': since, 'auth-id': auth_id}

    # Do Request and return response root
    response_root = request('total', payload, "v3", "json")
    response_root_auth = request('total', payload_auth, "v3", "json")

    # Action before class
    def setup_class(cls):
        print("\n>>> Class Setup")

    #  Action after class
    def teardown_class(cls):
        print("\n>>> Class Teardown")
Ejemplo n.º 7
0
class ContextSearchDefaultApi(object):

    #settings
    api_type = 'search'
    term = random_list_value(['google', 'facebook', 'car'])
    payload = {'term': term, 'amount': '', 'offset': '', 'platform': ''}
    payload_auth = {
        'term': term,
        'amount': '',
        'offset': '',
        'platform': '',
        'auth-id': auth_id
    }
    search_platform = random_list_value(
        ["win8", "android", "color", "win10", "office"])

    print(
        '''Search v1 default tests: term - %s, amount - %s , offset - %s, platform - %s'''
        % (term, '', '', ''))

    icon_count = 25

    # Do Request and return response root
    response_root = request(api_type, payload, "v1", "xml")
    response_root_auth = request(api_type, payload_auth, "v1", "xml")

    icons_current_count = 0
    x = True
    while x == True:
        try:
            icons_current_count += 1
            tag_attribs = all_tag_attrib(response_root, 'icon',
                                         str(icons_current_count))
            value_of_attrib = attrib_value(tag_attribs, 'id')
            assert word_count(value_of_attrib) >= 1
            assert icons_current_count <= icon_count
        except AttributeError:
            x = False
            icons_current_count -= 1
            assert icons_current_count > 0

    # Choose random icon between min and max
    icon_number = str(random_between_values(1, icon_count))

    # Action before class
    def setup_class(cls):
        print("\n>>> Class Setup")

    #  Action after class
    def teardown_class(cls):
        print("\n>>> Class Teardown")
Ejemplo n.º 8
0
class ContextIconApi(object):

    # Settings
    # icon id what will be in request
    icon_id = random.choice([str(random_between_values(1, 7500)),
                             str(random_between_values(9500, 20000))])

    print ('''Icon v1 tests: id - %s'''
           % icon_id)

    payload = {'id': icon_id}
    payload_auth = {'id': icon_id, 'auth-id': auth_id}

    # Do Request and return response root
    response_root = request('icon', payload, "v1", "xml")
    response_root_auth = request('icon', payload_auth, "v1", "xml")

    # Action before class
    def setup_class(cls):
        print("\n>>> Class Setup")

    #  Action after class
    def teardown_class(cls):
        print("\n>>> Class Teardown")
Ejemplo n.º 9
0
class ContextCategoryApi(object):

    # settings
    api_type = 'category'

    category = random_list_value(
        ["City", "Food", "Travel", "Transport", "Weather"])
    amount = random_list_value(["", "5", "10", "15", "20"])
    offset = random_list_value(["", "5", "10", "15", "20"])
    platform = random_list_value(
        ["win8", "ios7", "android", "androidL", "color", "win10", "office"])
    attributes = ''

    payload = {
        'category': category,
        'amount': amount,
        'offset': offset,
        'platform': platform,
        'attributes': attributes
    }
    payload_auth = {
        'category': category,
        'amount': amount,
        'offset': offset,
        'platform': platform,
        'attributes': attributes,
        'auth-id': auth_id
    }

    print(
        '''Category v1 tests: category - %s, amount - %s , offset - %s, platform - %s, attributes - %s'''
        % (category, amount, offset, platform, attributes))

    icon_count = 100

    # Do Request and return response root
    response_root = request(api_type, payload, "v1", "xml")
    response_root_auth = request(api_type, payload_auth, "v1", "xml")

    icons_current_count = 0
    x = True
    while x is True:
        try:
            icons_current_count += 1
            tag_attribs = all_tag_attrib(response_root, 'icon',
                                         str(icons_current_count))
            value_of_attrib = attrib_value(tag_attribs, 'id')
            assert word_count(value_of_attrib) >= 1
            assert icons_current_count <= icon_count
        except AttributeError:
            x = False
            icons_current_count -= 1
            assert icons_current_count > 0

    # Choose random icon between min and max
    icon_number = str(random_between_values(1, icons_current_count))

    # Action before class
    def setup_class(cls):
        print("\n>>> Class Setup")

    #  Action after class
    def teardown_class(cls):
        print("\n>>> Class Teardown")