• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

safe-global / safe-config-service / 8420893675

25 Mar 2024 01:28PM UTC coverage: 99.891%. Remained the same
8420893675

Pull #1072

github

web-flow
Bump black from 24.2.0 to 24.3.0

Bumps [black](https://github.com/psf/black) from 24.2.0 to 24.3.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](https://github.com/psf/black/compare/24.2.0...24.3.0)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #1072: Bump black from 24.2.0 to 24.3.0

4581 of 4586 relevant lines covered (99.89%)

1.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.55
/src/chains/migrations/tests/utils.py
1
from django.apps import apps
1✔
2
from django.db import connection
1✔
3
from django.db.migrations.executor import MigrationExecutor
1✔
4
from django.db.migrations.state import StateApps
1✔
5
from django.test import TestCase
1✔
6

7

8
# Use this TestCase class in order to test migrations
9
# migrate_from – the name of the migration where the test starts
10
# migrate_to – the target migration
11
#
12
# Example:
13
# You can set models on a specific migration inside your implementation of setUpBeforeMigration()
14
# The validation can then be performed on each test function of the Test class
15
# This class is heavily inspired by https://www.caktusgroup.com/blog/2016/02/02/writing-unit-tests-django-migrations/
16
class TestMigrations(TestCase):
1✔
17
    @property
1✔
18
    def app(self) -> str:
1✔
19
        app_config = apps.get_containing_app_config(type(self).__module__)
1✔
20
        if app_config is None:
1✔
21
            raise Exception("Could not retrieve app configuration")  # pragma: no cover
×
22
        return app_config.name
1✔
23

24
    migrate_from: str
1✔
25
    migrate_to: str
1✔
26
    apps_registry: StateApps
1✔
27

28
    def setUp(self) -> None:
1✔
29
        assert (
30
            self.migrate_from and self.migrate_to
1✔
31
        ), "TestCase '{}' must define migrate_from and migrate_to     properties".format(
32
            type(self).__name__
33
        )
34
        migrate_from: tuple[str, str] = (self.app, self.migrate_from)
1✔
35
        migrate_to: tuple[str, str] = (self.app, self.migrate_to)
1✔
36
        executor = MigrationExecutor(connection)
1✔
37
        old_apps = executor.loader.project_state(migrate_from).apps
1✔
38

39
        # Reverse to the original migration
40
        executor.migrate([migrate_from])
1✔
41

42
        self.setUpBeforeMigration(old_apps)
1✔
43

44
        # Run the migration to test
45
        executor = MigrationExecutor(connection)
1✔
46
        executor.loader.build_graph()  # reload.
1✔
47
        executor.migrate([migrate_to])
1✔
48

49
        self.apps_registry = executor.loader.project_state(migrate_to).apps
1✔
50

51
    def setUpBeforeMigration(self, apps: StateApps) -> None:
1✔
52
        pass  # pragma: no cover
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc