<commit_before>import datetime
import dateutil.parser

from nose.tools import nottest

from ...testcases import DustyIntegrationTestCase
from ...fixtures import specs_fixture_with_depends

class TestRestartCli(DustyIntegrationTestCase):
    def setUp(self):
        super(TestRestartCli, self).setUp()
        specs_fixture_with_depends()
        self.run_command('bundles activate bundle-a bundle-b')
        self.run_command('up')
        self.up_complete_time = datetime.datetime.now()

    def tearDown(self):
        try:
            self.run_command('stop')
        except Exception:
            pass
        super(TestStopCLI, self).tearDown()

    @nottest
    def container_has_restarted(self, app_name):
        inspected = self.inspect_container(app_name)
        start_time = dateutil.parser.parse(inspected['State']['StartedAt'])
        return start_time > self.up_complete_time

    def test_restart_one(self):
        self.run_command('restart app-a')
        self.assertTrue(self.container_has_restarted('app-a'))<commit_msg>restart all plus setup local repos<commit_after>import datetime
import dateutil.parser

from nose.tools import nottest

from dusty.compiler.spec_assembler import get_all_repos
from ...testcases import DustyIntegrationTestCase
from ...fixtures import specs_fixture_with_depends

class TestRestartCli(DustyIntegrationTestCase):
    def setUp(self):
        super(TestRestartCli, self).setUp()
        specs_fixture_with_depends()
        for repo in get_all_repos():
            self._set_up_fake_local_repo(path=repo.local_path)
        self.run_command('bundles activate bundle-a bundle-b')
        self.run_command('up')
        self.up_complete_time = datetime.datetime.now()

    def tearDown(self):
        try:
            self.run_command('stop')
        except Exception:
            pass
        super(TestStopCLI, self).tearDown()

    @nottest
    def container_has_restarted(self, app_name):
        inspected = self.inspect_container(app_name)
        start_time = dateutil.parser.parse(inspected['State']['StartedAt'])
        return start_time > self.up_complete_time

    def test_restart_one(self):
        self.run_command('restart app-a')
        self.assertTrue(self.container_has_restarted('app-a'))
        self.assertTrue(not self.container_has_restarted('app-b'))
        self.assertTrue(not self.container_has_restarted('app-c'))

    def test_restart_all(self):
        self.run_command('restart')
        self.assertTrue(self.container_has_restarted('app-a'))
        self.assertTrue(self.container_has_restarted('app-b'))
        self.assertTrue(self.container_has_restarted('app-c'))
{'fraction_non_alphanumeric': 0.0998869204673954, 'fraction_numerical': 0.0, 'mean_word_length': 3.453020134228188, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '915548', 'n_tokens_mistral': 822, 'n_tokens_neox': 810, 'n_words': 133}