def test_pull_bzr(self): repo_fixture = fixture_setup.BzrRepo("bzr-source") self.useFixture(repo_fixture) project_dir = "asset-tracking-bzr" source_commit = repo_fixture.commit if self.source_commit else "" self.run_snapcraft(["pull", self.part_name], project_dir) state_file = os.path.join(self.parts_dir, self.part_name, "state", "pull") self.assertThat(state_file, FileExists()) self.assertThat( state_file, FileContains(matcher=Contains( dedent("""\ assets: build-packages: [] build-snaps: [] source-details: source: bzr-source source-branch: null source-commit: '{source_commit}' source-tag: {source_tag} stage-packages: [] """.format(source_commit=source_commit, source_tag=self.source_tag)))), )
def setUp(self): super().setUp() self.working_tree = "bzr-test" self.bzr_repo = fixture_setup.BzrRepo(self.working_tree) self.useFixture(self.bzr_repo) self.source_dir = "bzr-checkout" os.mkdir(self.source_dir) self.bzr = sources.Bazaar(self.working_tree, self.source_dir, silent=True) self.bzr.pull() self.source_details = self.bzr._get_source_details()
def test_pull_bzr(self): repo_fixture = fixture_setup.BzrRepo('bzr-source') self.useFixture(repo_fixture) project_dir = 'asset-tracking-bzr' part = self.part_name self.run_snapcraft(['pull', part], project_dir) state_file = os.path.join(self.parts_dir, part, 'state', 'pull') self.assertThat(state_file, FileExists()) with open(state_file) as f: state = yaml.load(f) self.assertIn('source-details', state.assets) if self.expected_details: self.assertThat( state.assets['source-details'][self.expected_details.field], Equals(self.expected_details.value)) else: self.assertThat(state.assets['source-details']['source-commit'], Equals(repo_fixture.commit))
def test_pull_bzr(self): repo_fixture = fixture_setup.BzrRepo("bzr-source") self.useFixture(repo_fixture) project_dir = "asset-tracking-bzr" part = self.part_name self.run_snapcraft(["pull", part], project_dir) state_file = os.path.join(self.parts_dir, part, "state", "pull") self.assertThat(state_file, FileExists()) with open(state_file) as f: state = yaml_utils.load(f) self.assertIn("source-details", state.assets) if self.expected_details: self.assertThat( state.assets["source-details"][self.expected_details.field], Equals(self.expected_details.value), ) else: self.assertThat( state.assets["source-details"]["source-commit"], Equals(repo_fixture.commit), )