예제 #1
0
    'sublime-merge',  # Purposefully 404's
    'atom',  # Purposefully 404's
    'slack'  # Purposefully 404's
]

# Dictonary of URLs. Unique to prevent duplicates.
# urls["http://example.com"] = 1
urls = {}

# Load Applications JSON
json_path = os.path.join(test.repo_root, 'data/js/applications.json')
try:
    with open(json_path) as data_file:
        index = json.load(data_file)
except Exception as reason:
    test.error('Cannot open applications.json due to load error.')
    test.end()

# Test each source and PPA
categories = list(index.keys())
categories.sort()
for category in categories:
    category_items = list(index[category].keys())
    category_items.sort()
    for program_id in category_items:
        app = index[category][program_id]

        try:
            if app['working'] == False:
                continue
        except:
###############################################
test.start()

valid_distro_codenames = [
    'trusty', 'xenial', 'artful', 'bionic', 'disco', 'eoan', 'focal', 'groovy',
    'hirsute', 'impish', 'jammy'
]
valid_arch = ['i386', 'amd64', 'armhf', 'arm64']

# Load Applications JSON
json_path = os.path.join(test.repo_root, 'data/js/applications.json')
try:
    with open(json_path) as data_file:
        index = json.load(data_file)
except Exception as reason:
    test.error('Syntax Error in "applications.json": ' + str(reason))
    # The test can't continue.
    test.error('Cannot open applications.json due to load error!')
    test.end()

# Check each application in index for correct data structure
categories = list(index.keys())
categories.sort()
for category in categories:
    category_items = list(index[category].keys())
    category_items.sort()

    for program_id in category_items:
        app = index[category][program_id]

        # Known Repositories listing contains minimal data.
html_pages = []
for page in pages:
    page = page.split('/')[-1]
    page = page.split('.html')[0]
    html_pages.append(page)

# Check each page's POT file
for page in html_pages:
    pot_path = os.path.join(template_dir, page, page + '.pot')

    with open(pot_path, 'r') as f:
        pot_data = f.read()

    # Search for code strings
    bad_strings = [
        '<span', '<b>', '</b>', '</span>', '<a', 'height=', 'width=', '<p',
        'class=', 'id='
    ]

    for syntax in bad_strings:
        results = pot_data.find(syntax)
        if results != -1:
            test.error(
                'Found bad syntax containing "{0}" in "{1}" at character {2}.'.
                format(syntax, page, results))

###############################################
# END OF TEST
###############################################
test.end()
#  (C) Luke Horwell, Revised Jun 2016
#

import common.testing as test
test.name = 'JSON Syntax Check'

import os
import json

###############################################
# START OF TEST
###############################################
test.start()

json_files = ['data/js/applications.json', 'data/js/news.json']

# Check each JSON file is free from syntax errors.
for json_path in json_files:
    try:
        path = os.path.join(test.repo_root, json_path)
        with open(json_path) as data_file:
            index = json.load(data_file)
    except Exception as reason:
        test.error('Syntax Error in "' + json_path + '". ')
        test.error('-- ' + str(reason))

###############################################
# END OF TEST
###############################################
test.end()
예제 #5
0
#
#  Copyright (C) 2016-2017 Luke Horwell <*****@*****.**>
#

import os
import json
import common.testing as test

# Load Applications JSON
path = os.path.join(test.repo_root, 'data/apps/index/en.json' )
try:
    with open(path) as f:
        data = json.load(f)

except Exception as reason:
    test.error('Syntax Error in "applications.json": ' + str(reason))
    test.error('Cannot proceed with this test!')
    test.end()

# Variables containing useful data
categories = list(data.keys())

# Function for getting information from the index.
def get(requested_id, attribute):
    ''' Retrieves a specific attribute from a listed application, without specifying its category. '''
    for category in categories:
        category_items = list(data[category].keys())
        for program_id in category_items:
            if program_id == requested_id:
                if not attribute == 'category':
                    return data[category][program_id][attribute]
import os
import glob

###############################################
# START OF TEST
###############################################
test.start()

# Where are they?
app_icons = os.path.join(test.repo_root, 'data/img/applications/')
app_scnsht = os.path.join(test.repo_root, 'data/img/applications/screenshots/')

icon_list   = glob.glob(app_icons + '*.jpg') + glob.glob(app_icons + '*.jpeg')
scnsht_list = glob.glob(app_scnsht + '*.png')

if len(icon_list) > 0:
    for filename in icon_list:
        filename = filename.split('/')[-1]
        test.error("Wrong extension for application icon: " + filename)

if len(scnsht_list) > 0:
    for filename in scnsht_list:
        filename = filename.split('/')[-1]
        test.error("Wrong extension for application screenshot: " + filename)

###############################################
# END OF TEST
###############################################
test.end()
예제 #7
0
templates = os.listdir(template_dir)
pages = glob.glob(page_dir + '*.html')

# Only get the page name, no paths or extensions
html_pages = []
excluded_pages = ["message"]
for page in pages:
    page = page.split('/')[-1]
    page = page.split('.html')[0]
    if page not in excluded_pages:
        html_pages.append(page)

# Check each page has a template
for page in html_pages:
    if not os.path.exists(os.path.join(template_dir, page, page + '.pot')):
        test.error("No POT for page: " + page)

# Check pages are being translated on Transifex

tx_path = os.path.join(test.repo_root, '.tx/config')
with open(tx_path, 'r') as f:
    tx_file = f.read()

for page in html_pages:
    if tx_file.find('[ubuntu-mate-welcome.' + page + ']') == -1:
        test.warning("Template not on Transifex: " + page)

###############################################
# END OF TEST
###############################################
test.end()