Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate all platforms that have no tests #22096

Merged
merged 7 commits into from Mar 17, 2019

Conversation

@balloob
Copy link
Member

commented Mar 15, 2019

Description:

Move all platforms that have no tests to their own folders.

Moving forward, all new integrations should follow the new format.

import pathlib
import subprocess

path = pathlib.Path('./homeassistant/components/')
test_path = pathlib.Path('./tests/components/')

# Move platforms to proper component dir
whitelist = {
    'remote',
    'air_quality',
    'alarm_control_panel',
    'binary_sensor',
    'calendar',
    'camera',
    'climate',
    'cover',
    'device_tracker',
    'fan',
    'geo_location',
    'image_processing',
    'light',
    'lock',
    'mailbox',
    'media_player',
    'scene',
    'sensor',
    'switch',
    'vacuum',
    'water_heater',
    'weather',
}

# To limit the script to specific integrations
focus_integration = {}

for fil in path.glob('*/*.py'):
    if fil.parent.name not in whitelist:
        continue

    if fil.name in ('__init__.py', 'const.py', 'util.py', 'group.py', 'homeassistant.py', 'reproduce_state.py'):
        continue

    platform = fil.name.rsplit('.', 1)[0]
    component = fil.parent.name

    if focus_integration and platform not in focus_integration:
        continue

    comp_path = path / platform

    # Skip all platforms that have tests
    comp_test_path = test_path / component / f"test_{platform}.py"
    if comp_test_path.is_file():
        continue

    if not comp_path.is_dir():
        comp_path.mkdir()
        with open(comp_path / '__init__.py', 'w') as fp:
            fp.write(f"\"\"\"The {platform} component.\"\"\"\n")
    subprocess.run(f'git mv {fil} {comp_path / f"{component}.py"}', shell=True)

@balloob balloob requested a review from amelchio as a code owner Mar 15, 2019

@ghost ghost assigned balloob Mar 15, 2019

@ghost ghost added the in progress label Mar 15, 2019

@balloob balloob force-pushed the consolidate-more branch from c3c0587 to d9d939f Mar 15, 2019

@amelchio

This comment has been minimized.

Copy link
Contributor

commented Mar 15, 2019

This does not update CODEOWNERS but maybe that is intentional since it is harder to do automatically.

Do we need those documentation links that are generated by an algorithm anyone looking at the source code will be able to figure out?

@balloob

This comment has been minimized.

Copy link
Member Author

commented Mar 15, 2019

Fabian had dropped the links from the other integrations already.

About code owners, once all consolidated let's go through it and automate fixing it up.

@balloob balloob requested review from Kane610 and rohankapoorcom as code owners Mar 16, 2019

@robbiet480

This comment has been minimized.

Copy link
Member

commented Mar 16, 2019

What should we be reviewing here exactly? Just making sure that paths make sense?

@balloob

This comment has been minimized.

Copy link
Member Author

commented Mar 16, 2019

Nothing. We've used the script a couple of times already.

balloob added some commits Mar 15, 2019

@balloob balloob force-pushed the consolidate-more branch from cf9bbfd to d923190 Mar 16, 2019

@balloob

This comment has been minimized.

Copy link
Member Author

commented Mar 16, 2019

Ugh, okay, so the failing tests now are because the integration name and the python package have the same name. So to work around that, will use importlib.

@balloob

This comment has been minimized.

Copy link
Member Author

commented Mar 16, 2019

When tests pass, feel free to merge this.

@awarecan

This comment has been minimized.

Copy link
Contributor

commented Mar 16, 2019

Need change .coveragerc file as well

@balloob

This comment has been minimized.

Copy link
Member Author

commented Mar 17, 2019

Updated .coveragerc and CODEOWNERS. Did a git show <commit sha>, took the rename from and rename to lines to replace that in the two files.

@balloob balloob merged commit f507618 into dev Mar 17, 2019

5 of 7 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
Hound No violations found. Woof!
Python 3.5 - tests Python 3.5 - tests
Details
Python 3.6 - tests Python 3.6 - tests
Details
Python 3.7 - tests Python 3.7 - tests
Details
cla-bot Everyone involved has signed the CLA

@ghost ghost removed the in progress label Mar 17, 2019

@delete-merged-branch delete-merged-branch bot deleted the consolidate-more branch Mar 17, 2019

@balloob balloob referenced this pull request Apr 3, 2019

Merged

0.91.0 #22688

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.