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

Add models for automation rules #5323

Merged
merged 38 commits into from
May 21, 2019
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2ae80d1
Add models for automation rules
stsewd Feb 20, 2019
d0e04e0
Merge branch 'master' into add-models-for-automationrules
stsewd Feb 28, 2019
d53bad2
Use django-polymorphic with proxy models
stsewd Feb 28, 2019
d287286
Add migration
stsewd Feb 28, 2019
c5e6010
Merge branch 'master' into add-models-for-automationrules
stsewd Mar 4, 2019
cb5e1b9
Refactor and suggestions from review
stsewd Mar 4, 2019
4fd56f6
Update migration
stsewd Mar 4, 2019
e570a58
Implement activation action
stsewd Mar 4, 2019
353bc8a
Clean model
stsewd Mar 4, 2019
7a60668
Tests!
stsewd Mar 4, 2019
409e960
Refactor name
stsewd Mar 4, 2019
8f58e77
Refactor models
stsewd Mar 4, 2019
8dfe290
Integrate in admin
stsewd Mar 4, 2019
0d4ab95
Merge branch 'master' into add-models-for-automationrules
stsewd Mar 6, 2019
74f1b9a
Don't search for project.name
stsewd Mar 6, 2019
7936f55
Merge branch 'master' into add-models-for-automationrules
stsewd Apr 1, 2019
4c77043
Merge branch 'master' into add-models-for-automationrules
stsewd Apr 25, 2019
11add5d
Return explicitly a boolean
stsewd Apr 25, 2019
5e90f62
Use action_arg from self
stsewd Apr 25, 2019
0903763
Add set default version action
stsewd Apr 25, 2019
26fc59b
Fix migrations
stsewd Apr 25, 2019
7660b86
Typo
stsewd Apr 26, 2019
a2c50ac
Execute automation rules on new versions
stsewd Apr 26, 2019
0f06958
Typo
stsewd Apr 26, 2019
bf2f954
Trigger build after activate
stsewd Apr 26, 2019
73030c0
Better admin page
stsewd Apr 29, 2019
6237ca4
More tests
stsewd Apr 29, 2019
25faa28
More tests
stsewd Apr 29, 2019
eda1cd2
Test from api call
stsewd Apr 29, 2019
39c8cc5
Tests for set_default_version
stsewd Apr 29, 2019
a6d959d
Fix test
stsewd Apr 29, 2019
2ae831d
Docs
stsewd Apr 29, 2019
78e6e62
Period
stsewd Apr 29, 2019
5d0c706
Merge branch 'master' into add-models-for-automationrules
stsewd Apr 29, 2019
b2a1339
Merge branch 'master' into add-models-for-automationrules
stsewd May 9, 2019
b07b660
Notes about the versions order
stsewd May 9, 2019
a86d427
Merge branch 'master' into add-models-for-automationrules
stsewd May 20, 2019
cbce26a
Fix mock
stsewd May 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tests!
  • Loading branch information
stsewd committed Mar 4, 2019
commit 7a60668b7aadb2b65b2438c0f35c3f0ed2b596a8
85 changes: 85 additions & 0 deletions readthedocs/rtd_tests/tests/test_automation_rules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import pytest
from django_dynamic_fixture import get

from readthedocs.builds.constants import BRANCH, TAG
from readthedocs.builds.models import (
RegexAutomationRule,
Version,
VersionAutomationRule,
)
from readthedocs.projects.models import Project


@pytest.mark.django_db
class TestRegexAutomationRules:

@pytest.fixture(autouse=True)
def setup_method(self):
self.project = get(Project)

@pytest.mark.parametrize(
'version_name,regex,result',
[
# Matches all
('master', r'.*', True),
('latest', r'.*', True),

# Contains match
('master', r'master', True),
('master-something', r'master', True),
('something-master', r'master', True),
('foo', r'master', False),

# Starts with match
('master', r'^master', True),
('master-foo', r'^master', True),
('foo-master', r'^master', False),

# Ends with match
('master', r'master$', True),
('foo-master', r'master$', True),
('master-foo', r'master$', False),

# Exact match
('master', r'^master$', True),
('masterr', r'^master$', False),
('mmaster', r'^master$', False),

# Match versions from 1.3.x series
('1.3.2', r'^1\.3\..*', True),
('1.3.3.5', r'^1\.3\..*', True),
('1.3.3-rc', r'^1\.3\..*', True),
('1.2.3', r'^1\.3\..*', False),

# Some special regex scape characters
('12-a', r'^\d{2}-\D$', True),
('1-a', r'^\d{2}-\D$', False),

# Groups
('1.3-rc', r'^(\d\.?)*-(\w*)$', True),

# Bad regex
('master', r'*', False),
('master', r'?', False),
]
)
@pytest.mark.parametrize('version_type', [BRANCH, TAG])
def test_action_activation_match(
self, version_name, regex, result, version_type):
version = get(
Version,
verbose_name=version_name,
project=self.project,
active=False,
type=version_type,
)
rule = get(
RegexAutomationRule,
project=self.project,
priority=0,
match_arg=regex,
action=VersionAutomationRule.ACTIVATE_VERSION_ACTION,
version_type=version_type,
)
assert rule.run(version) is result
assert version.active is result