예제 #1
0
 def test_returns_unknown_if_version_is_empty_and_not_git_repo(self):
     mock_version = self.patch(version, "get_version_from_apt")
     mock_version.return_value = ""
     mock_repo_hash = self.patch(version, "get_maas_repo_hash")
     mock_repo_hash.return_value = None
     self.assertEqual((old_version, "unknown"),
                      version.get_maas_version_subversion())
예제 #2
0
 def test__returns_unknown_if_version_is_empty_and_not_bzr_branch(self):
     mock_version = self.patch(version, "get_version_from_apt")
     mock_version.return_value = ""
     mock_branch_version = self.patch(version, "get_maas_branch_version")
     mock_branch_version.return_value = None
     self.assertEqual((old_version, "unknown"),
                      version.get_maas_version_subversion())
예제 #3
0
 def test_returns_package_version(self):
     mock_apt = self.patch(version, "get_version_from_apt")
     mock_apt.return_value = "1.8.0~alpha4+bzr356-0ubuntu1"
     self.assertEqual(
         ("1.8.0~alpha4", "bzr356-0ubuntu1"),
         version.get_maas_version_subversion(),
     )
예제 #4
0
 def test_get_maas_version_tuple(self):
     mock_repo_hash = self.patch(version, "get_maas_repo_hash")
     mock_repo_hash.return_value = None
     self.assertEqual(
         ".".join([str(i) for i in version.get_maas_version_tuple()]),
         version.get_maas_version_subversion()[0],
     )
예제 #5
0
 def test__returns_from_source_and_revno_from_branch(self):
     mock_version = self.patch(version, "get_version_from_apt")
     mock_version.return_value = ""
     mock_repo_hash = self.patch(version, "get_maas_repo_hash")
     mock_repo_hash.return_value = 'deadbeef'
     self.assertEqual(("%s from source" % old_version, 'git+deadbeef'),
                      version.get_maas_version_subversion())
예제 #6
0
 def test__returns_from_source_and_revno_from_branch(self):
     mock_version = self.patch(version, "get_version_from_apt")
     mock_version.return_value = ""
     revno = random.randint(1, 5000)
     mock_branch_version = self.patch(version, "get_maas_branch_version")
     mock_branch_version.return_value = revno
     self.assertEqual(("%s from source" % old_version, "bzr%d" % revno),
                      version.get_maas_version_subversion())
예제 #7
0
 def read(self, request):
     """Version and capabilities of this MAAS instance."""
     version, subversion = get_maas_version_subversion()
     version_info = {
         'capabilities': API_CAPABILITIES_LIST,
         'version': version,
         'subversion': subversion,
     }
     return HttpResponse(json.dumps(version_info),
                         content_type='application/json; charset=utf-8',
                         status=int(http.client.OK))
예제 #8
0
    def read(self, request):
        """@description-title MAAS version information
        @description Read version and capabilities of this MAAS instance.

        @success (http-status-code) "server-success" 200
        @success (json) "success-json" A JSON object containing MAAS version
        and capabilities information.
        @success-example "success-json" [exkey=version] placeholder text
        """
        version, subversion = get_maas_version_subversion()
        version_info = {
            'capabilities': API_CAPABILITIES_LIST,
            'version': version,
            'subversion': subversion,
        }
        return HttpResponse(json.dumps(version_info),
                            content_type='application/json; charset=utf-8',
                            status=int(http.client.OK))
예제 #9
0
 def test_get_maas_version_tuple(self):
     self.assertEquals(
         '.'.join([str(i) for i in version.get_maas_version_tuple()]),
         version.get_maas_version_subversion()[0])